Skip to content

Commit

Permalink
GitHub Action for unit tests and e2e test on k3s/k3d and minikube (do…
Browse files Browse the repository at this point in the history
…cker and cri-o). (#118)
  • Loading branch information
bostrt authored Aug 6, 2021
1 parent b882817 commit e299ffb
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/assets/busybox-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Pod
metadata:
name: busybox-sleep
spec:
containers:
- name: busybox
image: busybox
args:
- sleep
- "10000"
17 changes: 17 additions & 0 deletions .github/workflows/assets/placeholder-kubeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
clusters:
- cluster:
server: http://example.com
name: example
contexts:
- context:
cluster: example
user: test
name: test
current-context: test
kind: Config
preferences: {}
users:
- name: test
user:
token: xxxxx
74 changes: 74 additions & 0 deletions .github/workflows/k3d-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This is a basic workflow to help you get started with Actions

name: k3s-e2e

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: AbsaOSS/[email protected]
name: "Create Single Cluster"
with:
cluster-name: "test-cluster-1"
args: --agents 1

- name: Deploy test pod
run: |
kubectl config use-context k3d-test-cluster-1
kubectl create -f .github/workflows/assets/busybox-pod.yaml
kubectl wait --for=condition=Ready pod/busybox-sleep
- name: Build
run: |
make
- name: Run ksniff privileged
run: |
kubectl config use-context k3d-test-cluster-1
sleep 60 && pkill kubectl-sniff &
set +e
./kubectl-sniff busybox-sleep --privileged --namespace default --socket /run/k3s/containerd/containerd.sock --output-file /tmp/output.pcap
set -e
if [ ! -f /tmp/output.pcap ]; then
echo "PCAP not created"
exit 1
fi
- if: failure()
name: Check pod and events
run: |
kubectl get pods
kubectl get events
- name: Build static-tcpdmp
run: |
sudo apt-get install libpcap-dev
make static-tcpdump
make install
- name: Run ksniff with static tcpdump
run: |
kubectl config use-context k3d-test-cluster-1
sleep 60 && pkill kubectl-sniff &
set +e
./kubectl-sniff busybox-sleep --namespace default --output-file /tmp/output.pcap
set -e
if [ ! -f /tmp/output.pcap ]; then
echo "PCAP not created"
exit 1
fi
65 changes: 65 additions & 0 deletions .github/workflows/minikube-e2e-crio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: minikube-e2e-crio

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Minikube
uses: manusa/[email protected]
with:
minikube version: 'v1.22.0'
kubernetes version: 'v1.21.2'
driver: docker
start args: --wait=all --container-runtime=cri-o
# github token: ${{ secrets.GITHUB_TOKEN }} Uncomment if we have API limit issues
- name: Deploy test pod
run: |
kubectl create -f .github/workflows/assets/busybox-pod.yaml
kubectl wait --for=condition=Ready pod/busybox-sleep
- name: Build
run: |
make
- name: Run ksniff privileged
run: |
sleep 60 && pkill kubectl-sniff &
set +e
./kubectl-sniff busybox-sleep --privileged --namespace default --output-file /tmp/output.pcap
set -e
if [ ! -f /tmp/output.pcap ]; then
echo "PCAP not created"
exit 1
fi
- if: failure()
name: Check pod and events
run: |
kubectl get pods
kubectl get events
- name: Build static-tcpdmp
run: |
sudo apt-get install libpcap-dev
make static-tcpdump
make install
- name: Run ksniff with static tcpdump
run: |
sleep 60 && pkill kubectl-sniff &
set +e
./kubectl-sniff busybox-sleep --namespace default --output-file /tmp/output.pcap
set -e
if [ ! -f /tmp/output.pcap ]; then
echo "PCAP not created"
exit 1
fi
64 changes: 64 additions & 0 deletions .github/workflows/minikube-e2e-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: minikube-e2e-docker

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Minikube
uses: manusa/[email protected]
with:
minikube version: 'v1.22.0'
kubernetes version: 'v1.21.2'
start args: --wait=all
# github token: ${{ secrets.GITHUB_TOKEN }} Uncomment if we have API limit issues
- name: Deploy test pod
run: |
kubectl create -f .github/workflows/assets/busybox-pod.yaml
kubectl wait --for=condition=Ready pod/busybox-sleep
- name: Build
run: |
make
- name: Run ksniff privileged
run: |
sleep 60 && pkill kubectl-sniff &
set +e
./kubectl-sniff busybox-sleep --privileged --namespace default --output-file /tmp/output.pcap
set -e
if [ ! -f /tmp/output.pcap ]; then
echo "PCAP not created"
exit 1
fi
- if: failure()
name: Check pod and events
run: |
kubectl get pods
kubectl get events
- name: Build static-tcpdmp
run: |
sudo apt-get install libpcap-dev
make static-tcpdump
make install
- name: Run ksniff with static tcpdump
run: |
sleep 60 && pkill kubectl-sniff &
set +e
./kubectl-sniff busybox-sleep --namespace default --output-file /tmp/output.pcap
set -e
if [ ! -f /tmp/output.pcap ]; then
echo "PCAP not created"
exit 1
fi
25 changes: 25 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: unit-test

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Copy kubeconfig
run: |
mkdir ~/.kube
cp .github/workflows/assets/placeholder-kubeconfig.yaml ~/.kube/config
# Run the tests
- name: Run make test
run: make test

0 comments on commit e299ffb

Please sign in to comment.