From bf0ac565d2873069799082ad7bc3e3c43acbc593 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 3 May 2019 21:40:48 -0700 Subject: Fix runsc restore to be compatible with docker start --checkpoint ... Change-Id: I02b30de13f1393df66edf8829fedbf32405d18f8 PiperOrigin-RevId: 246621192 --- runsc/test/integration/integration_test.go | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'runsc/test/integration/integration_test.go') diff --git a/runsc/test/integration/integration_test.go b/runsc/test/integration/integration_test.go index 842f05545..de17dd3c2 100644 --- a/runsc/test/integration/integration_test.go +++ b/runsc/test/integration/integration_test.go @@ -148,6 +148,50 @@ func TestPauseResume(t *testing.T) { } } +func TestCheckpointRestore(t *testing.T) { + if !testutil.IsPauseResumeSupported() { + t.Log("Pause/resume is not supported, skipping test.") + return + } + if err := testutil.Pull("google/python-hello"); err != nil { + t.Fatal("docker pull failed:", err) + } + d := testutil.MakeDocker("save-restore-test") + if err := d.Run("-p", "8080", "google/python-hello"); err != nil { + t.Fatalf("docker run failed: %v", err) + } + defer d.CleanUp() + + if err := d.Checkpoint("test"); err != nil { + t.Fatal("docker checkpoint failed:", err) + } + + if _, err := d.Wait(30 * time.Second); err != nil { + t.Fatal(err) + } + + if err := d.Restore("test"); err != nil { + t.Fatal("docker restore failed:", err) + } + + // Find where port 8080 is mapped to. + port, err := d.FindPort(8080) + if err != nil { + t.Fatal("docker.FindPort(8080) failed:", err) + } + + // Wait until it's up and running. + if err := testutil.WaitForHTTP(port, 30*time.Second); err != nil { + t.Fatal("WaitForHTTP() timeout:", err) + } + + // Check if container is working again. + client := http.Client{Timeout: time.Duration(2 * time.Second)} + if err := httpRequestSucceeds(client, "localhost", port); err != nil { + t.Error("http request failed:", err) + } +} + // Create client and server that talk to each other using the local IP. func TestConnectToSelf(t *testing.T) { d := testutil.MakeDocker("connect-to-self-test") -- cgit v1.2.3