MCPcopy
hub / github.com/grpc/grpc-go / TestCZGetServer

Method TestCZGetServer

test/channelz_test.go:175–207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

173}
174
175func (s) TestCZGetServer(t *testing.T) {
176 e := tcpClearRREnv
177 te := newTest(t, e)
178 te.startServer(&testServer{security: e.security})
179 defer te.tearDown()
180
181 ss, _ := channelz.GetServers(0, 0)
182 if len(ss) != 1 {
183 t.Fatalf("there should only be one server, not %d", len(ss))
184 }
185
186 serverID := ss[0].ID
187 srv := channelz.GetServer(serverID)
188 if srv == nil {
189 t.Fatalf("server %d does not exist", serverID)
190 }
191 if srv.ID != serverID {
192 t.Fatalf("server want id %d, but got %d", serverID, srv.ID)
193 }
194
195 te.tearDown()
196
197 if err := verifyResultWithDelay(func() (bool, error) {
198 srv := channelz.GetServer(serverID)
199 if srv != nil {
200 return false, fmt.Errorf("server %d should not exist", serverID)
201 }
202
203 return true, nil
204 }); err != nil {
205 t.Fatal(err)
206 }
207}
208
209func (s) TestCZGetSocket(t *testing.T) {
210 e := tcpClearRREnv

Callers

nothing calls this directly

Calls 9

GetServersFunction · 0.92
GetServerFunction · 0.92
newTestFunction · 0.70
verifyResultWithDelayFunction · 0.70
FatalfMethod · 0.65
ErrorfMethod · 0.65
FatalMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45

Tested by

no test coverage detected