-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* e2e: ingress class * remove e2e tag from ingress class
- Loading branch information
1 parent
d8ab6e4
commit 7055fe2
Showing
6 changed files
with
185 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// ------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
// -------------------------------------------------------------------------------------------- | ||
|
||
// +build e2eingressclass | ||
|
||
package runner | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/klog" | ||
) | ||
|
||
var _ = Describe("IngressClass", func() { | ||
var ( | ||
clientset *kubernetes.Clientset | ||
err error | ||
) | ||
|
||
Context("Test Ingress Class", func() { | ||
BeforeEach(func() { | ||
clientset, err = getClient() | ||
Expect(err).To(BeNil()) | ||
|
||
cleanUp(clientset) | ||
}) | ||
|
||
It("[ingress-class] should only pick up ingresses that match the class specified in helm", func() { | ||
namespaceName := "e2e-ingress-class" | ||
ns := &v1.Namespace{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: namespaceName, | ||
}, | ||
} | ||
klog.Info("Creating namespace: ", namespaceName) | ||
_, err = clientset.CoreV1().Namespaces().Create(ns) | ||
Expect(err).To(BeNil()) | ||
|
||
// This application has two ingresses: | ||
// 1. One Ingress: uses "azure/application-gateway" as ingress class | ||
// 2. Two Ingress: uses "custom-ingress-class" as ingress class | ||
// We expect that AGIC will use ingress with "custom-ingress-class" | ||
SSLIngressClassYamlPath := "testdata/ingress-class/app.yaml" | ||
klog.Info("Applying yaml: ", SSLIngressClassYamlPath) | ||
err = applyYaml(clientset, namespaceName, SSLIngressClassYamlPath) | ||
Expect(err).To(BeNil()) | ||
time.Sleep(30 * time.Second) | ||
|
||
// get ip address for 1 ingress | ||
klog.Info("Getting public IP from Ingress...") | ||
publicIP, _ := getPublicIP(clientset, namespaceName) | ||
Expect(publicIP).ToNot(Equal("")) | ||
|
||
url := fmt.Sprintf("http://%s/status/200", publicIP) | ||
|
||
// should return 404 as this ingress is using "azure/application-gateway" | ||
_, err = makeGetRequest(url, "www.default.com", 404, true) | ||
Expect(err).To(BeNil(), "This should return 404 as this ingress is using 'azure/application-gateway'") | ||
|
||
// should return 200 as this ingress is using "custom-ingress-class" | ||
_, err = makeGetRequest(url, "www.custom.com", 200, true) | ||
Expect(err).To(BeNil(), "This should return 200 as this ingress is using 'custom-ingress-class'") | ||
}) | ||
|
||
AfterEach(func() { | ||
// clear all namespaces | ||
cleanUp(clientset) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: depl | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: app | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: app | ||
spec: | ||
containers: | ||
- name: ctr | ||
imagePullPolicy: Always | ||
image: docker.io/kennethreitz/httpbin | ||
ports: | ||
- name: port | ||
containerPort: 80 | ||
livenessProbe: | ||
httpGet: | ||
path: /status/200 | ||
port: 80 | ||
initialDelaySeconds: 3 | ||
periodSeconds: 3 | ||
imagePullSecrets: | ||
- name: acr-creds | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: svc | ||
spec: | ||
selector: | ||
app: app | ||
ports: | ||
- name: pp | ||
protocol: TCP | ||
port: 80 | ||
targetPort: port | ||
|
||
--- | ||
# This ingress is using "custom: custom-ingress-class" ingress class | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
annotations: | ||
kubernetes.io/ingress.class: custom-ingress-class | ||
name: custom-ingress-class | ||
spec: | ||
rules: | ||
- host: www.custom.com | ||
http: | ||
paths: | ||
- backend: | ||
serviceName: svc | ||
servicePort: pp | ||
path: /status* | ||
|
||
--- | ||
# This ingress is using "default: azure/application-gateway" ingress class | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
annotations: | ||
kubernetes.io/ingress.class: azure/application-gateway | ||
name: default-ingress-class | ||
spec: | ||
rules: | ||
- host: www.default.com | ||
http: | ||
paths: | ||
- backend: | ||
serviceName: svc | ||
servicePort: pp | ||
path: /status* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.