cleanup and comments

pull/12779/head
Sharif Elgamal 2021-10-25 18:22:49 -07:00
parent b0598d06e5
commit 1e932bc5bd
2 changed files with 9 additions and 20 deletions

View File

@ -46,7 +46,10 @@ func kubectlCommand(cc *config.ClusterConfig, files []string, enable bool) *exec
args = append(args, []string{"-f", f}...)
}
} else {
// --ignore-not-found just ignores when we try to ignore a resource that is gone,
// like a completed job with a ttlSecondsAfterFinished
args = append(args, "--ignore-not-found")
// reverse the order of files to delete, sometimes file order matters
for i := len(files) - 1; i >= 0; i-- {
args = append(args, []string{"-f", files[i]}...)
}

View File

@ -65,33 +65,18 @@ func TestAddons(t *testing.T) {
t.Fatalf("Failed setting GOOGLE_CLOUD_PROJECT env var: %v", err)
}
args := append([]string{"start", "-p", profile, "--wait=true", "--memory=4000", "--alsologtostderr", "--addons=registry", "--addons=metrics-server", "--addons=olm", "--addons=volumesnapshots", "--addons=csi-hostpath-driver"}, StartArgs()...)
args := append([]string{"start", "-p", profile, "--wait=true", "--memory=4000", "--alsologtostderr", "--addons=registry", "--addons=metrics-server", "--addons=olm", "--addons=volumesnapshots", "--addons=csi-hostpath-driver", "--addons=gcp-auth"}, StartArgs()...)
if !NoneDriver() { // none driver does not support ingress
args = append(args, "--addons=ingress", "--addons=ingress-dns")
}
if !arm64Platform() {
args = append(args, "--addons=helm-tiller")
}
if !detect.IsOnGCE() {
args = append(args, "--addons=gcp-auth")
}
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}
// If we're running the integration tests on GCE, which is frequently the case, first check to make sure we exit out properly,
// then use force to actually test using creds.
if detect.IsOnGCE() {
// ok, use force here since we are in GCE
// do not use --force unless absolutely necessary
args := []string{"-p", profile, "addons", "enable", "gcp-auth", "--force"}
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Errorf("%s failed: %v", rr.Command(), err)
}
}
})
if !setupSucceeded {
@ -677,8 +662,6 @@ func validateGCPAuthAddon(ctx context.Context, t *testing.T, profile string) {
t.Errorf("failed to disable GCP auth addon: %v", err)
}
// maybe check that everything got cleaned up here?
// If we're on GCE, we have proper credentials and can test the registry secrets with an artifact registry image
if detect.IsOnGCE() && !detect.IsCloudShell() {
os.Unsetenv("GOOGLE_APPLICATION_CREDENTIALS")
@ -710,11 +693,14 @@ func validateGCPAuthAddon(ctx context.Context, t *testing.T, profile string) {
t.Fatalf("print env project: %v", err)
}
// Make sure the pod is up and running, which means we successfully pulled the private image down
// 8 minutes, because 4 is not enough for images to pull in all cases.
_, err = PodWait(ctx, t, profile, "default", "integration-test=private-image-eu", Minutes(8))
if err != nil {
t.Fatalf("wait for private image: %v", err)
}
// Disable the addon for good now
if err := retry.Expo(disableGCPAuth, Minutes(2), Minutes(10), 5); err != nil {
t.Errorf("failed to disable GCP auth addon: %v", err)
}
}
}