summaryrefslogtreecommitdiffhomepage
path: root/runsc/container/container_test.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-08-21 13:13:34 -0700
committerShentubot <shentubot@google.com>2018-08-21 13:14:43 -0700
commitd6d165cb0b8147461388287ffd4cfee221940123 (patch)
tree8beb9ea0e792c6691385f5b9d7ca65f0a1eaf9dc /runsc/container/container_test.go
parent9c407382b031f16160f83383ef8b0d419457829a (diff)
Initial change for multi-gofer support
PiperOrigin-RevId: 209647293 Change-Id: I980fca1257ea3fcce796388a049c353b0303a8a5
Diffstat (limited to 'runsc/container/container_test.go')
-rw-r--r--runsc/container/container_test.go47
1 files changed, 46 insertions, 1 deletions
diff --git a/runsc/container/container_test.go b/runsc/container/container_test.go
index a2da63afd..dadf8445b 100644
--- a/runsc/container/container_test.go
+++ b/runsc/container/container_test.go
@@ -350,7 +350,7 @@ func TestLifecycle(t *testing.T) {
// ourselves.
p, _ := os.FindProcess(s.Sandbox.Pid)
p.Wait()
- g, _ := os.FindProcess(s.Sandbox.GoferPid)
+ g, _ := os.FindProcess(s.GoferPid)
g.Wait()
// Load the container from disk and check the status.
@@ -1701,3 +1701,48 @@ func TestContainerVolumeContentsShared(t *testing.T) {
t.Errorf("stat %q got error %v, wanted ErrNotExist", filename, err)
}
}
+
+func TestGoferExits(t *testing.T) {
+ spec := testutil.NewSpecWithArgs("/bin/sleep", "10000")
+ conf := testutil.TestConfig()
+ rootDir, bundleDir, err := testutil.SetupContainer(spec, conf)
+ if err != nil {
+ t.Fatalf("error setting up container: %v", err)
+ }
+ defer os.RemoveAll(rootDir)
+ defer os.RemoveAll(bundleDir)
+
+ // Create and start the container.
+ c, err := container.Create(testutil.UniqueContainerID(), spec, conf, bundleDir, "", "")
+ if err != nil {
+ t.Fatalf("error creating container: %v", err)
+ }
+ defer c.Destroy()
+ if err := c.Start(conf); err != nil {
+ t.Fatalf("error starting container: %v", err)
+ }
+
+ sandboxProc, err := os.FindProcess(c.Sandbox.Pid)
+ if err != nil {
+ t.Fatalf("error finding sandbox process: %v", err)
+ }
+ gofer, err := os.FindProcess(c.GoferPid)
+ if err != nil {
+ t.Fatalf("error finding sandbox process: %v", err)
+ }
+
+ // Kill sandbox and expect gofer to exit on its own.
+ if err := sandboxProc.Kill(); err != nil {
+ t.Fatalf("error killing sandbox process: %v", err)
+ }
+ if _, err := sandboxProc.Wait(); err != nil {
+ t.Fatalf("error waiting for sandbox process: %v", err)
+ }
+
+ if _, err := gofer.Wait(); err != nil {
+ t.Fatalf("error waiting for gofer process: %v", err)
+ }
+ if c.IsRunning() {
+ t.Errorf("container shouldn't be running, container: %+v", c)
+ }
+}