(peers []string)
| 64 | } |
| 65 | |
| 66 | func (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 | |
| 83 | func (c *TestCluster) AddNode(ctx context.Context, nodeID uint64, peer string) error { |
| 84 | if len(c.nodes) == 0 { |
no test coverage detected