From 63ac4b5569e06e5fde91a1f8085afee8bf018417 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 2 Oct 2017 17:02:52 -0400 Subject: [PATCH] Skip all testdata in integration Also skip.IfCondition directly from the test, so that the skip message is correct Signed-off-by: Daniel Nephin Upstream-commit: 104c1c68438c5c59ab0e7a5fb2da6bae4ce6d080 Component: engine --- components/engine/hack/make/.integration-test-helpers | 2 +- .../integration/plugin/authz/authz_plugin_v2_test.go | 2 +- components/engine/integration/plugin/pkg_test.go | 1 + .../integration/util/requirement/requirement.go | 11 +++-------- 4 files changed, 6 insertions(+), 10 deletions(-) create mode 100644 components/engine/integration/plugin/pkg_test.go diff --git a/components/engine/hack/make/.integration-test-helpers b/components/engine/hack/make/.integration-test-helpers index af6e63f998..23780396e0 100644 --- a/components/engine/hack/make/.integration-test-helpers +++ b/components/engine/hack/make/.integration-test-helpers @@ -15,7 +15,7 @@ source "$SCRIPTDIR/make/.go-autogen" integration_api_dirs=${TEST_INTEGRATION_DIR:-"$( find ./integration -type d | - grep -vE '^(./integration($|/util|/testdata|/plugin$))')"} + grep -vE '(^./integration($|/util)|/testdata)')"} run_test_integration() { [[ "$TESTFLAGS" != *-check.f* ]] && run_test_integration_suites diff --git a/components/engine/integration/plugin/authz/authz_plugin_v2_test.go b/components/engine/integration/plugin/authz/authz_plugin_v2_test.go index 27ecbce5b6..d6c049813c 100644 --- a/components/engine/integration/plugin/authz/authz_plugin_v2_test.go +++ b/components/engine/integration/plugin/authz/authz_plugin_v2_test.go @@ -31,7 +31,7 @@ var ( func setupTestV2(t *testing.T) func() { skip.IfCondition(t, testEnv.DaemonInfo.OSType != "linux") - requirement.HasHubConnectivity(t) + skip.IfCondition(t, !requirement.HasHubConnectivity(t)) teardown := setupTest(t) diff --git a/components/engine/integration/plugin/pkg_test.go b/components/engine/integration/plugin/pkg_test.go new file mode 100644 index 0000000000..b0736c3a05 --- /dev/null +++ b/components/engine/integration/plugin/pkg_test.go @@ -0,0 +1 @@ +package plugin diff --git a/components/engine/integration/util/requirement/requirement.go b/components/engine/integration/util/requirement/requirement.go index 073a9f7c74..936b2ddded 100644 --- a/components/engine/integration/util/requirement/requirement.go +++ b/components/engine/integration/util/requirement/requirement.go @@ -5,21 +5,16 @@ import ( "strings" "testing" "time" - - "github.com/gotestyourself/gotestyourself/skip" ) // HasHubConnectivity checks to see if https://hub.docker.com is // accessible from the present environment -func HasHubConnectivity(t *testing.T) { +func HasHubConnectivity(t *testing.T) bool { // Set a timeout on the GET at 15s var timeout = 15 * time.Second var url = "https://hub.docker.com" - client := http.Client{ - Timeout: timeout, - } - + client := http.Client{Timeout: timeout} resp, err := client.Get(url) if err != nil && strings.Contains(err.Error(), "use of closed network connection") { t.Fatalf("Timeout for GET request on %s", url) @@ -27,5 +22,5 @@ func HasHubConnectivity(t *testing.T) { if resp != nil { resp.Body.Close() } - skip.IfCondition(t, err != nil) + return err == nil }