From 33f29c730f46aacb56cb7710c31d19dbe0d5ff3f Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Tue, 19 Jun 2018 17:03:55 -0700 Subject: runsc: Fix flakey container_test. Verified that this is no longer flakey over 10K repetitions. PiperOrigin-RevId: 201267499 Change-Id: I793c916fe725412aec25953f764cb4f52c9fbed3 --- runsc/container/container_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runsc/container/container_test.go b/runsc/container/container_test.go index 7818990a7..7f87ea5ab 100644 --- a/runsc/container/container_test.go +++ b/runsc/container/container_test.go @@ -164,6 +164,7 @@ func TestLifecycle(t *testing.T) { if _, err := container.Create(id, spec, conf, bundleDir, "", ""); err != nil { t.Fatalf("error creating container: %v", err) } + // Load the container from disk and check the status. s, err := container.Load(rootDir, id) if err != nil { @@ -206,14 +207,17 @@ func TestLifecycle(t *testing.T) { go func() { ws, err := s.Wait() if err != nil { - t.Errorf("error waiting on container: %v", err) + t.Fatalf("error waiting on container: %v", err) } if got, want := ws.Signal(), syscall.SIGTERM; got != want { - t.Errorf("got signal %v, want %v", got, want) + t.Fatalf("got signal %v, want %v", got, want) } wg.Done() }() + // Wait a bit to ensure that we've started waiting on the container + // before we signal. + time.Sleep(5 * time.Second) // Send the container a SIGTERM which will cause it to stop. if err := s.Signal(syscall.SIGTERM); err != nil { t.Fatalf("error sending signal %v to container: %v", syscall.SIGTERM, err) -- cgit v1.2.3