-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub Action for unit tests and e2e test on k3s/k3d and minikube (do…
…cker and cri-o). (#118)
- Loading branch information
Showing
6 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |