"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/integration/addons_test.go" between
minikube-1.25.2.tar.gz and minikube-1.26.0.tar.gz

About: minikube implements a local Kubernetes cluster on macOS, Linux, and Windows. minikube's primary goals are to be the best tool for local Kubernetes application development and to support all Kubernetes features that fit.

addons_test.go  (minikube-1.25.2):addons_test.go  (minikube-1.26.0)
//go:build integration //go:build integration
// +build integration
/* /*
Copyright 2016 The Kubernetes Authors All rights reserved. Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
skipping to change at line 33 skipping to change at line 32
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"reflect" "reflect"
"regexp"
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/blang/semver/v4" "github.com/blang/semver/v4"
retryablehttp "github.com/hashicorp/go-retryablehttp" retryablehttp "github.com/hashicorp/go-retryablehttp"
"k8s.io/minikube/pkg/kapi" "k8s.io/minikube/pkg/kapi"
"k8s.io/minikube/pkg/minikube/detect" "k8s.io/minikube/pkg/minikube/detect"
"k8s.io/minikube/pkg/util/retry" "k8s.io/minikube/pkg/util/retry"
) )
skipping to change at line 69 skipping to change at line 69
} }
err = os.Setenv("GOOGLE_CLOUD_PROJECT", "this_is_fake") err = os.Setenv("GOOGLE_CLOUD_PROJECT", "this_is_fake")
t.Cleanup(func() { t.Cleanup(func() {
os.Unsetenv("GOOGLE_CLOUD_PROJECT") os.Unsetenv("GOOGLE_CLOUD_PROJECT")
}) })
if err != nil { if err != nil {
t.Fatalf("Failed setting GOOGLE_CLOUD_PROJECT env var: %v ", err) 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-serve r", "--addons=olm", "--addons=volumesnapshots", "--addons=csi-hostpath-driver", "--addons=gcp-auth"}, StartArgs()...) args := append([]string{"start", "-p", profile, "--wait=true", "- -memory=4000", "--alsologtostderr", "--addons=registry", "--addons=metrics-serve r", "--addons=volumesnapshots", "--addons=csi-hostpath-driver", "--addons=gcp-au th"}, StartArgs()...)
if !NoneDriver() { // none driver does not support ingress if !NoneDriver() { // none driver does not support ingress
args = append(args, "--addons=ingress", "--addons=ingress -dns") args = append(args, "--addons=ingress", "--addons=ingress -dns")
} }
if !arm64Platform() { if !arm64Platform() {
args = append(args, "--addons=helm-tiller") args = append(args, "--addons=helm-tiller")
} }
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil { if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err) t.Fatalf("%s failed: %v", rr.Command(), err)
} }
skipping to change at line 99 skipping to change at line 99
tests := []struct { tests := []struct {
name string name string
validator validateFunc validator validateFunc
}{ }{
{"Registry", validateRegistryAddon}, {"Registry", validateRegistryAddon},
{"Ingress", validateIngressAddon}, {"Ingress", validateIngressAddon},
{"MetricsServer", validateMetricsServerAddon}, {"MetricsServer", validateMetricsServerAddon},
{"HelmTiller", validateHelmTillerAddon}, {"HelmTiller", validateHelmTillerAddon},
{"Olm", validateOlmAddon}, {"Olm", validateOlmAddon},
{"CSI", validateCSIDriverAndSnapshots}, {"CSI", validateCSIDriverAndSnapshots},
{"Headlamp", validateHeadlampAddon},
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc tc := tc
if ctx.Err() == context.DeadlineExceeded { if ctx.Err() == context.DeadlineExceeded {
t.Fatalf("Unable to run more tests (deadline exce eded)") t.Fatalf("Unable to run more tests (deadline exce eded)")
} }
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
MaybeParallel(t) MaybeParallel(t)
tc.validator(ctx, t, profile) tc.validator(ctx, t, profile)
}) })
skipping to change at line 449 skipping to change at line 450
} }
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addo ns", "disable", "helm-tiller", "--alsologtostderr", "-v=1")) rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "addo ns", "disable", "helm-tiller", "--alsologtostderr", "-v=1"))
if err != nil { if err != nil {
t.Errorf("failed disabling helm-tiller addon. arg %q.s %v", rr.Co mmand(), err) t.Errorf("failed disabling helm-tiller addon. arg %q.s %v", rr.Co mmand(), err)
} }
} }
// validateOlmAddon tests the OLM addon // validateOlmAddon tests the OLM addon
func validateOlmAddon(ctx context.Context, t *testing.T, profile string) { func validateOlmAddon(ctx context.Context, t *testing.T, profile string) {
t.Skip("Skipping Olm addon till images are fixed") t.Skip("Skipping OLM addon test until https://github.com/operator-framewo rk/operator-lifecycle-manager/issues/2534 is resolved")
defer PostMortemLogs(t, profile) defer PostMortemLogs(t, profile)
start := time.Now() start := time.Now()
if _, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", prof ile, "wait", "--for=condition=ready", "--namespace=olm", "pod", "--selector=app= catalog-operator", "--timeout=90s")); err != nil { if _, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", prof ile, "wait", "--for=condition=ready", "--namespace=olm", "pod", "--selector=app= catalog-operator", "--timeout=90s")); err != nil {
t.Fatalf("failed waiting for pod catalog-operator: %v", err) t.Fatalf("failed waiting for pod catalog-operator: %v", err)
} }
t.Logf("catalog-operator stabilized in %s", time.Since(start)) t.Logf("catalog-operator stabilized in %s", time.Since(start))
if _, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", prof ile, "wait", "--for=condition=ready", "--namespace=olm", "pod", "--selector=app= olm-operator", "--timeout=90s")); err != nil { if _, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", prof ile, "wait", "--for=condition=ready", "--namespace=olm", "pod", "--selector=app= olm-operator", "--timeout=90s")); err != nil {
t.Fatalf("failed waiting for pod olm-operator: %v", err) t.Fatalf("failed waiting for pod olm-operator: %v", err)
skipping to change at line 609 skipping to change at line 610
// validateGCPAuthAddon tests the GCP Auth addon with either phony or real crede ntials and makes sure the files are mounted into pods correctly // validateGCPAuthAddon tests the GCP Auth addon with either phony or real crede ntials and makes sure the files are mounted into pods correctly
func validateGCPAuthAddon(ctx context.Context, t *testing.T, profile string) { func validateGCPAuthAddon(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile) defer PostMortemLogs(t, profile)
// schedule a pod to check environment variables // schedule a pod to check environment variables
rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profil e, "create", "-f", filepath.Join(*testdataDir, "busybox.yaml"))) rr, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profil e, "create", "-f", filepath.Join(*testdataDir, "busybox.yaml")))
if err != nil { if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err) t.Fatalf("%s failed: %v", rr.Command(), err)
} }
serviceAccountName := "gcp-auth-test"
// create a dummy service account so we know the pull secret got added
rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile
, "create", "sa", serviceAccountName))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}
// 8 minutes, because 4 is not enough for images to pull in all cases. // 8 minutes, because 4 is not enough for images to pull in all cases.
names, err := PodWait(ctx, t, profile, "default", "integration-test=busyb ox", Minutes(8)) names, err := PodWait(ctx, t, profile, "default", "integration-test=busyb ox", Minutes(8))
if err != nil { if err != nil {
t.Fatalf("wait: %v", err) t.Fatalf("wait: %v", err)
} }
// Use this pod to confirm that the env vars are set correctly // Use this pod to confirm that the env vars are set correctly
rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile , "exec", names[0], "--", "/bin/sh", "-c", "printenv GOOGLE_APPLICATION_CREDENTI ALS")) rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile , "exec", names[0], "--", "/bin/sh", "-c", "printenv GOOGLE_APPLICATION_CREDENTI ALS"))
if err != nil { if err != nil {
t.Fatalf("printenv creds: %v", err) t.Fatalf("printenv creds: %v", err)
} }
got := strings.TrimSpace(rr.Stdout.String()) got := strings.TrimSpace(rr.Stdout.String())
expected := "/google-app-creds.json" expected := "/google-app-creds.json"
if got != expected { if got != expected {
t.Errorf("'printenv GOOGLE_APPLICATION_CREDENTIALS' returned %s, expected %s", got, expected) t.Errorf("'printenv GOOGLE_APPLICATION_CREDENTIALS' returned %s, expected %s", got, expected)
} }
// Now check the service account and make sure the "gcp-auth" image pull
secret is present
rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile
, "describe", "sa", serviceAccountName))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
}
expectedPullSecret := "gcp-auth"
re := regexp.MustCompile(`.*Image pull secrets:.*`)
secrets := re.FindString(rr.Stdout.String())
if !strings.Contains(secrets, expectedPullSecret) {
t.Errorf("Unexpected image pull secrets. expected %s, got %s", ex
pectedPullSecret, secrets)
}
if !detect.IsOnGCE() || detect.IsCloudShell() { if !detect.IsOnGCE() || detect.IsCloudShell() {
// Make sure the file contents are correct // Make sure the file contents are correct
rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "exec", names[0], "--", "/bin/sh", "-c", "cat /google-app-creds.json") ) rr, err = Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "exec", names[0], "--", "/bin/sh", "-c", "cat /google-app-creds.json") )
if err != nil { if err != nil {
t.Fatalf("cat creds: %v", err) t.Fatalf("cat creds: %v", err)
} }
var gotJSON map[string]string var gotJSON map[string]string
err = json.Unmarshal(bytes.TrimSpace(rr.Stdout.Bytes()), &gotJSON ) err = json.Unmarshal(bytes.TrimSpace(rr.Stdout.Bytes()), &gotJSON )
if err != nil { if err != nil {
skipping to change at line 712 skipping to change at line 733
if err != nil { if err != nil {
t.Fatalf("print env project: %v", err) t.Fatalf("print env project: %v", err)
} }
_, err = PodWait(ctx, t, profile, "default", "integration-test=pr ivate-image-eu", Minutes(8)) _, err = PodWait(ctx, t, profile, "default", "integration-test=pr ivate-image-eu", Minutes(8))
if err != nil { if err != nil {
t.Fatalf("wait for private image: %v", err) t.Fatalf("wait for private image: %v", err)
} }
} }
} }
func validateHeadlampAddon(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)
rr, err := Run(t, exec.CommandContext(ctx, Target(), "addons", "enable",
"headlamp", "-p", profile, "--alsologtostderr", "-v=1"))
if err != nil {
t.Fatalf("failed to enable headlamp addon: args: %q: %v", rr.Comm
and(), err)
}
if _, err := PodWait(ctx, t, profile, "headlamp", "app.kubernetes.io/name
=headlamp", Minutes(8)); err != nil {
t.Fatalf("failed waiting for headlamp pod: %v", err)
}
}
 End of changes. 8 change blocks. 
3 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)