From 768631fbf5fe2f79b80e45fd4cc921083b16800b Mon Sep 17 00:00:00 2001 From: mozillazg Date: Sat, 27 Apr 2024 20:38:37 +0800 Subject: [PATCH] ci: add e2e test --- .github/workflows/test.yml | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f12148e..24a5d32a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,75 @@ jobs: - name: Test run: make test + - name: Store executable + uses: actions/upload-artifact@v4 + with: + name: ptcpdump + path: ptcpdump + + + e2e-test: + runs-on: ubuntu-latest + name: e2e-test + needs: build + strategy: + fail-fast: false + matrix: + kernel: [ '5.10-v0.3', '5.15-v0.3', '6.3-main', 'bpf-next-20231030.012704' ] + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + + - name: Retrieve stored ptcpdump executable + uses: actions/download-artifact@v4 + with: + name: ptcpdump + path: ptcpdump + + - name: Provision LVH VMs + uses: cilium/little-vm-helper@v0.0.12 + with: + test-name: ptcpdump-test + image-version: ${{ matrix.kernel }} + host-mount: ./ + install-dependencies: 'true' + cmd: | + chmod +x /host/ptcpdump/ptcpdump + + - name: Test base + uses: cilium/little-vm-helper@v0.0.12 + with: + provision: 'false' + cmd: | + set -ex + + timeout 20s /host/ptcpdump/ptcpdump -c 1 -i any --print -w ptcpdump.pcapng 'dst host 1.1.1.1 and tcp[tcpflags] = tcp-syn' 2>&1 1>/tmp/log | (read _; curl 1.1.1.1 &>/dev/null || true) + + cat /tmp/log + cat /tmp/log | grep '/usr/bin/curl' + cat /tmp/log | grep -P ' > 1.1.1.1.80' + + apt update && apt install -y tcpdump + tcpdump -nr ./ptcpdump.pcapnp + tcpdump -nr ./ptcpdump.pcapnp | grep -F ' > 1.1.1.1.80' + + - name: Test filter by process + uses: cilium/little-vm-helper@v0.0.12 + with: + provision: 'false' + cmd: | + set -ex + + timeout 20s /host/ptcpdump/ptcpdump -c 1 --pname curl --pid "$$" -f -i any --print -w ptcpdump.pcapng 2>&1 1>/tmp/log | (read _; curl 1.1.1.1 &>/dev/null || true) + + cat /tmp/log + cat /tmp/log | grep '/usr/bin/curl' + cat /tmp/log | grep -P ' > 1.1.1.1.80' + + apt update && apt install -y tcpdump + tcpdump -nr ./ptcpdump.pcapnp + tcpdump -nr ./ptcpdump.pcapnp | grep -F ' > 1.1.1.1.80' + releaser-test: runs-on: ubuntu-latest