Skip to content

Commit 1e66121

Browse files
committed
Run “GCP only” tests on kokoro
Signed-off-by: David Gageot <[email protected]>
1 parent 1843ed5 commit 1e66121

15 files changed

+70
-20
lines changed

Makefile

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ GSC_BUILD_LATEST ?= gs://$(RELEASE_BUCKET)/builds/latest
2323
GSC_RELEASE_PATH ?= gs://$(RELEASE_BUCKET)/releases/$(VERSION)
2424
GSC_RELEASE_LATEST ?= gs://$(RELEASE_BUCKET)/releases/latest
2525

26-
REMOTE_INTEGRATION ?= false
26+
GCP_ONLY ?= false
2727
GCP_PROJECT ?= k8s-skaffold
2828
GKE_CLUSTER_NAME ?= integration-tests
2929
GKE_ZONE ?= us-central1-a
@@ -90,13 +90,13 @@ install: $(GO_FILES) $(BUILD_DIR)
9090

9191
.PHONY: integration
9292
integration: install
93-
ifeq ($(REMOTE_INTEGRATION),true)
93+
ifeq ($(GCP_ONLY),true)
9494
gcloud container clusters get-credentials \
9595
$(GKE_CLUSTER_NAME) \
9696
--zone $(GKE_ZONE) \
9797
--project $(GCP_PROJECT)
9898
endif
99-
REMOTE_INTEGRATION=$(REMOTE_INTEGRATION) go test -v $(REPOPATH)/integration -timeout 15m
99+
GCP_ONLY=$(GCP_ONLY) go test -v $(REPOPATH)/integration -timeout 15m
100100

101101
.PHONY: release
102102
release: cross $(BUILD_DIR)/VERSION
@@ -169,7 +169,6 @@ integration-in-kind: kind-cluster skaffold-builder
169169
-v /var/run/docker.sock:/var/run/docker.sock \
170170
-v /tmp/kind-config:/kind-config \
171171
-v /tmp/docker-config:/root/.docker/config.json \
172-
-e REMOTE_INTEGRATION=$(REMOTE_INTEGRATION) \
173172
-e KUBECONFIG=/kind-config \
174173
gcr.io/$(GCP_PROJECT)/skaffold-integration
175174

@@ -179,7 +178,7 @@ integration-in-docker: skaffold-builder
179178
-v /var/run/docker.sock:/var/run/docker.sock \
180179
-v $(HOME)/.config/gcloud:/root/.config/gcloud \
181180
-v $(GOOGLE_APPLICATION_CREDENTIALS):$(GOOGLE_APPLICATION_CREDENTIALS) \
182-
-e REMOTE_INTEGRATION=$(REMOTE_INTEGRATION) \
181+
-e GCP_ONLY=$(GCP_ONLY) \
183182
-e GCP_PROJECT=$(GCP_PROJECT) \
184183
-e GKE_CLUSTER_NAME=$(GKE_CLUSTER_NAME) \
185184
-e GKE_ZONE=$(GKE_ZONE) \

hack/kokoro/presubmit.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export DOCKER_NAMESPACE=gcr.io/k8s-skaffold
1818
source $KOKORO_GFILE_DIR/common.sh
1919

2020
pushd $KOKORO_ARTIFACTS_DIR/github/skaffold >/dev/null
21-
REMOTE_INTEGRATION=true make integration-in-docker
21+
GCP_ONLY=true make integration-in-docker
2222
popd
2323

