From b6417ad9460afdd75ed1ed5fe0bdd0d9cc490d50 Mon Sep 17 00:00:00 2001 From: Alexander Pavel Date: Tue, 18 Dec 2018 17:07:04 -0800 Subject: [PATCH 1/3] test/e2e/memcached_test.go: make tests work on forks --- .travis.yml | 2 +- test/e2e/memcached_test.go | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec6aa0f316a..8ecafbdad43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ jobs: # Build and test go - <<: *test name: Go on OpenShift - script: make test/ci-go + script: make test/ci-go ARGS="-v" # Build and test ansible - <<: *test diff --git a/test/e2e/memcached_test.go b/test/e2e/memcached_test.go index 008b6409bc5..3f08aa6724d 100644 --- a/test/e2e/memcached_test.go +++ b/test/e2e/memcached_test.go @@ -93,10 +93,16 @@ func TestMemcached(t *testing.T) { ctx.AddCleanupFn(func() error { return os.RemoveAll(absProjectPath) }) os.Chdir("memcached-operator") - prSlug, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SLUG") - if ok && prSlug != "" { - prSha, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SHA") - if ok && prSha != "" { + repo, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SLUG") + if repo == "" { + repo, ok = os.LookupEnv("TRAVIS_REPO_SLUG") + } + if ok && repo != "" && repo != "operator-framework/operator-sdk" { + commitSha, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SHA") + if commitSha == "" { + commitSha, ok = os.LookupEnv("TRAVIS_COMMIT") + } + if ok && commitSha != "" { gopkg, err := ioutil.ReadFile("Gopkg.toml") if err != nil { t.Fatal(err) @@ -111,7 +117,7 @@ func TestMemcached(t *testing.T) { // correctly. gopkgString := string(gopkg) gopkgLoc := strings.LastIndex(gopkgString, "\n name = \"github.com/operator-framework/operator-sdk\"\n") - gopkgString = gopkgString[:gopkgLoc] + "\n source = \"https://github.com/" + prSlug + "\"\n revision = \"" + prSha + "\"\n" + gopkgString[gopkgLoc+1:] + gopkgString = gopkgString[:gopkgLoc] + "\n source = \"https://github.com/" + repo + "\"\n revision = \"" + commitSha + "\"\n" + gopkgString[gopkgLoc+1:] err = ioutil.WriteFile("Gopkg.toml", []byte(gopkgString), fileutil.DefaultFileMode) if err != nil { t.Fatalf("failed to write updated Gopkg.toml: %v", err) @@ -124,7 +130,7 @@ func TestMemcached(t *testing.T) { } cmdOut, err = exec.Command("dep", "ensure").CombinedOutput() if err != nil { - t.Fatalf("error: %v\nCommand Output: %s\n", err, string(cmdOut)) + t.Fatalf("error after modifying Gopkg.toml: %v\nCommand Output: %s\n", err, string(cmdOut)) } // Set replicas to 2 to test leader election. In production, this should @@ -217,7 +223,7 @@ func TestMemcached(t *testing.T) { t.Fatalf("dep ensure failed: %v\nCommand Output:\n%v", err, string(cmdOut)) } // link local sdk to vendor if not in travis - if prSlug == "" { + if repo == "" { os.RemoveAll("vendor/github.com/operator-framework/operator-sdk/pkg") os.Symlink(filepath.Join(gopath, "src/github.com/operator-framework/operator-sdk/pkg"), "vendor/github.com/operator-framework/operator-sdk/pkg") From b655266c3791cf99cd0327480890b72167e994f4 Mon Sep 17 00:00:00 2001 From: Alexander Pavel Date: Tue, 18 Dec 2018 17:16:12 -0800 Subject: [PATCH 2/3] run test --- test/e2e/memcached_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/memcached_test.go b/test/e2e/memcached_test.go index 3f08aa6724d..8909f75b7e6 100644 --- a/test/e2e/memcached_test.go +++ b/test/e2e/memcached_test.go @@ -249,6 +249,7 @@ func TestMemcached(t *testing.T) { t.Run("ClusterTest", MemcachedClusterTest) t.Run("Local", MemcachedLocal) }) + } func memcachedLeaderTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) error { From a7a26e3cebfb2132ee2de07943e54651d6084c89 Mon Sep 17 00:00:00 2001 From: Alexander Pavel Date: Wed, 19 Dec 2018 10:46:16 -0800 Subject: [PATCH 3/3] test/e2e/memcached_test.go: remove extra newline The extra newline was added just to create a new commit to trigger travis. Removing it because we don't need it --- test/e2e/memcached_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/memcached_test.go b/test/e2e/memcached_test.go index 8909f75b7e6..3f08aa6724d 100644 --- a/test/e2e/memcached_test.go +++ b/test/e2e/memcached_test.go @@ -249,7 +249,6 @@ func TestMemcached(t *testing.T) { t.Run("ClusterTest", MemcachedClusterTest) t.Run("Local", MemcachedLocal) }) - } func memcachedLeaderTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) error {