MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / createNode

Method createNode

store/engine/raft/node_test.go:66–81  ·  view source on GitHub ↗
(peers []string)

Source from the content-addressed store, hash-verified

64}
65
66func (c *TestCluster) createNode(peers []string) (*Node, error) {
67 randomPort := rand.Int31n(1024) + 20000
68 addr := fmt.Sprintf("http://127.0.0.1:%d", randomPort)
69 node, err := New(&Config{
70 ID: uint64(len(peers) + 1),
71 DataDir: fmt.Sprintf("/tmp/kvrocks/raft/%d", randomPort),
72 Peers: append(peers, addr),
73 HeartbeatSeconds: 1,
74 ElectionSeconds: 2,
75 })
76 if err != nil {
77 return nil, err
78 }
79 c.nodes = append(c.nodes, node)
80 return node, nil
81}
82
83func (c *TestCluster) AddNode(ctx context.Context, nodeID uint64, peer string) error {
84 if len(c.nodes) == 0 {

Callers 1

Calls 1

NewFunction · 0.70

Tested by

no test coverage detected