Skip to content

Commit e9693a7

Browse files
authored
Added Integration Tests, Resolved Bugs With Annotations (#255)
* First commit - made manifests for test deployments, made manifests for i tests for other deployment strategies * broke down blue/green * added latest tags to test manifests for new tags * remade tester * ready to test bgi * using all but first index of argv * careless error with dicts * added test to namespace * realized i was silencing error * indexing containers * keyerror * logging bc python errors are weird * expected still string * parsed args behaving weirdly * test seems to be working now, applying changes to other YAMLs now * blue/green ready to test * oops * oops * Added additional labels to check * hyphen * Added our annotations * lol * added our labels to services too * nonetype issue' * nonetype issue' * narrowing down parameter * fixed annotations issue with promote * adding debhug statement to figure out why services aren't getting annotations * this should fix annotations issue for service * not sure why this wasn't caught by intellisense * should be fixed with removing comma but adding logs in case * added linkerd install * verification * upgraded kubernetes version * removing crds * proxy option * Added smi extension * logging service * smi svcs also getting labeled now * matching ts type * not sure where stable service is going * remaining svc and deployment should match * keeping stable service and ts object * updated tests to reflect keeping ts object * no green svc after promote * duh * lol * canary work * canary test ready * logging for ing, filename for canary * changed ingress svc key and returning svc files from smi canary deployment * ts name * forgot about baseline in first deploy * * * * * smi canary should annotate, fixed cleanup * typescript issue plus percentage * forgot to type extra method * removed cleaned up objects from annotate list * logging because services aren't getting removed * moving to try/catch strategy of annotation since deletion can fail silently/with warnings * moved label to individual * removing canary service check after promote * pod ready for testing * set weights to 1000 * selectors * * * percentage * * * typing * mixed up pod and smi * fixed tests * prettier * forgot to remove canary * cleanup * Added oliver's feedback + more cleanup * ncc as dev dependency * npx * going back to global ncc install bc npm is being weird * prettier * removed unnecessary post step
1 parent a6cfc31 commit e9693a7

24 files changed

+1672
-317
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Minikube Integration Tests - basic
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
- 'releases/*'
7+
push:
8+
branches:
9+
- main
10+
- 'releases/*'
11+
workflow_dispatch:
12+
13+
jobs:
14+
run-integration-test:
15+
name: Run Minikube Integration Tests
16+
runs-on: ubuntu-latest
17+
env:
18+
KUBECONFIG: /home/runner/.kube/config
19+
NAMESPACE: test-${{ github.run_id }}
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Install dependencies
24+
run: |
25+
rm -rf node_modules/
26+
npm install
27+
- name: Install ncc
28+
run: npm i -g @vercel/ncc
29+
- name: Build
30+
run: ncc build src/run.ts -o lib
31+
32+
- uses: Azure/setup-kubectl@v3
33+
name: Install Kubectl
34+
35+
- id: setup-minikube
36+
name: Setup Minikube
37+
uses: manusa/[email protected]
38+
with:
39+
minikube version: 'v1.24.0'
40+
kubernetes version: 'v1.21.0'
41+
driver: 'none'
42+
timeout-minutes: 3
43+
44+
- name: Create namespace to run tests
45+
run: kubectl create ns ${{ env.NAMESPACE }}
46+
47+
- uses: actions/setup-python@v2
48+
name: Install Python
49+
with:
50+
python-version: '3.x'
51+
52+
- name: Cleaning any previously created items
53+
run: |
54+
python test/integration/k8s-deploy-delete.py 'Service' 'all' ${{ env.NAMESPACE }}
55+
python test/integration/k8s-deploy-delete.py 'Deployment' 'all' ${{ env.NAMESPACE }}
56+
python test/integration/k8s-deploy-delete.py 'Ingress' 'all' ${{ env.NAMESPACE }}
57+
58+
- name: Executing deploy action for pod
59+
uses: ./
60+
with:
61+
namespace: ${{ env.NAMESPACE }}
62+
images: nginx:1.14.2
63+
manifests: |
64+
test/integration/manifests/test.yml
65+
action: deploy
66+
67+
- name: Checking if deployments and services were created with canary labels and original tag
68+
run: |
69+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment containerName=nginx:1.14.2 labels=app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_basic selectorLabels=app:nginx
70+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_basic selectorLabels=app:nginx
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: Minikube Integration Tests - blue-green ingress
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
- 'releases/*'
7+
push:
8+
branches:
9+
- main
10+
- 'releases/*'
11+
workflow_dispatch:
12+
13+
jobs:
14+
run-integration-test:
15+
name: Run Minikube Integration Tests
16+
runs-on: ubuntu-latest
17+
env:
18+
KUBECONFIG: /home/runner/.kube/config
19+
NAMESPACE: test-${{ github.run_id }}
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Install dependencies
24+
run: |
25+
rm -rf node_modules/
26+
npm install
27+
- name: Install ncc
28+
run: npm i -g @vercel/ncc
29+
- name: Build
30+
run: ncc build src/run.ts -o lib
31+
32+
- uses: Azure/setup-kubectl@v3
33+
name: Install Kubectl
34+
35+
- id: setup-minikube
36+
name: Setup Minikube
37+
uses: manusa/[email protected]
38+
with:
39+
minikube version: 'v1.24.0'
40+
kubernetes version: 'v1.21.0'
41+
driver: 'none'
42+
timeout-minutes: 3
43+
44+
- name: Create namespace to run tests
45+
run: kubectl create ns ${{ env.NAMESPACE }}
46+
47+
- uses: actions/setup-python@v2
48+
name: Install Python
49+
with:
50+
python-version: '3.x'
51+
52+
- name: Cleaning any previously created items
53+
run: |
54+
python test/integration/k8s-deploy-delete.py 'Service' 'nginx-service' ${{ env.NAMESPACE }}
55+
python test/integration/k8s-deploy-delete.py 'Service' 'nginx-service-green' ${{ env.NAMESPACE }}
56+
python test/integration/k8s-deploy-delete.py 'Deployment' 'nginx-deployment-green' ${{ env.NAMESPACE }}
57+
python test/integration/k8s-deploy-delete.py 'Deployment' 'nginx-deployment' ${{ env.NAMESPACE }}
58+
python test/integration/k8s-deploy-delete.py 'Ingress' 'nginx-ingress' ${{ env.NAMESPACE }}
59+
60+
- name: Executing deploy action for ingress
61+
uses: ./
62+
with:
63+
namespace: ${{ env.NAMESPACE }}
64+
images: nginx:1.14.2
65+
manifests: |
66+
test/integration/manifests/blue-green/test-ingress.yml
67+
strategy: blue-green
68+
route-method: ingress
69+
action: deploy
70+
71+
- name: Checking if deployments, services and ingresses were created with green labels and original tag
72+
run: |
73+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment-green containerName=nginx:1.14.2 labels=k8s.deploy.color:green,app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:green
74+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service-green labels=k8s.deploy.color:green,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:green
75+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Ingress name=nginx-ingress ingressServices=nginx-service-green,unrouted-service
76+
77+
- name: Executing promote action for ingress
78+
uses: ./
79+
with:
80+
namespace: ${{ env.NAMESPACE }}
81+
images: nginx:1.14.2
82+
manifests: |
83+
test/integration/manifests/blue-green/test-ingress.yml
84+
strategy: blue-green
85+
route-method: ingress
86+
action: promote
87+
88+
- name: Checking if deployments, services and ingresses were created with none labels after first promote
89+
run: |
90+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment containerName=nginx:1.14.2 labels=k8s.deploy.color:None,app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
91+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=k8s.deploy.color:None,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
92+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Ingress name=nginx-ingress ingressServices=nginx-service,unrouted-service
93+
94+
- name: Executing second deploy action for ingress with new tag
95+
uses: ./
96+
with:
97+
namespace: ${{ env.NAMESPACE }}
98+
images: nginx:latest
99+
manifests: |
100+
test/integration/manifests/blue-green/test-ingress.yml
101+
strategy: blue-green
102+
route-method: ingress
103+
action: deploy
104+
105+
- name: Checking if deployments (with new tag), services and ingresses were created with green labels after deploy, and old deployment persists
106+
run: |
107+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment-green containerName=nginx:latest labels=k8s.deploy.color:green,app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:green
108+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment containerName=nginx:1.14.2 labels=k8s.deploy.color:None,app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
109+
110+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service-green labels=k8s.deploy.color:green,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:green
111+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=k8s.deploy.color:None,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
112+
113+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Ingress name=nginx-ingress ingressServices=nginx-service-green,unrouted-service
114+
115+
- name: Executing second promote action for ingress now using new image tag
116+
uses: ./
117+
with:
118+
namespace: ${{ env.NAMESPACE }}
119+
images: nginx:latest
120+
manifests: |
121+
test/integration/manifests/blue-green/test-ingress.yml
122+
strategy: blue-green
123+
route-method: ingress
124+
action: promote
125+
126+
- name: Checking if deployments, services and ingresses were created with none labels after promote for new tag
127+
run: |
128+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment containerName=nginx:latest labels=k8s.deploy.color:None,app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
129+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=k8s.deploy.color:None,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
130+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Ingress name=nginx-ingress ingressServices=nginx-service,unrouted-service
131+
132+
- name: Executing deploy action for ingress to be rejected using old tag
133+
uses: ./
134+
with:
135+
namespace: ${{ env.NAMESPACE }}
136+
images: nginx:1.14.2
137+
manifests: |
138+
test/integration/manifests/blue-green/test-ingress.yml
139+
strategy: blue-green
140+
route-method: ingress
141+
action: deploy
142+
143+
- name: Checking if new deployments (with old tag), services and ingresses were created with green labels after deploy, and old deployment (with latest tag) persists
144+
run: |
145+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment-green containerName=nginx:1.14.2 labels=k8s.deploy.color:green,app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:green
146+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment containerName=nginx:latest labels=k8s.deploy.color:None,app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
147+
148+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service-green labels=k8s.deploy.color:green,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:green
149+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=k8s.deploy.color:None,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
150+
151+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Ingress name=nginx-ingress ingressServices=nginx-service-green,unrouted-service
152+
153+
- name: Executing reject action for ingress to reject new deployment with 1.14.2 tag
154+
uses: ./
155+
with:
156+
namespace: ${{ env.NAMESPACE }}
157+
images: nginx:1.14.2
158+
manifests: |
159+
test/integration/manifests/blue-green/test-ingress.yml
160+
strategy: blue-green
161+
route-method: ingress
162+
action: reject
163+
164+
# MAY BE USEFUL TO ADD AN ANTI-CHECK - CHECK TO MAKE SURE CERTAIN OBJECTS DON'T EXIST
165+
- name: Checking if deployments, services and ingresses were created with none labels and latest tag after reject
166+
run: |
167+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment containerName=nginx:latest labels=k8s.deploy.color:None,app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
168+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=k8s.deploy.color:None,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_blue-green_ingress selectorLabels=app:nginx,k8s.deploy.color:None
169+
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Ingress name=nginx-ingress ingressServices=nginx-service,unrouted-service
170+
171+
- name: Cleaning up current set up
172+
run: |
173+
python test/integration/k8s-deploy-delete.py 'Service' 'nginx-service' ${{ env.NAMESPACE }}
174+
python test/integration/k8s-deploy-delete.py 'Deployment' 'nginx-deployment' ${{ env.NAMESPACE }}
175+
176+
- if: ${{ always() }}
177+
name: Delete created namespace
178+
run: kubectl delete ns ${{ env.NAMESPACE }}

0 commit comments

Comments
 (0)