(t *testing.T)
| 221 | } |
| 222 | |
| 223 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…