k8s-deploy/.github/workflows/run-integration-tests.yml
David Gamero 5cbd4acaca
Add Minikube integration testing workflow (#160)
Move integration testing into pull_request action that is isolated to an action runner using minikube

Co-authored-by: David Gamero <davidgamero@microsoft.com>
2021-12-07 16:21:34 -05:00

200 lines
8.6 KiB
YAML

name: Minikube Integration Tests
on: pull_request
jobs:
run-integration-test:
name: Run Minikube Integration Tests
runs-on: ubuntu-latest
env:
KUBECONFIG: /home/runner/.kube/config
steps:
- uses: actions/checkout@v2
- name: Building latest changes
run: |
npm install
npm run build
- name: Set name of ns
run: echo "::set-output name=name::$(echo `date +%Y%m%d%H%M%S`)"
shell: bash
id: ns
- uses: Azure/setup-kubectl@v1
name: Install Kubectl
- id: setup-minikube
name: Setup Minikube
uses: manusa/actions-setup-minikube@v2.4.2
with:
minikube version: "v1.24.0"
kubernetes version: "v1.17.8"
driver: "none"
timeout-minutes: 3
- name: Create namespace to run tests
run: kubectl create ns test-${{ steps.ns.outputs.name }}
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: "3.x"
- name: Cleaning any previously created items
run: |
python test/integration/k8s-deploy-delete.py 'Service' 'nginx-service' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-delete.py 'Service' 'nginx-service-green' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-delete.py 'Deployment' 'nginx-deployment-green' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-delete.py 'Deployment' 'nginx-deployment' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-delete.py 'Ingress' 'nginx-ingress' ${{ steps.ns.outputs.name }}
- name: Executing deploy action
uses: ./
with:
namespace: test-${{ steps.ns.outputs.name }}
images: nginx:1.14.2
manifests: |
test/integration/manifests/test-service.yml
strategy: blue-green
route-method: service
action: deploy
- name: Checking if deploments and services were created with green labels
run: |
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment-green' 'green' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Service' 'nginx-service' 'green' ${{ steps.ns.outputs.name }}
- name: Executing promote action
uses: ./
with:
namespace: test-${{ steps.ns.outputs.name }}
images: nginx:1.14.2
manifests: |
test/integration/manifests/test-service.yml
strategy: blue-green
route-method: service
action: promote
- name: Checking if deploments and services were created with none labels after promote
run: |
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment' 'None' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Service' 'nginx-service' 'None' ${{ steps.ns.outputs.name }}
- name: Executing deploy action on
uses: ./
with:
namespace: test-${{ steps.ns.outputs.name }}
images: nginx:1.19.1
manifests: |
test/integration/manifests/test-service.yml
strategy: blue-green
route-method: service
action: deploy
- name: Checking if deploments and services were created with green labels, and old workloads persist on deploy
run: |
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment-green' 'green' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Service' 'nginx-service' 'green' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment' 'None' ${{ steps.ns.outputs.name }}
- name: Executing reject action
uses: ./
with:
namespace: test-${{ steps.ns.outputs.name }}
images: nginx:1.19.1
manifests: |
test/integration/manifests/test-service.yml
strategy: blue-green
route-method: service
action: reject
- name: Checking if deploments and services were routed back to none labels after reject
run: |
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment' 'None' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Service' 'nginx-service' 'None' ${{ steps.ns.outputs.name }}
- name: Cleaning up current set up
run: |
python test/integration/k8s-deploy-delete.py 'Service' 'nginx-service' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-delete.py 'Deployment' 'nginx-deployment' ${{ steps.ns.outputs.name }}
- name: Executing deploy action for ingress
uses: ./
with:
namespace: test-${{ steps.ns.outputs.name }}
images: nginx:1.14.2
manifests: |
test/integration/manifests/test-ingress.yml
strategy: blue-green
route-method: ingress
action: deploy
- name: Checking if deploments, services and ingresses were created with green labels
run: |
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment-green' 'green' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Service' 'nginx-service-green' 'green' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Ingress' 'nginx-ingress' 'green' ${{ steps.ns.outputs.name }}
- name: Executing promote action for ingress
uses: ./
with:
namespace: test-${{ steps.ns.outputs.name }}
images: nginx:1.14.2
manifests: |
test/integration/manifests/test-ingress.yml
strategy: blue-green
route-method: ingress
action: promote
- name: Checking if deploments, services and ingresses were created with none labels after promote
run: |
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment' 'None' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Service' 'nginx-service' 'None' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Ingress' 'nginx-ingress' 'None' ${{ steps.ns.outputs.name }}
- name: Executing deploy action for ingress
uses: ./
with:
namespace: test-${{ steps.ns.outputs.name }}
images: nginx:1.19.1
manifests: |
test/integration/manifests/test-ingress.yml
strategy: blue-green
route-method: ingress
action: deploy
- name: Checking if deploments, services and ingresses were created with green labels after deploy, and old deployment persists
run: |
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment-green' 'green' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment' 'None' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Service' 'nginx-service' 'None' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Service' 'nginx-service-green' 'green' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Ingress' 'nginx-ingress' 'green' ${{ steps.ns.outputs.name }}
- name: Executing reject action for ingress
uses: ./
with:
namespace: test-${{ steps.ns.outputs.name }}
images: nginx:1.19.1
manifests: |
test/integration/manifests/test-ingress.yml
strategy: blue-green
route-method: ingress
action: reject
- name: Checking if deploments, services and ingresses were created with none labels after reject
run: |
python test/integration/k8s-deploy-test.py 'Deployment' 'nginx-deployment' 'None' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Service' 'nginx-service' 'None' ${{ steps.ns.outputs.name }}
python test/integration/k8s-deploy-test.py 'Ingress' 'nginx-ingress' 'None' ${{ steps.ns.outputs.name }}
- if: ${{ always() }}
name: Delete created namespace
run: kubectl delete ns test-${{ steps.ns.outputs.name }}
- if: ${{ always() }}
name: Posting result back to PR
run: |
if [ '${{ steps.job-type.outputs.type }}' == 'pr' ]; then ruby postStatus.rb ${{github.event.client_payload.repository}} ${{github.event.client_payload.commit}} ${{secrets.L2_REPO_TOKEN}} ${{job.status}} ${{github.run_id}} ${{matrix.os}} false ${{ secrets.L2_REPO_USER }}; fi
shell: bash