Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/cyclonus-netpol-extended-nightly-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Cyclonus Network Policy Extended Test

on:
workflow_dispatch:
schedule:
# run once a day at midnight
- cron: "0 0 * * *"

jobs:
cyclonus-test:
runs-on: ubuntu-latest
timeout-minutes: 240
strategy:
matrix:
# run cyclonus tests in parallel for NPM with the given ConfigMaps
profile:
[
v1-default.yaml,
v1-place-azure-chain-first.yaml,
v2-default.yaml,
v2-apply-on-need.yaml,
v2-place-azure-after-kube-services.yaml,
]
steps:
- name: Checkout
uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: "^1.17"

- name: Setup Kind
uses: engineerd/setup-kind@v0.5.0
with:
version: "v0.11.1"
config: ./test/kind/kind.yaml
name: npm-kind

- name: Check Kind
run: |
kubectl get po -owide -A

- name: Make NPM image
run: |
make npm-image VERSION=cyclonus PLATFORM=linux/amd64 CONTAINER_BUILDER=docker

- name: Install Azure NPM
# set the ConfigMap based on the build matrix
# currently have to restart the daemonset because changing the ConfigMap doesn't restart NPM
run: |
sed -i 's/mcr.microsoft.com\/containernetworking\/azure-npm:.*/acnpublic.azurecr.io\/azure-npm:cyclonus/' ./npm/azure-npm.yaml
kind load docker-image acnpublic.azurecr.io/azure-npm:cyclonus --name npm-kind
kubectl apply -f ./npm/azure-npm.yaml
echo "Applying profile: ${{ matrix.profile }}"
kubectl apply -f ./npm/profiles/${{ matrix.profile }}
kubectl rollout restart ds azure-npm -n kube-system

- name: Check Cluster Components
run: |
sleep 10
kubectl get po -owide -A
kubectl describe ds azure-npm -n kube-system

- name: Run Cyclonus network policy test
run: make test-extended-cyclonus

- name: Fetch logs
if: always()
run: |
kubectl logs -n kube-system -l k8s-app=azure-npm --tail -1 --prefix > npm-logs_${{ matrix.profile }}.txt
mv ./test/cyclonus/cyclonus-test.txt ./cyclonus-test_${{ matrix.profile }}.txt

- name: "Upload Logs"
uses: actions/upload-artifact@v2
if: always()
with:
name: logs
path: |
./npm-logs_${{ matrix.profile }}.txt
./cyclonus-test_${{ matrix.profile }}.txt
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ test-cyclonus: ## run the cyclonus test for npm.
cd test/cyclonus && bash ./test-cyclonus.sh
cd ..

test-extended-cyclonus: ## run the cyclonus test for npm.
cd test/cyclonus && bash ./test-cyclonus.sh extended
cd ..

.PHONY: kind
kind:
kind create cluster --config ./test/kind/kind.yaml
Expand Down
27 changes: 27 additions & 0 deletions test/cyclonus/install-cyclonus-exclude-sctp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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=30
- --job-timeout-seconds=2
- --server-protocol=TCP,UDP
- --exclude=sctp
name: cyclonus
imagePullPolicy: IfNotPresent
image: mfenwick100/cyclonus:v0.4.7
serviceAccount: cyclonus
3 changes: 1 addition & 2 deletions test/cyclonus/install-cyclonus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ spec:
- --pod-creation-timeout-seconds=30
- --job-timeout-seconds=2
- --server-protocol=TCP,UDP
- --verbosity=debug
name: cyclonus
imagePullPolicy: IfNotPresent
image: mfenwick100/cyclonus:v0.4.7
serviceAccount: cyclonus
serviceAccount: cyclonus
17 changes: 14 additions & 3 deletions test/cyclonus/test-cyclonus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@
set -eo pipefail
set -xv

cyclonusProfile="./install-cyclonus.yaml"
if [ -z "$1" ]
then
echo "Running with default profile: $cyclonusProfile"
elif [[ $1 == "extended" ]];
then
# extended will exclude SCTP and will run 214 testcases with cyclonus
cyclonusProfile="./install-cyclonus-exclude-sctp.yaml"
echo "Running with exclude SCTP profile with 214 testcases: $cyclonusProfile"
fi

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 -f $cyclonusProfile
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
kubectl create -f $cyclonusProfile

sleep 5

Expand All @@ -33,7 +44,7 @@ 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
kubectl delete --ignore-not-found=true -f $cyclonusProfile

# if 'failure' is in the logs, fail; otherwise succeed
rc=0
Expand Down