Skip to content

Test

Test #683

Workflow file for this run

name: Test
on:
workflow_dispatch:
push:
branches: [ "master", "dev" ]
pull_request:
branches: [ "master", "dev" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
with:
go-version: '1.23'
- name: Build
run: make build-via-docker
- name: Test
run: make test
- name: Store executable
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: ptcpdump
path: ptcpdump
run-with-docker:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: test running with docker
run: |
bash testdata/test_run_with_docker.sh "quay.io/ptcpdump/ptcpdump:latest"
e2e-test:
name: e2e-test
needs: build
strategy:
fail-fast: false
matrix:
backend:
- 'tc'
- 'cgroup-skb'
kernel:
# renovate: datasource=docker depName=quay.io/lvh-images/kernel-images
- '4.19-20241031.113911'
# renovate: datasource=docker depName=quay.io/lvh-images/kernel-images
- '5.4-20241031.113911'
# renovate: datasource=docker depName=quay.io/lvh-images/kernel-images
- '5.10-20241031.113911'
# renovate: datasource=docker depName=quay.io/lvh-images/kernel-images
- '5.15-20241031.113911'
# renovate: datasource=docker depName=quay.io/lvh-images/kernel-images
- '6.1-20241031.113911'
# renovate: datasource=docker depName=quay.io/lvh-images/kernel-images
- '6.6-20241031.113911'
# renovate: datasource=docker depName=quay.io/lvh-images/kernel-images
- '6.12-20250116.014736'
# renovate: datasource=docker depName=quay.io/lvh-images/kernel-images
- 'bpf-20241101.013334'
# renovate: datasource=docker depName=quay.io/lvh-images/kernel-images
- 'bpf-next-20241101.013334'
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: |
if [ "${{ matrix.backend }}" = "tc" ]; then
PTCPDUMP_EXTRA_ARGS=''
else
PTCPDUMP_EXTRA_ARGS='--backend cgroup-skb'
fi
echo "PTCPDUMP_EXTRA_ARGS=${PTCPDUMP_EXTRA_ARGS}" >> $GITHUB_ENV
- name: Retrieve stored ptcpdump executable
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: ptcpdump
path: ptcpdump
- name: Provision LVH VMs
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
test-name: ptcpdump-test
image-version: ${{ matrix.kernel }}
cpu: 2
mem: '4G'
host-mount: ./
install-dependencies: 'true'
cmd: |
chmod +x /host/ptcpdump/ptcpdump
- name: download btf file
if: ${{ startsWith(matrix.kernel, '4.') }}
run: |
img=quay.io/lvh-images/kernel-images:${{ matrix.kernel }}
docker pull $img
id=$(docker create $img)
mkdir data/
docker cp $id:/data/kernels data/
ls -la data/
find data/ -path "*vmlinuz*" -type f
find data/ -path "*btf*" -type f
- name: copy btf file
if: ${{ startsWith(matrix.kernel, '4.') }}
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
uname -a
cat /etc/issue
cat /etc/os-release
sudo mkdir -p /var/lib/ptcpdump/btf/
sudo cp /host/data/kernels/4.*/boot/btf-4.* /var/lib/ptcpdump/btf/vmlinux
# btf_file=$(find /host/ -path "*btf*" -type f)
# sudo cp $btf_file /var/lib/ptcpdump/btf/vmlinux
- name: Test default (ping)
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
if: ${{ !startsWith(matrix.backend, 'cgroup-skb') }}
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_default.sh /host/ptcpdump/ptcpdump
- name: Test base (curl)
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
if: ${{ ( !( (startsWith(matrix.backend, 'cgroup-skb') && (startsWith(matrix.kernel, '5.4') || startsWith(matrix.kernel, '4.')) ) ) ) }

Check failure on line 150 in .github/workflows/test.yml

View workflow run for this annotation

GitHub Actions / Test

Invalid workflow file

The workflow is not valid. .github/workflows/test.yml (Line: 150, Col: 13): The expression is not closed. An unescaped ${{ sequence was found, but the closing }} sequence was not found. .github/workflows/test.yml (Line: 161, Col: 13): The expression is not closed. An unescaped ${{ sequence was found, but the closing }} sequence was not found.
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_base.sh /host/ptcpdump/ptcpdump
- name: Test parent info
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
if: ${{ ( !( (startsWith(matrix.backend, 'cgroup-skb') && (startsWith(matrix.kernel, '5.4') || startsWith(matrix.kernel, '4.')) ) ) ) }
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_parent_info.sh /host/ptcpdump/ptcpdump
- name: Test filter by process name
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
if: ${{ ( !( (startsWith(matrix.backend, 'cgroup-skb') && (startsWith(matrix.kernel, '5.4') || startsWith(matrix.kernel, '4.')) ) ) ) }
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_pname_filter.sh /host/ptcpdump/ptcpdump
- name: Test filter by process id
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
if: ${{ ( !( (startsWith(matrix.backend, 'cgroup-skb') && (startsWith(matrix.kernel, '5.4') || startsWith(matrix.kernel, '4.')) ) ) ) }
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_pid_filter.sh /host/ptcpdump/ptcpdump
- name: Test read pcap file
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_read_pcap.sh /host/ptcpdump/ptcpdump
- name: Test write pcap file
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_write_pcap.sh /host/ptcpdump/ptcpdump
- name: Test write to stdout
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_write_stdout.sh /host/ptcpdump/ptcpdump
- name: Test exist connections
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_exist_connection.sh /host/ptcpdump/ptcpdump
- name: Test arp and icmp
if: ${{ (!startsWith(matrix.kernel, '5.4')) && (!startsWith(matrix.kernel, '4.')) && (!startsWith(matrix.backend, 'cgroup-skb')) }}
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_arp.sh /host/ptcpdump/ptcpdump
bash /host/testdata/test_icmp.sh /host/ptcpdump/ptcpdump
- name: Test netns
if: ${{ !startsWith(matrix.backend, 'cgroup-skb') }}
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_netns.sh /host/ptcpdump/ptcpdump
- name: Test netns newly
if: ${{ !startsWith(matrix.backend, 'cgroup-skb') }}
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_netns_newly_normal.sh /host/ptcpdump/ptcpdump
bash /host/testdata/test_netns_newly_exec.sh /host/ptcpdump/ptcpdump
- name: Test run sub program
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
bash /host/testdata/test_sub_program.sh /host/ptcpdump/ptcpdump
bash /host/testdata/test_sub_curl_domain_program.sh /host/ptcpdump/ptcpdump
- name: Test NAT
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
if: ${{ !startsWith(matrix.backend, 'cgroup-skb') }}
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
for i in {1..10}; do
bash /host/testdata/test_nat.sh /host/ptcpdump/ptcpdump && exit 0 || sleep 1
done
exit 1
- name: build demo app
if: ${{ (!startsWith(matrix.kernel, '5.4')) && (!startsWith(matrix.kernel, '4.')) }}
run: |
make -C testdata/gohttpapp build
- name: Test go tls keylog (unstripped)
if: ${{ (!startsWith(matrix.kernel, '5.4')) && (!startsWith(matrix.kernel, '4.')) }}
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
ls -lh /host/testdata/gohttpapp
apt update && yes | apt install -y tshark
for i in {1..10}; do
bash /host/testdata/test_gotls_keylog.sh /host/ptcpdump/ptcpdump gohttpapp && exit 0 || sleep 1
done
exit 1
- name: Test go tls keylog (PIE)
if: ${{ (!startsWith(matrix.kernel, '5.4')) && (!startsWith(matrix.kernel, '4.')) }}
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
ls -lh /host/testdata/gohttpapp
apt update && yes | apt install -y tshark
for i in {1..10}; do
bash /host/testdata/test_gotls_keylog.sh /host/ptcpdump/ptcpdump gohttpapp_pie && exit 0 || sleep 1
done
exit 1
- name: Test go tls keylog (stripped)
if: ${{ (!startsWith(matrix.kernel, '5.4')) && (!startsWith(matrix.kernel, '4.')) }}
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
ls -lh /host/testdata/gohttpapp
apt update && yes | apt install -y tshark
for i in {1..10}; do
bash /host/testdata/test_gotls_keylog.sh /host/ptcpdump/ptcpdump gohttpapp_stripped && exit 0 || sleep 1
done
exit 1
- name: Test go tls keylog (stripped + PIE)
if: ${{ (!startsWith(matrix.kernel, '5.4')) && (!startsWith(matrix.kernel, '4.')) }}
uses: cilium/little-vm-helper@e87948476ca97050b1f149ab2aec379d0de19b84 # v0.0.23
with:
provision: 'false'
cmd: |
set -ex
export PTCPDUMP_EXTRA_ARGS="${{ env.PTCPDUMP_EXTRA_ARGS }}"
ls -lh /host/testdata/gohttpapp
apt update && yes | apt install -y tshark
for i in {1..10}; do
bash /host/testdata/test_gotls_keylog.sh /host/ptcpdump/ptcpdump gohttpapp_stripped_pie && exit 0 || sleep 1
done
exit 1