MCPcopy
hub / github.com/dgraph-io/dgraph / TestProposal

Function TestProposal

conn/node_test.go:51–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestProposal(t *testing.T) {
52 dir := t.TempDir()
53 store := raftwal.Init(dir)
54
55 rc := &pb.RaftContext{Id: 1}
56 n := NewNode(rc, store, nil)
57
58 peers := []raft.Peer{{ID: n.Id}}
59 n.SetRaft(raft.StartNode(n.Cfg, peers))
60
61 loop := 5
62 var wg sync.WaitGroup
63 wg.Add(loop)
64 go n.run(&wg)
65
66 for i := range loop {
67 data := []byte(fmt.Sprintf("hey-%d", i))
68 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
69 defer cancel()
70 require.NoError(t, n.Raft().Propose(ctx, data))
71 }
72 wg.Wait()
73}

Callers

nothing calls this directly

Calls 7

SetRaftMethod · 0.95
runMethod · 0.95
RaftMethod · 0.95
InitFunction · 0.92
NewNodeFunction · 0.85
WaitMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected