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

e2e: test case for health probe annotations #1117

Merged
merged 8 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
100 changes: 100 additions & 0 deletions scripts/e2e/cmd/runner/mfu_one_namespace_one_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,106 @@ var _ = Describe("MFU", func() {
}
})

It("[health-probe-config] health probe configuration with annotation should be applied first", func() {
namespaceName := "health-probe-config"
3quanfeng marked this conversation as resolved.
Show resolved Hide resolved
ns := &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: namespaceName,
},
}
klog.Info("Creating namespace: ", namespaceName)
_, err = clientset.CoreV1().Namespaces().Create(ns)
Expect(err).To(BeNil())

healthConfigProbeYamlPath := "testdata/one-namespace-one-ingress/health-probe-configurations/app.yaml"
klog.Info("Applying yaml: ", healthConfigProbeYamlPath)
err = applyYaml(clientset, "", healthConfigProbeYamlPath)
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(""))

// initial deployment should be ok for the request
url := fmt.Sprintf("http://%s/status/200", publicIP)
_, err = makeGetRequest(url, "", 200, true)
Expect(err).To(BeNil())

// start to configure with bad hostname, 502 is expected
healthConfigProbeBadHostnameYamlPath := "testdata/one-namespace-one-ingress/health-probe-configurations/probe-hostname-bad.yaml"
klog.Info("Applying ingress with bad hostname annotation")
err = applyYaml(clientset, "", healthConfigProbeBadHostnameYamlPath)
Expect(err).To(BeNil())
time.Sleep(15 * time.Second)
_, err = makeGetRequest(url, "", 502, true)
Expect(err).To(BeNil())

// start to configure with good hostname, 200 is expected
healthConfigProbeGoodHostnameYamlPath := "testdata/one-namespace-one-ingress/health-probe-configurations/probe-hostname-good.yaml"
klog.Info("Applying ingress with good hostname annotation")
err = applyYaml(clientset, "", healthConfigProbeGoodHostnameYamlPath)
Expect(err).To(BeNil())
time.Sleep(15 * time.Second)
_, err = makeGetRequest(url, "", 200, true)
Expect(err).To(BeNil())

// start to configure with bad path, 502 is expected
healthConfigProbeBadPathYamlPath := "testdata/one-namespace-one-ingress/health-probe-configurations/probe-path-bad.yaml"
klog.Info("Applying ingress with bad path annotation")
err = applyYaml(clientset, "", healthConfigProbeBadPathYamlPath)
Expect(err).To(BeNil())
time.Sleep(15 * time.Second)
_, err = makeGetRequest(url, "", 502, true)
Expect(err).To(BeNil())

// start to configure with good path, 200 is expected
healthConfigProbeGoodPathYamlPath := "testdata/one-namespace-one-ingress/health-probe-configurations/probe-path-good.yaml"
klog.Info("Applying ingress with good path annotation")
err = applyYaml(clientset, "", healthConfigProbeGoodPathYamlPath)
Expect(err).To(BeNil())
time.Sleep(15 * time.Second)
_, err = makeGetRequest(url, "", 200, true)
Expect(err).To(BeNil())

// start to configure with bad port, 502 is expected
healthConfigProbeBadPortYamlPath := "testdata/one-namespace-one-ingress/health-probe-configurations/probe-port-bad.yaml"
klog.Info("Applying ingress with bad port annotation")
err = applyYaml(clientset, "", healthConfigProbeBadPortYamlPath)
Expect(err).To(BeNil())
time.Sleep(15 * time.Second)
_, err = makeGetRequest(url, "", 502, true)
Expect(err).To(BeNil())

// start to configure with good port, 200 is expected
healthConfigProbeGoodPortYamlPath := "testdata/one-namespace-one-ingress/health-probe-configurations/probe-port-good.yaml"
klog.Info("Applying ingress with good port annotation")
err = applyYaml(clientset, "", healthConfigProbeGoodPortYamlPath)
Expect(err).To(BeNil())
time.Sleep(15 * time.Second)
_, err = makeGetRequest(url, "", 200, true)
Expect(err).To(BeNil())

// start to configure with bad status, 502 is expected
healthConfigProbeBadStatusYamlPath := "testdata/one-namespace-one-ingress/health-probe-configurations/probe-status-bad.yaml"
klog.Info("Applying ingress with bad status annotation")
err = applyYaml(clientset, "", healthConfigProbeBadStatusYamlPath)
Expect(err).To(BeNil())
time.Sleep(15 * time.Second)
_, err = makeGetRequest(url, "", 502, true)
Expect(err).To(BeNil())

