From a0cfc6091067ec3c86d5c1802a4834c98528dfb4 Mon Sep 17 00:00:00 2001 From: cpanato Date: Tue, 26 Mar 2024 13:50:05 +0100 Subject: [PATCH] upgrade integration_test Signed-off-by: cpanato --- integration_test.sh | 32 +++++++++++++++++--------------- test/main.go | 4 ++-- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/integration_test.sh b/integration_test.sh index 182f1e95e6..ddc3a65f63 100755 --- a/integration_test.sh +++ b/integration_test.sh @@ -20,6 +20,8 @@ echo "Copying ko to temp gopath." mkdir -p "$GOPATH/src/github.com/google/ko" cp -r "$ROOT_DIR/"* "$GOPATH/src/github.com/google/ko/" +pushd "$GOPATH/src/github.com/google/ko" || exit 1 + echo "Building ko" RESULT="$(GO111MODULE="on" GOFLAGS="-mod=vendor" go build .)" @@ -31,8 +33,8 @@ FILTER="[^ ]local[^ ]*" echo "1. Go module auto mode should create an image that outputs 'Hello World' when run outside the module." pushd .. || exit 1 -RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko/ko build --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" -if [[ "$RESULT" != *"Hello World"* ]]; then +RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko/ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)" +if [[ "$RESULT" != *"Hello there"* ]]; then echo "Test FAILED. Saw $RESULT" && exit 1 else echo "Test PASSED" @@ -40,34 +42,34 @@ fi popd || exit 1 -echo "2. Auto inside the module with vendoring should output TEST" +echo "2. Auto inside the module with vendoring should output Hello there" -RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko build --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" -if [[ "$RESULT" != *"TEST"* ]]; then +RESULT="$(GO111MODULE=auto GOFLAGS="-mod=vendor" ./ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)" +if [[ "$RESULT" != *"Hello there"* ]]; then echo "Test FAILED. Saw $RESULT" && exit 1 else echo "Test PASSED" fi -echo "3. Auto inside the module without vendoring should output TEST" -RESULT="$(GO111MODULE=auto GOFLAGS="" ./ko build --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" -if [[ "$RESULT" != *"TEST"* ]]; then +echo "3. Auto inside the module without vendoring should output Hello there" +RESULT="$(GO111MODULE=auto GOFLAGS="" ./ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)" +if [[ "$RESULT" != *"Hello there"* ]]; then echo "Test FAILED. Saw $RESULT" && exit 1 else echo "Test PASSED" fi -echo "4. On inside the module with vendor should output TEST." -RESULT="$(GO111MODULE=on GOFLAGS="-mod=vendor" ./ko build --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" -if [[ "$RESULT" != *"TEST"* ]]; then +echo "4. On inside the module with vendor should output Hello there." +RESULT="$(GO111MODULE=on GOFLAGS="-mod=vendor" ./ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)" +if [[ "$RESULT" != *"Hello there"* ]]; then echo "Test FAILED. Saw $RESULT" && exit 1 else echo "Test PASSED" fi -echo "5. On inside the module without vendor should output TEST" -RESULT="$(GO111MODULE=on GOFLAGS="" ./ko build --local github.com/go-training/helloworld | grep "$FILTER" | xargs -I% docker run %)" -if [[ "$RESULT" != *"TEST"* ]]; then +echo "5. On inside the module without vendor should output Hello there" +RESULT="$(GO111MODULE=on GOFLAGS="" ./ko build --local "$GOPATH/src/github.com/google/ko/test" | grep "$FILTER" | xargs -I% docker run %)" +if [[ "$RESULT" != *"Hello there"* ]]; then echo "Test FAILED. Saw $RESULT" && exit 1 else echo "Test PASSED" @@ -75,7 +77,7 @@ fi echo "6. On outside the module should fail." pushd .. || exit 1 -GO111MODULE=on ./ko/ko build --local github.com/go-training/helloworld && exit 1 +GO111MODULE=on ./ko/ko build --local "$GOPATH/src/github.com/google/ko/test" && exit 1 popd || exit 1 echo "7. On outside with build config specifying the test module builds." diff --git a/test/main.go b/test/main.go index aa4d6b43a1..9a0f1ccaef 100644 --- a/test/main.go +++ b/test/main.go @@ -31,7 +31,7 @@ import ( var ( f = flag.String("f", "kenobi", "File in kodata to print") - wait = flag.Bool("wait", true, "Whether to wait for SIGTERM") + wait = flag.Bool("wait", false, "Whether to wait for SIGTERM") ) // This is defined so we can test build-time variable setting using ldflags. @@ -66,7 +66,7 @@ func main() { if err != nil { log.Fatalf("Error reading %q: %v", file, err) } - log.Print(string(bytes)) + fmt.Println(string(bytes)) // Cause the pod to "hang" to allow us to check for a readiness state. if *wait {