-
Notifications
You must be signed in to change notification settings - Fork 260
[CI] Add Cyclonus to merge validation #860
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Cyclonus Network Policy Test | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| schedule: | ||
| # run once a day at midnight | ||
| - cron: '0 0 * * *' | ||
|
|
||
| jobs: | ||
| cyclonus-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Make NPM image | ||
| run: | | ||
| VERSION=cyclonus make azure-npm-image | ||
|
|
||
| - name: Setup Kind | ||
| uses: engineerd/setup-kind@v0.5.0 | ||
| with: | ||
| version: "v0.9.0" | ||
| config: ./test/kind/kind.yaml | ||
| name: npm-kind | ||
|
|
||
| - name: Install Azure NPM | ||
| run: | | ||
| sed -i 's/mcr.microsoft.com\/containernetworking\/azure-npm:v1.3.1/acnpublic.azurecr.io\/azure-npm:cyclonus/' ./npm/azure-npm.yaml | ||
| kind load docker-image acnpublic.azurecr.io/azure-npm:cyclonus --name npm-kind | ||
matmerr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| kubectl apply -f ./npm/azure-npm.yaml | ||
|
|
||
| - name: Run Cyclonus network policy test | ||
| run: make test-cyclonus | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NPM has dependency about telemetricHandle before running each controller. Does it have enough time to fail them to start each controller before running test-cyclonus when using kind cluster? If not, it may fail some of the first testsets. Can you check it in log files? We eventually remove these dependency later. |
||
|
|
||
| - name: Fetch logs | ||
| if: always() | ||
| run: | | ||
| kubectl logs -n kube-system -l k8s-app=azure-npm --tail -1 --prefix > npm-logs.txt | ||
| mv ./test/cyclonus/cyclonus-test.txt ./cyclonus-test.txt | ||
|
|
||
| - name: 'Upload Logs' | ||
| uses: actions/upload-artifact@v2 | ||
| if: always() | ||
| with: | ||
| name: logs | ||
| path: | | ||
| ./npm-logs.txt | ||
| ./cyclonus-test.txt | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| apiVersion: batch/v1 | ||
| kind: Job | ||
| metadata: | ||
| name: cyclonus | ||
| namespace: kube-system | ||
| labels: | ||
| app: cyclonus | ||
| spec: | ||
| template: | ||
| spec: | ||
| restartPolicy: Never | ||
| containers: | ||
| - command: | ||
| - ./cyclonus | ||
| - generate | ||
| - --noisy=true | ||
| - --ignore-loopback=true | ||
| - --cleanup-namespaces=true | ||
| - --perturbation-wait-seconds=5 | ||
| - --pod-creation-timeout-seconds=20 | ||
| - --job-timeout-seconds=2 | ||
| - --server-protocol=TCP,UDP | ||
| - --server-port=80 | ||
| name: cyclonus | ||
| imagePullPolicy: IfNotPresent | ||
| image: mfenwick100/cyclonus:v0.4.4 | ||
| serviceAccount: cyclonus | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -eo pipefail | ||
| set -xv | ||
|
|
||
| kubectl delete --ignore-not-found=true clusterrolebinding cyclonus | ||
| kubectl delete --ignore-not-found=true sa cyclonus -n kube-system | ||
| kubectl delete --ignore-not-found=true -f ./install-cyclonus.yaml | ||
| kubectl delete --ignore-not-found=true ns x y z | ||
|
|
||
| sleep 5 | ||
|
|
||
| # set up cyclonus | ||
| kubectl create clusterrolebinding cyclonus --clusterrole=cluster-admin --serviceaccount=kube-system:cyclonus | ||
| kubectl create sa cyclonus -n kube-system | ||
| kubectl create -f ./install-cyclonus.yaml | ||
|
|
||
| time kubectl wait --for=condition=ready --timeout=1m pod -n kube-system -l job-name=cyclonus | ||
|
|
||
| #!/bin/bash | ||
| { kubectl logs -f -n kube-system job.batch/cyclonus; } & | ||
| { time kubectl wait --for=condition=completed --timeout=600m pod -n kube-system -l job-name=cyclonus; } & | ||
| wait -n | ||
| pkill -P $$ | ||
| echo done | ||
|
|
||
| # grab the job logs | ||
| LOG_FILE=cyclonus-test.txt | ||
| kubectl logs -n kube-system job.batch/cyclonus | tee "$LOG_FILE" | ||
| cat "$LOG_FILE" | ||
|
|
||
| kubectl delete --ignore-not-found=true clusterrolebinding cyclonus | ||
| kubectl delete --ignore-not-found=true sa cyclonus -n kube-system | ||
| kubectl delete --ignore-not-found=true -f ./install-cyclonus.yaml | ||
|
|
||
| # if 'failure' is in the logs, fail; otherwise succeed | ||
| rc=0 | ||
|
|
||
| cat "$LOG_FILE" | grep "failed" > /dev/null 2>&1 || rc=$? | ||
| echo $rc | ||
| if [ $rc -eq 0 ]; then | ||
| exit 1 | ||
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| kind: Cluster | ||
| apiVersion: kind.x-k8s.io/v1alpha4 | ||
| nodes: | ||
| - role: control-plane | ||
| image: kindest/node:v1.19.1 | ||
| - role: worker | ||
| image: kindest/node:v1.19.1 | ||
| - role: worker | ||
| image: kindest/node:v1.19.1 | ||
| networking: | ||
| ipFamily: ipv4 | ||
| podSubnet: "10.10.0.0/16" | ||
| serviceSubnet: "10.11.0.0/16" | ||
matmerr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.