MCPcopy
hub / github.com/etcd-io/etcd / TestEmbedEtcdStopDuringBootstrapping

Function TestEmbedEtcdStopDuringBootstrapping

tests/integration/embed/embed_test.go:223–263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

221}
222
223func TestEmbedEtcdStopDuringBootstrapping(t *testing.T) {
224 integration2.BeforeTest(t, integration2.WithFailpoint("beforePublishing", `sleep("2s")`))
225
226 done := make(chan struct{})
227 go func() {
228 defer close(done)
229
230 cfg := embed.NewConfig()
231 urls := newEmbedURLs(false, 2)
232 setupEmbedCfg(cfg, []url.URL{urls[0]}, []url.URL{urls[1]})
233 cfg.Dir = filepath.Join(t.TempDir(), "embed-etcd")
234
235 e, err := embed.StartEtcd(cfg)
236 if err != nil {
237 t.Errorf("Failed to start etcd, got error %v", err)
238 }
239 defer e.Close()
240
241 go func() {
242 time.Sleep(time.Second)
243 e.Server.Stop()
244 t.Log("Stopped server during bootstrapping")
245 }()
246
247 select {
248 case <-e.Server.ReadyNotify():
249 t.Log("Server is ready!")
250 case <-e.Server.StopNotify():
251 t.Log("Server is stopped")
252 case <-time.After(20 * time.Second):
253 e.Server.Stop() // trigger a shutdown
254 t.Error("Server took too long to start!")
255 }
256 }()
257
258 select {
259 case <-done:
260 case <-time.After(10 * time.Second):
261 t.Error("timeout in bootstrapping etcd")
262 }
263}

Callers

nothing calls this directly

Calls 11

newEmbedURLsFunction · 0.70
setupEmbedCfgFunction · 0.70
BeforeTestMethod · 0.65
TempDirMethod · 0.65
ErrorfMethod · 0.65
CloseMethod · 0.65
StopMethod · 0.65
ErrorMethod · 0.65
LogMethod · 0.45
ReadyNotifyMethod · 0.45
StopNotifyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…