From a752d1b5677f7085ec8563c504940e7d25475ea8 Mon Sep 17 00:00:00 2001 From: Alexander Pavel Date: Mon, 24 Sep 2018 13:15:47 -0700 Subject: [PATCH 1/2] test/e2e/memcached_test.go: fix dep issues in travis --- test/e2e/memcached_test.go | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/test/e2e/memcached_test.go b/test/e2e/memcached_test.go index 3591b31389..4c0dff3d00 100644 --- a/test/e2e/memcached_test.go +++ b/test/e2e/memcached_test.go @@ -22,6 +22,7 @@ import ( "os" "os/exec" "path" + "strings" "testing" "time" @@ -68,9 +69,30 @@ func TestMemcached(t *testing.T) { ctx.AddFinalizerFn(func() error { return os.RemoveAll(path.Join(gopath, "/src/github.com/example-inc/memcached-operator")) }) os.Chdir("memcached-operator") - os.RemoveAll("vendor/github.com/operator-framework/operator-sdk/pkg") - os.Symlink(path.Join(gopath, "/src/github.com/operator-framework/operator-sdk/pkg"), - "vendor/github.com/operator-framework/operator-sdk/pkg") + + prSlug, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SLUG") + if ok { + prSha, ok := os.LookupEnv("TRAVIS_PULL_REQUEST_SHA") + if ok { + gopkg, err := ioutil.ReadFile("Gopkg.toml") + if err != nil { + t.Fatal(err) + } + // TODO: make this match more complete in case we add another repo tracking master + gopkg = bytes.Replace(gopkg, []byte("branch = \"master\""), []byte("# branch = \"master\""), -1) + gopkgString := string(gopkg) + gopkgLoc := strings.LastIndex(gopkgString, "\n name = \"github.com/operator-framework/operator-sdk\"\n") + gopkgString = gopkgString[:gopkgLoc] + "\n source = \"" + prSlug + "\"\n revision = \"" + prSha + "\"\n" + gopkgString[gopkgLoc+1:] + err = ioutil.WriteFile("Gopkg.toml", []byte(gopkgString), os.FileMode(filemode)) + cmdOut, err = exec.Command("dep", "ensure").CombinedOutput() + if err != nil { + t.Fatalf("dep ensure after gopkg replace failed: %v\nCommand Output: %s\nGopkg Contents: %s", err, cmdOut, gopkgString) + } + } else { + t.Fatal("could not find sha of PR") + } + } + handlerFile, err := os.Create("pkg/stub/handler.go") if err != nil { t.Fatal(err) From e12c5ce4307f0cf7c843b2f6c5fa4d4bd6cfd4f2 Mon Sep 17 00:00:00 2001 From: Alexander Pavel Date: Mon, 24 Sep 2018 13:22:04 -0700 Subject: [PATCH 2/2] test/e2e/memcached_test.go: fix source replacement --- test/e2e/memcached_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/memcached_test.go b/test/e2e/memcached_test.go index 4c0dff3d00..cbcbd2467a 100644 --- a/test/e2e/memcached_test.go +++ b/test/e2e/memcached_test.go @@ -82,7 +82,7 @@ func TestMemcached(t *testing.T) { gopkg = bytes.Replace(gopkg, []byte("branch = \"master\""), []byte("# branch = \"master\""), -1) gopkgString := string(gopkg) gopkgLoc := strings.LastIndex(gopkgString, "\n name = \"github.com/operator-framework/operator-sdk\"\n") - gopkgString = gopkgString[:gopkgLoc] + "\n source = \"" + prSlug + "\"\n revision = \"" + prSha + "\"\n" + gopkgString[gopkgLoc+1:] + gopkgString = gopkgString[:gopkgLoc] + "\n source = \"https://github.com/" + prSlug + "\"\n revision = \"" + prSha + "\"\n" + gopkgString[gopkgLoc+1:] err = ioutil.WriteFile("Gopkg.toml", []byte(gopkgString), os.FileMode(filemode)) cmdOut, err = exec.Command("dep", "ensure").CombinedOutput() if err != nil {