// start to configure with good status, 200 is expected
healthConfigProbeGoodStatusYamlPath := "testdata/one-namespace-one-ingress/health-probe-configurations/probe-status-good.yaml"
klog.Info("Applying ingress with good status annotation")
err = applyYaml(clientset, "", healthConfigProbeGoodStatusYamlPath)
Expect(err).To(BeNil())
time.Sleep(15 * time.Second)
_, err = makeGetRequest(url, "", 200, true)
Expect(err).To(BeNil())
})

It("[container-readiness-probe] backend should be removed when health probe is not healthy", func() {
// http get to return 200 ok
for _, nm := range []string{"e2e-probe1", "e2e-probe2"} {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
spec:
selector:
matchLabels:
app: test-app
replicas: 1
template:
metadata:
labels:
app: test-app
spec:
containers:
- name: test-app
imagePullPolicy: Always
image: docker.io/kennethreitz/httpbin
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /statusx/200
port: 80
host: localhostx
3quanfeng marked this conversation as resolved.
Show resolved Hide resolved
initialDelaySeconds: 3
periodSeconds: 3
imagePullSecrets:
- name: acr-creds
---

apiVersion: v1
kind: Service
metadata:
name: test-service
spec:
selector:
app: test-app
ports:
- protocol: TCP
port: 80
targetPort: 80

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-interval: "1"
appgw.ingress.kubernetes.io/health-probe-unhealthy-threshold: "3"
appgw.ingress.kubernetes.io/health-probe-timeout: "1
spec:
rules:
- http:
paths:
- path: /status/*
backend:
serviceName: test-service
servicePort: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-hostname: localhost1
appgw.ingress.kubernetes.io/health-probe-interval: "1"
appgw.ingress.kubernetes.io/health-probe-unhealthy-threshold: "3"
appgw.ingress.kubernetes.io/health-probe-timeout: "1
spec:
rules:
- http:
paths:
- path: /status/*
backend:
serviceName: test-service
servicePort: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-hostname: localhost
appgw.ingress.kubernetes.io/health-probe-interval: "1"
appgw.ingress.kubernetes.io/health-probe-unhealthy-threshold: "3"
appgw.ingress.kubernetes.io/health-probe-timeout: "1
spec:
rules:
- http:
paths:
- path: /status/*
backend:
serviceName: test-service
servicePort: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-path: "/statuss/200"
appgw.ingress.kubernetes.io/health-probe-interval: "1"
appgw.ingress.kubernetes.io/health-probe-unhealthy-threshold: "3"
appgw.ingress.kubernetes.io/health-probe-timeout: "1
spec:
rules:
- http:
paths:
- path: /status/*
backend:
serviceName: test-service
servicePort: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-path: "/status/200"
appgw.ingress.kubernetes.io/health-probe-interval: "1"
appgw.ingress.kubernetes.io/health-probe-unhealthy-threshold: "3"
appgw.ingress.kubernetes.io/health-probe-timeout: "1
spec:
rules:
- http:
paths:
- path: /status/*
backend:
serviceName: test-service
servicePort: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-port: "81"
appgw.ingress.kubernetes.io/health-probe-interval: "1"
appgw.ingress.kubernetes.io/health-probe-unhealthy-threshold: "3"
appgw.ingress.kubernetes.io/health-probe-timeout: "1
spec:
rules:
- http:
paths:
- path: /status/*
backend:
serviceName: test-service
servicePort: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-port: "80"
appgw.ingress.kubernetes.io/health-probe-interval: "1"
appgw.ingress.kubernetes.io/health-probe-unhealthy-threshold: "3"
appgw.ingress.kubernetes.io/health-probe-timeout: "1
spec:
rules:
- http:
paths:
- path: /status/*
backend:
serviceName: test-service
servicePort: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-status-codes: "201"
appgw.ingress.kubernetes.io/health-probe-interval: "1"
appgw.ingress.kubernetes.io/health-probe-unhealthy-threshold: "3"
appgw.ingress.kubernetes.io/health-probe-timeout: "1
spec:
rules:
- http:
paths:
- path: /status/*
backend:
serviceName: test-service
servicePort: 80
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: azure/application-gateway
appgw.ingress.kubernetes.io/health-probe-status-codes: "200"
appgw.ingress.kubernetes.io/health-probe-interval: "1"
appgw.ingress.kubernetes.io/health-probe-unhealthy-threshold: "3"
appgw.ingress.kubernetes.io/health-probe-timeout: "1"
spec:
rules:
- http:
paths:
- path: /status/*
backend:
serviceName: test-service
servicePort: 80