|
| 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 | + |
| 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