Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an integration test for ambassador addon, fix filename and bump operator version #8372

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/addons/ambassador/ambassador-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ spec:
containers:
- name: ambassador-operator
# Replace this with the built image name
image: quay.io/datawire/ambassador-operator:v1.2.3
image: quay.io/datawire/ambassador-operator:v1.2.8
command:
- ambassador-operator
imagePullPolicy: Always
Expand Down
2 changes: 2 additions & 0 deletions deploy/addons/ambassador/ambassadorinstallation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ spec:
installOSS: true
helmValues:
deploymentTool: amb-oper-minikube
deploymentStrategy:
type: Recreate
2 changes: 1 addition & 1 deletion pkg/minikube/assets/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ var Addons = map[string]*Addon{
MustBinAsset(
"deploy/addons/ambassador/ambassadorinstallation.yaml",
vmpath.GuestAddonsDir,
"ambassadorinstallation.yaml.yaml",
"ambassadorinstallation.yaml",
concaf marked this conversation as resolved.
Show resolved Hide resolved
"0640",
false),
}, false, "ambassador"),
Expand Down
82 changes: 79 additions & 3 deletions test/integration/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ func TestAddons(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), Minutes(40))
defer Cleanup(t, profile, cancel)

args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2600", "--alsologtostderr", "--addons=registry", "--addons=metrics-server", "--addons=helm-tiller", "--addons=olm"}, StartArgs()...)
if !NoneDriver() { // none doesn't support ingress
args := append([]string{"start", "-p", profile, "--wait=false", "--memory=2800", "--alsologtostderr", "--addons=ingress", "--addons=registry", "--addons=metrics-server", "--addons=helm-tiller", "--addons=olm", "--addons=ambassador"}, StartArgs()...)

if !NoneDriver() { // none doesn't support ingress
args = append(args, "--addons=ingress")
}

rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("%s failed: %v", rr.Command(), err)
Expand All @@ -60,6 +62,7 @@ func TestAddons(t *testing.T) {
{"MetricsServer", validateMetricsServerAddon},
{"HelmTiller", validateHelmTillerAddon},
{"Olm", validateOlmAddon},
{"Ambassador", validateAmbassadorAddon},
}
for _, tc := range tests {
tc := tc
Expand Down Expand Up @@ -104,7 +107,7 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
t.Errorf("failed waiting for ingress-controller deployment to stabilize: %v", err)
}
if _, err := PodWait(ctx, t, profile, "kube-system", "app.kubernetes.io/name=ingress-nginx", Minutes(12)); err != nil {
t.Fatalf("failed waititing for nginx-ingress-controller : %v", err)
t.Fatalf("failed waiting for nginx-ingress-controller : %v", err)
}

createIngress := func() error {
Expand Down Expand Up @@ -164,6 +167,79 @@ func validateIngressAddon(ctx context.Context, t *testing.T, profile string) {
}
}

func validateAmbassadorAddon(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)

client, err := kapi.Client(profile)
if err != nil {
t.Fatalf("failed to get Kubernetes client: %v", client)
}

// Let's wait for the operator to come up
if err := kapi.WaitForDeploymentToStabilize(client, "ambassador", "ambassador-operator", Minutes(6)); err != nil {
t.Errorf("failed waiting for ambassador-operator deployment to stabilize: %v", err)
}

if _, err := PodWait(ctx, t, profile, "ambassador", "getambassador.io/installer=operator", Minutes(12)); err != nil {
t.Errorf("failed waiting for ambassador pods : %v", err)
}

// Let's wait for the operator to spin up Ambassador pods
if err := kapi.WaitForDeploymentToStabilize(client, "ambassador", "ambassador", Minutes(6)); err != nil {
t.Errorf("failed waiting for ambassador deployment to stabilize: %v", err)
}

if _, err := PodWait(ctx, t, profile, "ambassador", "app.kubernetes.io/name=ambassador", Minutes(12)); err != nil {
t.Errorf("failed waiting for ambassador pods : %v", err)
}

// Create echoserver for testing ingress
deploymentName := "hello-minikube"
rrDeployment, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "create", "deployment", deploymentName, "--image=k8s.gcr.io/echoserver:1.4"))
if err != nil {
t.Errorf("failed to create echoserver deployment, args %q. %v", rrDeployment.Command(), err)
}

rrService, err := Run(t, exec.CommandContext(ctx, "kubectl", "expose", "deployment", deploymentName, "--port=8080"))
if err != nil {
t.Errorf("failed to expose echoserver deployment, args %q. %v", rrService.Command(), err)
}

if _, err := PodWait(ctx, t, profile, "default", "app=hello-minikube", Minutes(4)); err != nil {
t.Errorf("failed waiting for echoserver pod: %v", err)
}

// Create an ingress resource
rrIngress, err := Run(t, exec.CommandContext(ctx, "kubectl", "apply", "-f", filepath.Join(*testdataDir, "ambassador-ingress.yaml")))
if err != nil {
t.Errorf("failed to create ingress, args %q. %v", rrIngress.Command(), err)
}

checkAmbassadorIngress := func() error {
rrStatus, err := Run(t, exec.CommandContext(ctx, "kubectl", "--context", profile, "run", "--rm", "ambassador-test", "--restart=Never", "--image=busybox", "-i", "--", "sh", "-c", "wget --spider -S http://ambassador.ambassador.svc.cluster.local/hello/"))
if err != nil {
t.Errorf("failed to hit ambassador.ambassador.svc.cluster.local/hello/, args %q failed: %v", rrStatus.Command(), err)
return err
}

stderr := rrStatus.Stderr.String()
if stderr != "" {
t.Errorf("debug: unexpected stderr for %v:\n%s", rrStatus.Command(), stderr)
}

want := "HTTP/1.1 200 OK"
stdout := rrStatus.Stdout.String()
if !strings.Contains(stdout, want) {
t.Errorf("expected curl response be %q, but got *%s*", want, stdout)
}
return nil
}

if err := retry.Expo(checkAmbassadorIngress, 500*time.Millisecond, Seconds(90)); err != nil {
t.Errorf("failed to get expected response: %v", err)
}
}

func validateRegistryAddon(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)

Expand Down
14 changes: 14 additions & 0 deletions test/integration/testdata/ambassador-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: ambassador
name: test-ambassador-ingress
spec:
rules:
- http:
paths:
- path: /hello/
backend:
serviceName: hello-minikube
servicePort: 8080