Skip to content

Commit

Permalink
Run “GCP only” tests on kokoro
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <[email protected]>
  • Loading branch information
dgageot committed Jun 5, 2019
1 parent 3c0b21b commit 46935b6
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 20 deletions.
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ GSC_BUILD_LATEST ?= gs://$(RELEASE_BUCKET)/builds/latest
GSC_RELEASE_PATH ?= gs://$(RELEASE_BUCKET)/releases/$(VERSION)
GSC_RELEASE_LATEST ?= gs://$(RELEASE_BUCKET)/releases/latest

REMOTE_INTEGRATION ?= false
GCP_ONLY ?= false
GCP_PROJECT ?= k8s-skaffold
GKE_CLUSTER_NAME ?= integration-tests
GKE_ZONE ?= us-central1-a
Expand Down Expand Up @@ -90,13 +90,13 @@ install: $(GO_FILES) $(BUILD_DIR)

.PHONY: integration
integration: install
ifeq ($(REMOTE_INTEGRATION),true)
ifeq ($(GCP_ONLY),true)
gcloud container clusters get-credentials \
$(GKE_CLUSTER_NAME) \
--zone $(GKE_ZONE) \
--project $(GCP_PROJECT)
endif
REMOTE_INTEGRATION=$(REMOTE_INTEGRATION) go test -v $(REPOPATH)/integration -timeout 15m
GCP_ONLY=$(GCP_ONLY) go test -v $(REPOPATH)/integration -timeout 15m

.PHONY: release
release: cross $(BUILD_DIR)/VERSION
Expand Down Expand Up @@ -169,7 +169,6 @@ integration-in-kind: kind-cluster skaffold-builder
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/kind-config:/kind-config \
-v /tmp/docker-config:/root/.docker/config.json \
-e REMOTE_INTEGRATION=$(REMOTE_INTEGRATION) \
-e KUBECONFIG=/kind-config \
gcr.io/$(GCP_PROJECT)/skaffold-integration

Expand All @@ -179,7 +178,7 @@ integration-in-docker: skaffold-builder
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(HOME)/.config/gcloud:/root/.config/gcloud \
-v $(GOOGLE_APPLICATION_CREDENTIALS):$(GOOGLE_APPLICATION_CREDENTIALS) \
-e REMOTE_INTEGRATION=$(REMOTE_INTEGRATION) \
-e GCP_ONLY=$(GCP_ONLY) \
-e GCP_PROJECT=$(GCP_PROJECT) \
-e GKE_CLUSTER_NAME=$(GKE_CLUSTER_NAME) \
-e GKE_ZONE=$(GKE_ZONE) \
Expand Down
2 changes: 1 addition & 1 deletion hack/kokoro/presubmit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export DOCKER_NAMESPACE=gcr.io/k8s-skaffold
source $KOKORO_GFILE_DIR/common.sh

pushd $KOKORO_ARTIFACTS_DIR/github/skaffold >/dev/null
REMOTE_INTEGRATION=true make integration-in-docker
GCP_ONLY=true make integration-in-docker
popd

