From 73c6d555b55f55f6d47ca5a9d0f3c379348f9325 Mon Sep 17 00:00:00 2001 From: Wade Simmons Date: Tue, 17 Dec 2019 00:17:25 -0500 Subject: [PATCH 1/2] Github Actions: Smoke test This change adds a new Github Action, a 3 node smoke test. It starts three docker containers (one lighthouse and two standard nodes) and tests that they can all ping each other. This should hopefully detect any basic runtime failures in PRs. --- .github/workflows/smoke.yml | 34 +++++++++++++++++++++++++ .github/workflows/smoke/.gitignore | 1 + .github/workflows/smoke/Dockerfile | 5 ++++ .github/workflows/smoke/build.sh | 21 +++++++++++++++ .github/workflows/smoke/host2.yml | 31 ++++++++++++++++++++++ .github/workflows/smoke/host3.yml | 31 ++++++++++++++++++++++ .github/workflows/smoke/lighthouse1.yml | 25 ++++++++++++++++++ .github/workflows/smoke/smoke.sh | 34 +++++++++++++++++++++++++ 8 files changed, 182 insertions(+) create mode 100644 .github/workflows/smoke.yml create mode 100644 .github/workflows/smoke/.gitignore create mode 100644 .github/workflows/smoke/Dockerfile create mode 100755 .github/workflows/smoke/build.sh create mode 100644 .github/workflows/smoke/host2.yml create mode 100644 .github/workflows/smoke/host3.yml create mode 100644 .github/workflows/smoke/lighthouse1.yml create mode 100755 .github/workflows/smoke/smoke.sh diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml new file mode 100644 index 0000000..71accea --- /dev/null +++ b/.github/workflows/smoke.yml @@ -0,0 +1,34 @@ +name: smoke +on: + push: + branches: + - master + pull_request: +jobs: + + smoke: + name: Run 3 node smoke test + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: build + run: make + + - name: setup docker image + working-directory: ./.github/workflows/smoke + run: ./build.sh + + - name: run smoke + working-directory: ./.github/workflows/smoke + run: ./smoke.sh + + timeout-minutes: 10 diff --git a/.github/workflows/smoke/.gitignore b/.github/workflows/smoke/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/.github/workflows/smoke/.gitignore @@ -0,0 +1 @@ +/build diff --git a/.github/workflows/smoke/Dockerfile b/.github/workflows/smoke/Dockerfile new file mode 100644 index 0000000..db9b34f --- /dev/null +++ b/.github/workflows/smoke/Dockerfile @@ -0,0 +1,5 @@ +FROM debian:buster + +ADD ./build / + +ENTRYPOINT ["/nebula"] diff --git a/.github/workflows/smoke/build.sh b/.github/workflows/smoke/build.sh new file mode 100755 index 0000000..71ca9de --- /dev/null +++ b/.github/workflows/smoke/build.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e -x + +rm -rf ./build +mkdir ./build + +( + cd build + + cp ../../../../nebula . + cp ../../../../nebula-cert . + cp ../*.yml . + + ./nebula-cert ca -name "Smoke Test" + ./nebula-cert sign -name "lighthouse1" -ip "192.168.100.1/24" + ./nebula-cert sign -name "host2" -ip "192.168.100.2/24" + ./nebula-cert sign -name "host3" -ip "192.168.100.3/24" +) + +docker build -t nebula:smoke . diff --git a/.github/workflows/smoke/host2.yml b/.github/workflows/smoke/host2.yml new file mode 100644 index 0000000..68708d2 --- /dev/null +++ b/.github/workflows/smoke/host2.yml @@ -0,0 +1,31 @@ +pki: + ca: /ca.crt + cert: /host2.crt + key: /host2.key + +static_host_map: + "192.168.100.1": ["172.17.0.2:4242"] + +lighthouse: + am_lighthouse: false + interval: 60 + hosts: + - "192.168.100.1" + +listen: + host: 0.0.0.0 + port: 4242 + +tun: + dev: nebula1 + +firewall: + outbound: + - port: any + proto: any + host: any + + inbound: + - port: any + proto: any + host: any diff --git a/.github/workflows/smoke/host3.yml b/.github/workflows/smoke/host3.yml new file mode 100644 index 0000000..66fb2cd --- /dev/null +++ b/.github/workflows/smoke/host3.yml @@ -0,0 +1,31 @@ +pki: + ca: /ca.crt + cert: /host3.crt + key: /host3.key + +static_host_map: + "192.168.100.1": ["172.17.0.2:4242"] + +lighthouse: + am_lighthouse: false + interval: 60 + hosts: + - "192.168.100.1" + +listen: + host: 0.0.0.0 + port: 4242 + +tun: + dev: nebula1 + +firewall: + outbound: + - port: any + proto: any + host: any + + inbound: + - port: any + proto: any + host: any diff --git a/.github/workflows/smoke/lighthouse1.yml b/.github/workflows/smoke/lighthouse1.yml new file mode 100644 index 0000000..2c5afd1 --- /dev/null +++ b/.github/workflows/smoke/lighthouse1.yml @@ -0,0 +1,25 @@ +pki: + ca: /ca.crt + cert: /lighthouse1.crt + key: /lighthouse1.key + +lighthouse: + am_lighthouse: true + +listen: + host: 0.0.0.0 + port: 4242 + +tun: + dev: nebula1 + +firewall: + outbound: + - port: any + proto: any + host: any + + inbound: + - port: any + proto: any + host: any diff --git a/.github/workflows/smoke/smoke.sh b/.github/workflows/smoke/smoke.sh new file mode 100755 index 0000000..591922c --- /dev/null +++ b/.github/workflows/smoke/smoke.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +set -e -x + +docker run --name lighthouse1 --device /dev/net/tun:/dev/net/tun --cap-add NET_ADMIN --rm nebula:smoke -config lighthouse1.yml & +sleep 1 +docker run --name host2 --device /dev/net/tun:/dev/net/tun --cap-add NET_ADMIN --rm nebula:smoke -config host2.yml & +sleep 1 +docker run --name host3 --device /dev/net/tun:/dev/net/tun --cap-add NET_ADMIN --rm nebula:smoke -config host3.yml & +sleep 1 + +set +x +echo +echo " *** Testing ping from lighthouse1" +echo +set -x +docker exec lighthouse1 ping -c1 192.168.100.2 +docker exec lighthouse1 ping -c1 192.168.100.3 + +set +x +echo +echo " *** Testing ping from host2" +echo +set -x +docker exec host2 ping -c1 192.168.100.1 +docker exec host2 ping -c1 192.168.100.3 + +set +x +echo +echo " *** Testing ping from host3" +echo +set -x +docker exec host3 ping -c1 192.168.100.1 +docker exec host3 ping -c1 192.168.100.2 From c321e40d24b7e66f451ad48ebc9cc834b11eeb45 Mon Sep 17 00:00:00 2001 From: Wade Simmons Date: Tue, 17 Dec 2019 08:38:59 -0500 Subject: [PATCH 2/2] generate the smoke config files --- .github/workflows/smoke/build.sh | 5 ++- .github/workflows/smoke/genconfig.sh | 60 +++++++++++++++++++++++++ .github/workflows/smoke/host2.yml | 31 ------------- .github/workflows/smoke/host3.yml | 31 ------------- .github/workflows/smoke/lighthouse1.yml | 25 ----------- 5 files changed, 64 insertions(+), 88 deletions(-) create mode 100755 .github/workflows/smoke/genconfig.sh delete mode 100644 .github/workflows/smoke/host2.yml delete mode 100644 .github/workflows/smoke/host3.yml delete mode 100644 .github/workflows/smoke/lighthouse1.yml diff --git a/.github/workflows/smoke/build.sh b/.github/workflows/smoke/build.sh index 71ca9de..2841b8d 100755 --- a/.github/workflows/smoke/build.sh +++ b/.github/workflows/smoke/build.sh @@ -10,7 +10,10 @@ mkdir ./build cp ../../../../nebula . cp ../../../../nebula-cert . - cp ../*.yml . + + HOST="lighthouse1" AM_LIGHTHOUSE=true ../genconfig.sh >lighthouse1.yml + HOST="host2" LIGHTHOUSES="192.168.100.1 172.17.0.2:4242" ../genconfig.sh >host2.yml + HOST="host3" LIGHTHOUSES="192.168.100.1 172.17.0.2:4242" ../genconfig.sh >host3.yml ./nebula-cert ca -name "Smoke Test" ./nebula-cert sign -name "lighthouse1" -ip "192.168.100.1/24" diff --git a/.github/workflows/smoke/genconfig.sh b/.github/workflows/smoke/genconfig.sh new file mode 100755 index 0000000..cc9a3f2 --- /dev/null +++ b/.github/workflows/smoke/genconfig.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +set -e + + +if [ "$STATIC_HOSTS" ] || [ "$LIGHTHOUSES" ] +then + echo "static_host_map:" + echo "$STATIC_HOSTS" | while read -r NEBULA_IP STATIC + do + [ -z "$NEBULA_IP" ] || echo " '$NEBULA_IP': ['$STATIC']" + done + echo "$LIGHTHOUSES" | while read -r NEBULA_IP STATIC + do + [ -z "$NEBULA_IP" ] || echo " '$NEBULA_IP': ['$STATIC']" + done + echo +fi + +lighthouse_hosts() { + if [ "$LIGHTHOUSES" ] + then + echo + echo "$LIGHTHOUSES" | while read -r NEBULA_IP STATIC + do + echo " - '$NEBULA_IP'" + done + else + echo "[]" + fi +} + +cat <