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 760ffad
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,22 @@ jobs:
bash /host/testdata/test_docker_filter_by_pid.sh '/host/kyanos/kyanos $kyanos_log_option'
fi
- 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 test containerd filter by container name
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
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}" &
curl --insecure https://127.0.0.1:4443 &>/dev/null || true
sleep 5
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}" &
timeout 30 python3 ./testdata/start_https_server.py &
curl --insecure https://127.0.0.1:4443 &>/dev/null || true
sleep 5
wait

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

function main() {
test_filter_by_comm
}

main

0 comments on commit 760ffad

Please sign in to comment.