3 changes: 3 additions & 0 deletions integration/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func TestBuild(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

tests := []struct {
description string
Expand Down
15 changes: 15 additions & 0 deletions integration/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func TestConfigListForContext(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

out := skaffold.Config("list", "-c", "testdata/config/config.yaml", "-k", "test-context").RunOrFailOutput(t)

Expand All @@ -37,6 +40,9 @@ func TestConfigListForAll(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

out := skaffold.Config("list", "-c", "testdata/config/config.yaml", "--all").RunOrFailOutput(t)

Expand All @@ -54,6 +60,9 @@ func TestFailToSetUnrecognizedValue(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

err := skaffold.Config("set", "doubt-this-will-ever-be-a-config-key", "VALUE", "-c", "testdata/config/config.yaml", "--global").Run(t)

Expand All @@ -64,6 +73,9 @@ func TestSetDefaultRepoForContext(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

file, delete := testutil.TempFile(t, "config", nil)
defer delete()
Expand All @@ -78,6 +90,9 @@ func TestSetGlobalDefaultRepo(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

file, delete := testutil.TempFile(t, "config", nil)
defer delete()
Expand Down
3 changes: 3 additions & 0 deletions integration/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func TestDebug(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

tests := []struct {
description string
Expand Down
6 changes: 6 additions & 0 deletions integration/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func TestBuildDeploy(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

ns, client, deleteNs := SetupNamespace(t)
defer deleteNs()
Expand Down Expand Up @@ -79,6 +82,9 @@ func TestDeploy(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

ns, client, deleteNs := SetupNamespace(t)
defer deleteNs()
Expand Down
3 changes: 3 additions & 0 deletions integration/dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func TestDev(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

Run(t, "testdata/dev", "sh", "-c", "echo foo > foo")
defer Run(t, "testdata/dev", "rm", "foo")
Expand Down
3 changes: 3 additions & 0 deletions integration/diagnose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func TestDiagnose(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

tests := []struct {
name string
Expand Down
3 changes: 3 additions & 0 deletions integration/fix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func TestFix(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

ns, _, deleteNs := SetupNamespace(t)
defer deleteNs()
Expand Down
5 changes: 2 additions & 3 deletions integration/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package integration

import (
"fmt"
"os"
"testing"

"github.com/GoogleContainerTools/skaffold/integration/skaffold"
Expand All @@ -33,8 +32,8 @@ func TestHelmDeploy(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if os.Getenv("REMOTE_INTEGRATION") != "true" {
t.Skip("skipping remote only test")
if !ShouldRunGCPOnlyTests() {
t.Skip("skipping gcp only test")
}

helmDir := "examples/helm-deployment"
Expand Down
3 changes: 3 additions & 0 deletions integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func TestInit(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

tests := []struct {
name string
Expand Down
3 changes: 3 additions & 0 deletions integration/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func TestEventLogRPC(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

rpcAddr := randomPort()
teardown := setupSkaffoldWithArgs(t, "--rpc-port", rpcAddr)
Expand Down
24 changes: 13 additions & 11 deletions integration/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package integration

import (
"os"
"testing"

"github.com/GoogleContainerTools/skaffold/integration/skaffold"
Expand All @@ -36,7 +35,7 @@ func TestRun(t *testing.T) {
deployments []string
pods []string
env []string
remoteOnly bool
gcpOnly bool
}{
{
description: "getting-started",
Expand Down Expand Up @@ -67,38 +66,38 @@ func TestRun(t *testing.T) {
description: "Google Cloud Build",
dir: "examples/google-cloud-build",
pods: []string{"getting-started"},
remoteOnly: true,
gcpOnly: true,
}, {
description: "Google Cloud Build with sub folder",
dir: "testdata/gcb-sub-folder",
pods: []string{"getting-started"},
remoteOnly: true,
gcpOnly: true,
}, {
description: "kaniko",
dir: "examples/kaniko",
pods: []string{"getting-started-kaniko"},
remoteOnly: true,
gcpOnly: true,
}, {
description: "kaniko local",
dir: "examples/kaniko-local",
pods: []string{"getting-started-kaniko"},
remoteOnly: true,
gcpOnly: true,
}, {
description: "kaniko local with sub folder",
dir: "testdata/kaniko-sub-folder",
pods: []string{"getting-started-kaniko"},
remoteOnly: true,
gcpOnly: true,
}, {
description: "kaniko microservices",
dir: "testdata/kaniko-microservices",
deployments: []string{"leeroy-app", "leeroy-web"},
remoteOnly: true,
gcpOnly: true,
}, {
description: "jib in googlecloudbuild",
dir: "testdata/jib",
args: []string{"-p", "gcb"},
deployments: []string{"web"},
remoteOnly: true,
gcpOnly: true,
}, {
description: "custom builder",
dir: "testdata/custom",
Expand All @@ -107,8 +106,11 @@ func TestRun(t *testing.T) {
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
if test.remoteOnly && os.Getenv("REMOTE_INTEGRATION") != "true" {
t.Skip("skipping remote only test")
if test.gcpOnly && !ShouldRunGCPOnlyTests() {
t.Skip("skipping gcp only test")
}
if !test.gcpOnly && ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

ns, client, deleteNs := SetupNamespace(t)
Expand Down
3 changes: 3 additions & 0 deletions integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func TestDevSync(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}

ns, client, deleteNs := SetupNamespace(t)
defer deleteNs()
Expand Down
5 changes: 5 additions & 0 deletions integration/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package integration
import (
"context"
"fmt"
"os"
"os/exec"
"testing"
"time"
Expand All @@ -31,6 +32,10 @@ import (
"k8s.io/client-go/kubernetes"
)

func ShouldRunGCPOnlyTests() bool {
return os.Getenv("GCP_ONLY") == "true"
}

func Run(t *testing.T, dir, command string, args ...string) {
cmd := exec.Command(command, args...)
cmd.Dir = dir
Expand Down

0 comments on commit 46935b6

Please sign in to comment.