用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill babuza-testcluster命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | babuza-testcluster |
| description | | Use when this capability is needed. |
Package:
github.com/fanaujie/babuza/test/testclusterFramework for orchestrating Babuza integration tests with network failure simulation.
You are an expert at testing distributed systems with babuza. Help users by:
testcluster.Refer to the local files for detailed scenarios:
./references/scenarios.md - Common testing patterns (partition, leadership transfer).Setup a cluster for direct network testing (no faults).
func TestClusterBasic(t *testing.T) {
// 1. Setup
storageDir := t.TempDir()
cluster := testcluster.CreateTestCluster(
1, storageDir, nil, createEmbeddedApp,
)
defer cluster.Teardown()
// 2. Create Peers
peerFactory := testcluster.NewPeerFactory(14200, 10000, 24200)
peers, group := peerFactory.MakeVotingStandardPeers(3)
// 3. Start
wait := cluster.RaftElectionTimeout() * 3
err := cluster.MakeCluster(wait, peers)
require.NoError(t, err)
// 4. Verify Leader
_, err = cluster.CheckOneLeader(wait, group.GetIDs())
require.NoError(t, err)
}
Use ProxyNetwork to simulate split-brain scenarios.
func TestPartition(t *testing.T) {
// 1. Setup with Proxy Network
proxy := proxynetwork.New()
cluster := testcluster.CreateTestCluster(1, dir, proxy, createApp)
// ... start cluster ...
// 2. Isolate Node 3 (Partition: {1,2}, {3})
cluster.SetPartition([]uint64{1, 2})
// 3. Verify Majority works
leader, _ := cluster.CheckOneLeader(wait, []uint64{1, 2})
// 4. Heal Partition
cluster.SetPartition([]uint64{1, 2, 3})
}
Inject latency or packet loss.
import "github.com/fanaujie/babuza/pkg/transport/protocol/tcp/networkio/proxynetwork"
// Add 50ms delay to Node 1
cluster.SetPeerFault(1, proxynetwork.FaultConfig{
DelayMin: 50 * time.Millisecond,
DelayMax: 50 * time.Millisecond,
})
// Add 20% packet loss to Node 2
cluster.SetPeerFault(2, proxynetwork.FaultConfig{
LossRate: 0.2,
})
// Restore
cluster.ClearPeerFault(1)
NewPeerFactory(raftBase, appBase, proxyBase)
raftBase: Start of Raft ports (e.g., 14200)appBase: Start of App Service ports (e.g., 10000)proxyBase: Start of Proxy ports (e.g., 24200)StandardPeer cannot simulate faults; BabuzaPeer (Proxy) is required.cluster.RaftElectionTimeout() * N for waiting, rather than hardcoded sleeps.defer cluster.Teardown().Converted and distributed by TomeVault — claim your Tome and manage your conversions.