integration/build_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func TestBuild(t *testing.T) {
3636
if testing.Short() {
3737
t.Skip("skipping integration test")
3838
}
39+
if ShouldRunGCPOnlyTests() {
40+
t.Skip("skipping test that is not gcp only")
41+
}
3942

4043
tests := []struct {
4144
description string

integration/config_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ func TestConfigListForContext(t *testing.T) {
2727
if testing.Short() {
2828
t.Skip("skipping integration test")
2929
}
30+
if ShouldRunGCPOnlyTests() {
31+
t.Skip("skipping test that is not gcp only")
32+
}
3033

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

@@ -37,6 +40,9 @@ func TestConfigListForAll(t *testing.T) {
3740
if testing.Short() {
3841
t.Skip("skipping integration test")
3942
}
43+
if ShouldRunGCPOnlyTests() {
44+
t.Skip("skipping test that is not gcp only")
45+
}
4046

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

@@ -54,6 +60,9 @@ func TestFailToSetUnrecognizedValue(t *testing.T) {
5460
if testing.Short() {
5561
t.Skip("skipping integration test")
5662
}
63+
if ShouldRunGCPOnlyTests() {
64+
t.Skip("skipping test that is not gcp only")
65+
}
5766

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

@@ -64,6 +73,9 @@ func TestSetDefaultRepoForContext(t *testing.T) {
6473
if testing.Short() {
6574
t.Skip("skipping integration test")
6675
}
76+
if ShouldRunGCPOnlyTests() {
77+
t.Skip("skipping test that is not gcp only")
78+
}
6779

6880
file, delete := testutil.TempFile(t, "config", nil)
6981
defer delete()
@@ -78,6 +90,9 @@ func TestSetGlobalDefaultRepo(t *testing.T) {
7890
if testing.Short() {
7991
t.Skip("skipping integration test")
8092
}
93+
if ShouldRunGCPOnlyTests() {
94+
t.Skip("skipping test that is not gcp only")
95+
}
8196

8297
file, delete := testutil.TempFile(t, "config", nil)
8398
defer delete()

integration/debug_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ func TestDebug(t *testing.T) {
2626
if testing.Short() {
2727
t.Skip("skipping integration test")
2828
}
29+
if ShouldRunGCPOnlyTests() {
30+
t.Skip("skipping test that is not gcp only")
31+
}
2932

3033
tests := []struct {
3134
description string

integration/deploy_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ func TestBuildDeploy(t *testing.T) {
2828
if testing.Short() {
2929
t.Skip("skipping integration test")
3030
}
31+
if ShouldRunGCPOnlyTests() {
32+
t.Skip("skipping test that is not gcp only")
33+
}
3134

3235
ns, client, deleteNs := SetupNamespace(t)
3336
defer deleteNs()
@@ -79,6 +82,9 @@ func TestDeploy(t *testing.T) {
7982
if testing.Short() {
8083
t.Skip("skipping integration test")
8184
}
85+
if ShouldRunGCPOnlyTests() {
86+
t.Skip("skipping test that is not gcp only")
87+
}
8288

8389
ns, client, deleteNs := SetupNamespace(t)
8490
defer deleteNs()

integration/dev_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ func TestDev(t *testing.T) {
2929
if testing.Short() {
3030
t.Skip("skipping integration test")
3131
}
32+
if ShouldRunGCPOnlyTests() {
33+
t.Skip("skipping test that is not gcp only")
34+
}
3235

3336
Run(t, "testdata/dev", "sh", "-c", "echo foo > foo")
3437
defer Run(t, "testdata/dev", "rm", "foo")

integration/diagnose_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ func TestDiagnose(t *testing.T) {
2626
if testing.Short() {
2727
t.Skip("skipping integration test")
2828
}
29+
if ShouldRunGCPOnlyTests() {
30+
t.Skip("skipping test that is not gcp only")
31+
}
2932

3033
tests := []struct {
3134
name string

integration/fix_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ func TestFix(t *testing.T) {
2626
if testing.Short() {
2727
t.Skip("skipping integration test")
2828
}
29+
if ShouldRunGCPOnlyTests() {
30+
t.Skip("skipping test that is not gcp only")
31+
}
2932

3033
ns, _, deleteNs := SetupNamespace(t)
3134
defer deleteNs()

integration/helm_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package integration
1818

1919
import (
2020
"fmt"
21-
"os"
2221
"testing"
2322

2423
"github.com/GoogleContainerTools/skaffold/integration/skaffold"
@@ -33,8 +32,8 @@ func TestHelmDeploy(t *testing.T) {
3332
if testing.Short() {
3433
t.Skip("skipping integration test")
3534
}
36-
if os.Getenv("REMOTE_INTEGRATION") != "true" {
37-
t.Skip("skipping remote only test")
35+
if !ShouldRunGCPOnlyTests() {
36+
t.Skip("skipping gcp only test")
3837
}
3938

4039
helmDir := "examples/helm-deployment"

integration/init_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ func TestInit(t *testing.T) {
2626
if testing.Short() {
2727
t.Skip("skipping integration test")
2828
}
29+
if ShouldRunGCPOnlyTests() {
30+
t.Skip("skipping test that is not gcp only")
31+
}
2932

3033
tests := []struct {
3134
name string

integration/rpc_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ func TestEventLogRPC(t *testing.T) {
4747
if testing.Short() {
4848
t.Skip("skipping integration test")
4949
}
50+
if ShouldRunGCPOnlyTests() {
51+
t.Skip("skipping test that is not gcp only")
52+
}
5053

5154
rpcAddr := randomPort()
5255
teardown := setupSkaffoldWithArgs(t, "--rpc-port", rpcAddr)

integration/run_test.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package integration
1818

1919
import (
20-
"os"
2120
"testing"
2221

2322
"github.com/GoogleContainerTools/skaffold/integration/skaffold"
@@ -36,7 +35,7 @@ func TestRun(t *testing.T) {
3635
deployments []string
3736
pods []string
3837
env []string
39-
remoteOnly bool
38+
gcpOnly bool
4039
}{
4140
{
4241
description: "getting-started",
@@ -67,38 +66,38 @@ func TestRun(t *testing.T) {
6766
description: "Google Cloud Build",
6867
dir: "examples/google-cloud-build",
6968
pods: []string{"getting-started"},
70-
remoteOnly: true,
69+
gcpOnly: true,
7170
}, {
7271
description: "Google Cloud Build with sub folder",
7372
dir: "testdata/gcb-sub-folder",
7473
pods: []string{"getting-started"},
75-
remoteOnly: true,
74+
gcpOnly: true,
7675
}, {
7776
description: "kaniko",
7877
dir: "examples/kaniko",
7978
pods: []string{"getting-started-kaniko"},
80-
remoteOnly: true,
79+
gcpOnly: true,
8180
}, {
8281
description: "kaniko local",
8382
dir: "examples/kaniko-local",
8483
pods: []string{"getting-started-kaniko"},
85-
remoteOnly: true,
84+
gcpOnly: true,
8685
}, {
8786
description: "kaniko local with sub folder",
8887
dir: "testdata/kaniko-sub-folder",
8988
pods: []string{"getting-started-kaniko"},
90-
remoteOnly: true,
89+
gcpOnly: true,
9190
}, {
9291
description: "kaniko microservices",
9392
dir: "testdata/kaniko-microservices",
9493
deployments: []string{"leeroy-app", "leeroy-web"},
95-
remoteOnly: true,
94+
gcpOnly: true,
9695
}, {
9796
description: "jib in googlecloudbuild",
9897
dir: "testdata/jib",
9998
args: []string{"-p", "gcb"},
10099
deployments: []string{"web"},
101-
remoteOnly: true,
100+
gcpOnly: true,
102101
}, {
103102
description: "custom builder",
104103
dir: "testdata/custom",
@@ -107,8 +106,11 @@ func TestRun(t *testing.T) {
107106
}
108107
for _, test := range tests {
109108
t.Run(test.description, func(t *testing.T) {
110-
if test.remoteOnly && os.Getenv("REMOTE_INTEGRATION") != "true" {
111-
t.Skip("skipping remote only test")
109+
if test.gcpOnly && !ShouldRunGCPOnlyTests() {
110+
t.Skip("skipping gcp only test")
111+
}
112+
if !test.gcpOnly && ShouldRunGCPOnlyTests() {
113+
t.Skip("skipping test that is not gcp only")
112114
}
113115

114116
ns, client, deleteNs := SetupNamespace(t)

integration/sync_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ func TestDevSync(t *testing.T) {
3030
if testing.Short() {
3131
t.Skip("skipping integration test")
3232
}
33+
if ShouldRunGCPOnlyTests() {
34+
t.Skip("skipping test that is not gcp only")
35+
}
3336

3437
ns, client, deleteNs := SetupNamespace(t)
3538
defer deleteNs()

integration/util.go

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package integration
1919
import (
2020
"context"
2121
"fmt"
22+
"os"
2223
"os/exec"
2324
"testing"
2425
"time"
@@ -31,6 +32,10 @@ import (
3132
"k8s.io/client-go/kubernetes"
3233
)
3334

35+
func ShouldRunGCPOnlyTests() bool {
36+
return os.Getenv("GCP_ONLY") == "true"
37+
}
38+
3439
func Run(t *testing.T, dir, command string, args ...string) {
3540
cmd := exec.Command(command, args...)
3641
cmd.Dir = dir

0 commit comments

Comments
 (0)