MCPcopy
hub / github.com/olric-data/olric / addNode

Method addNode

internal/cluster/routingtable/routingtable_test.go:72–111  ·  view source on GitHub ↗
(c *config.Config)

Source from the content-addressed store, hash-verified

70}
71
72func (t *testCluster) addNode(c *config.Config) (*RoutingTable, error) {
73 if c == nil {
74 c = testutil.NewConfig()
75 }
76 port, err := testutil.GetFreePort()
77 if err != nil {
78 return nil, err
79 }
80 c.MemberlistConfig.BindPort = port
81
82 var peers []string
83 for _, peerPort := range t.peerPorts {
84 peers = append(peers, net.JoinHostPort("127.0.0.1", strconv.Itoa(peerPort)))
85 }
86 c.Peers = peers
87
88 srv := testutil.NewServer(c)
89 rt := newRoutingTableForTest(c, srv)
90 err = rt.Join()
91 if err != nil {
92 return nil, err
93 }
94 err = rt.Start()
95 if err != nil {
96 return nil, err
97 }
98
99 t.errGr.Go(func() error {
100 <-t.ctx.Done()
101 return srv.Shutdown(context.Background())
102 })
103
104 t.errGr.Go(func() error {
105 <-t.ctx.Done()
106 return rt.Shutdown(context.Background())
107 })
108
109 t.peerPorts = append(t.peerPorts, port)
110 return rt, err
111}
112
113func (t *testCluster) shutdown() error {
114 t.cancel()

Calls 8

ShutdownMethod · 0.95
NewConfigFunction · 0.92
GetFreePortFunction · 0.92
NewServerFunction · 0.92
newRoutingTableForTestFunction · 0.85
StartMethod · 0.65
ShutdownMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected