diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-07-03 11:33:20 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-07-03 11:34:15 -0700 |
commit | c1b4c1ffee850aea2880f5f91a1e48e840933c71 (patch) | |
tree | 9729eb5a2eea93103c65485adce4594dbf9b6117 | |
parent | 062a6f6ec5f4bf2ce46790a22d8e7278d51e6836 (diff) |
Fix flaky image_test
- Some failures were being ignored in run_tests.sh
- Give more time for mysql to setup
- Fix typo with network=host tests
- Change httpd test to wait on http server being available, not only output
PiperOrigin-RevId: 203156896
Change-Id: Ie1801dcd76e9b5fe4722c4d8695c76e40988dd74
-rwxr-xr-x | kokoro/gcp_ubuntu/run_tests.sh | 15 | ||||
-rw-r--r-- | runsc/test/image/BUILD | 2 | ||||
-rw-r--r-- | runsc/test/image/image_test.go | 14 |
3 files changed, 17 insertions, 14 deletions
diff --git a/kokoro/gcp_ubuntu/run_tests.sh b/kokoro/gcp_ubuntu/run_tests.sh index 5554350da..978a21599 100755 --- a/kokoro/gcp_ubuntu/run_tests.sh +++ b/kokoro/gcp_ubuntu/run_tests.sh @@ -44,12 +44,15 @@ bazel test --test_output=errors //... exit_code=${?} if [[ ${exit_code} -eq 0 ]]; then - # image_test is tagged manual - bazel test --test_output=errors --test_env=RUNSC_RUNTIME=${runtime} //runsc/test/image:image_test - bazel test --test_output=errors --test_env=RUNSC_RUNTIME=${runtime}-kvm //runsc/test/image:image_test - bazel test --test_output=errors --test_env=RUNSC_RUNTIME=${runtime}-nethost //runsc/test/image:image_test - bazel test --test_output=errors --test_env=RUNSC_RUNTIME=${runtime}-overlay //runsc/test/image:image_test - exit_code=${?} + declare -a variations=("" "-kvm" "-hostnet" "-overlay") + for v in "${variations[@]}"; do + # image_test is tagged manual + bazel test --test_output=errors --test_env=RUNSC_RUNTIME=${runtime}${v} //runsc/test/image:image_test + exit_code=${?} + if [[ ${exit_code} -ne 0 ]]; then + break + fi + done fi # Best effort to uninstall diff --git a/runsc/test/image/BUILD b/runsc/test/image/BUILD index fb9db4d4c..8fdaa1e5c 100644 --- a/runsc/test/image/BUILD +++ b/runsc/test/image/BUILD @@ -4,7 +4,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_test( name = "image_test", - size = "small", + size = "large", srcs = ["image_test.go"], data = [ "latin10k.txt", diff --git a/runsc/test/image/image_test.go b/runsc/test/image/image_test.go index 849bf76a2..ed2111107 100644 --- a/runsc/test/image/image_test.go +++ b/runsc/test/image/image_test.go @@ -156,7 +156,7 @@ func (d *docker) waitForOutput(pattern string, timeout time.Duration) error { // Success! return nil } - time.Sleep(10 * time.Millisecond) + time.Sleep(100 * time.Millisecond) } return fmt.Errorf("timeout waiting for output %q: %s", re.String(), out) } @@ -168,7 +168,7 @@ func (d *docker) waitForHTTP(port int, timeout time.Duration) error { // Success! return nil } - time.Sleep(10 * time.Millisecond) + time.Sleep(100 * time.Millisecond) } return fmt.Errorf("timeout waiting for HTTP server on port %d", port) } @@ -238,8 +238,8 @@ func TestHttpd(t *testing.T) { } // Wait until it's up and running. - if err := d.waitForOutput("'httpd -D FOREGROUND'", 5*time.Second); err != nil { - t.Fatalf("docker.WaitForOutput() timeout: %v", err) + if err := d.waitForHTTP(port, 5*time.Second); err != nil { + t.Fatalf("docker.WaitForHTTP() timeout: %v", err) } if err := testHTTPServer(port); err != nil { @@ -287,7 +287,7 @@ func TestMysql(t *testing.T) { defer d.cleanUp() // Wait until it's up and running. - if err := d.waitForOutput("port: 3306 MySQL Community Server", 30*time.Second); err != nil { + if err := d.waitForOutput("port: 3306 MySQL Community Server", 3*time.Minute); err != nil { t.Fatalf("docker.WaitForOutput() timeout: %v", err) } @@ -311,10 +311,10 @@ func TestMysql(t *testing.T) { defer client.cleanUp() // Ensure file executed to the end and shutdown mysql. - if err := client.waitForOutput("--------------\nshutdown\n--------------", 5*time.Second); err != nil { + if err := client.waitForOutput("--------------\nshutdown\n--------------", 15*time.Second); err != nil { t.Fatalf("docker.WaitForOutput() timeout: %v", err) } - if err := d.waitForOutput("mysqld: Shutdown complete", 15*time.Second); err != nil { + if err := d.waitForOutput("mysqld: Shutdown complete", 30*time.Second); err != nil { t.Fatalf("docker.WaitForOutput() timeout: %v", err) } } |