runsc: Fix flakey container_test.

Verified that this is no longer flakey over 10K repetitions.

PiperOrigin-RevId: 201267499
Change-Id: I793c916fe725412aec25953f764cb4f52c9fbed3
This commit is contained in:
Kevin Krakauer
2018-06-19 17:04:51 -07:00
committed by Shentubot
parent be76cad5bc
commit 33f29c730f
+6 -2
View File
@@ -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)