Skip to content

Commit

Permalink
feat: introduce test_filter_by_comm.sh
Browse files Browse the repository at this point in the history
Signed-off-by: spencercjh <[email protected]>
  • Loading branch information
spencercjh committed Dec 27, 2024
1 parent 2bfdc88 commit c5e874d
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 43 deletions.
100 changes: 57 additions & 43 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,40 @@ jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: recursive

- name: Set up Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5
with:
go-version: '1.22.4'

- name: Build
run: |
sudo apt update
sudo apt install -y git
sudo apt-get -y install pkg-config
sudo apt install -y libelf-dev
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
sudo apt update
sudo apt install -y llvm
sudo apt install -y clang
pwd
ls -l
make clean && make build-bpf && make
# - name: Test
# run: make test

- name: Store executable
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
with:
name: kyanos
path: kyanos
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: recursive

- name: Set up Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5
with:
go-version: '1.22.4'

- name: Build
run: |
sudo apt update
sudo apt install -y git
sudo apt-get -y install pkg-config
sudo apt install -y libelf-dev
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"
sudo apt update
sudo apt install -y llvm
sudo apt install -y clang
pwd
ls -l
make clean && make build-bpf && make
# - name: Test
# run: make test

- name: Store executable
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
with:
name: kyanos
path: kyanos


e2e-test:
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
install-dependencies: 'true'
cmd: |
chmod +x /host/kyanos/kyanos
- name: download btf file
if: ${{ startsWith(matrix.kernel, '4.') }}
run: |
Expand All @@ -113,7 +113,7 @@ jobs:
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@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
Expand All @@ -125,7 +125,7 @@ jobs:
cat /etc/os-release
sudo mkdir -p /var/lib/kyanos/btf/
sudo cp /host/data/kernels/4.*/boot/btf-4.* /var/lib/kyanos/btf/current.btf
# btf_file=$(find /host/ -path "*btf*" -type f)
# sudo cp $btf_file /var/lib/ptcpdump/btf/vmlinux
Expand Down Expand Up @@ -155,8 +155,22 @@ jobs:
#install python pip
sudo apt install -y python3 python3-pip pipx

- name: Test filter by comm
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
provision: 'false'
cmd: |
set -ex
uname -a
cat /etc/issue
pushd /host
if [ -f "/var/lib/kyanos/btf/current.btf" ]; then
bash /host/testdata/test_filter_by_comm.sh '/host/kyanos/kyanos $kyanos_log_option --btf /var/lib/kyanos/btf/current.btf'
else
bash /host/testdata/test_filter_by_comm.sh '/host/kyanos/kyanos $kyanos_log_option'
fi
popd
- name: Test gotls
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
Expand All @@ -172,7 +186,7 @@ jobs:
bash /host/testdata/test_gotls.sh '/host/kyanos/kyanos $kyanos_log_option'
fi
popd
- name: Test https
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
Expand All @@ -188,7 +202,7 @@ jobs:
bash /host/testdata/test_https.sh '/host/kyanos/kyanos $kyanos_log_option'
fi
popd
- name: Test side
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
Expand Down Expand Up @@ -263,7 +277,7 @@ jobs:
else
bash /host/testdata/test_kern_evt.sh '/host/kyanos/kyanos $kyanos_log_option'
fi
- name: Test test docker filter by container id
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
Expand Down Expand Up @@ -347,7 +361,7 @@ jobs:
else
bash /host/testdata/test_redis.sh '/host/kyanos/kyanos $kyanos_log_option'
fi
- name: Test k8s
if: ${{ startsWith(matrix.kernel, '6.') }}
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
Expand Down
40 changes: 40 additions & 0 deletions testdata/test_filter_by_comm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
. $(dirname "$0")/common.sh
set -ex

CMD="$1"
FILE_PREFIX="/tmp/kyanos"
BEFORE_LNAME="${FILE_PREFIX}_filter_by_comm_before.log"
AFTER_LNAME="${FILE_PREFIX}_filter_by_comm_after.log"

function test_filter_by_comm() {
openssl req -x509 -newkey rsa:2048 -keyout server.pem -out server.pem -days 365 -nodes -subj "/C=US/ST=California/L=San Francisco/O=My Company/CN=localhost"

pip install --break-system-packages ssl || true

# server start before kyanos
timeout 40 python3 ./testdata/start_https_server.py &
timeout 30 ${CMD} watch --debug-output http --comm python3 2>&1 | tee "${BEFORE_LNAME}" &
sleep 10
curl --insecure https://127.0.0.1:4443 &>/dev/null || true
wait

cat "${BEFORE_LNAME}"
cat "${BEFORE_LNAME}" | grep "127.0.0.1:4443"

# server start after kyanos
timeout 40 ${CMD} watch --debug-output http --comm python3 2>&1 | tee "${AFTER_LNAME}" &
sleep 10
timeout 30 python3 ./testdata/start_https_server.py &
curl --insecure https://127.0.0.1:4443 &>/dev/null || true
wait

cat "${AFTER_LNAME}"
cat "${AFTER_LNAME}" | grep "127.0.0.1:4443"
}

function main() {
test_filter_by_comm
}

main

0 comments on commit c5e874d

Please sign in to comment.