-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
495 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,4 @@ testhosts | |
**/debian-binary | ||
packaging/dist | ||
itest/dist | ||
itest/config.yml | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
_net_filters: &net_filters | ||
- subnet_name: 0_0_0_0__2 | ||
network: 0.0.0.0 | ||
network_mask: 192.0.0.0 | ||
description: "Non-loopback subnet section" | ||
- subnet_name: 64_0_0_0__3 | ||
network: 64.0.0.0 | ||
network_mask: 224.0.0.0 | ||
description: "Non-loopback subnet section" | ||
- subnet_name: 96_0_0_0__4 | ||
network: 96.0.0.0 | ||
network_mask: 240.0.0.0 | ||
description: "Non-loopback subnet section" | ||
- subnet_name: 112_0_0_0__5 | ||
network: 112.0.0.0 | ||
network_mask: 248.0.0.0 | ||
description: "Non-loopback subnet section" | ||
- subnet_name: 120_0_0_0__6 | ||
network: 120.0.0.0 | ||
network_mask: 252.0.0.0 | ||
description: "Non-loopback subnet section" | ||
- subnet_name: 124_0_0_0__7 | ||
network: 124.0.0.0 | ||
network_mask: 254.0.0.0 | ||
description: "Non-loopback subnet section" | ||
- subnet_name: 126_0_0_0__8 | ||
network: 126.0.0.0 | ||
network_mask: 255.0.0.0 | ||
description: "Non-loopback subnet section" | ||
- subnet_name: 128_0_0_0__1 | ||
network: 128.0.0.0 | ||
network_mask: 128.0.0.0 | ||
description: "Non-loopback subnet section" | ||
- subnet_name: 127_0_0_0__16 | ||
network: 127.0.0.0 | ||
network_mask: 255.255.0.0 | ||
description: "127.0/16 to get rid of the noise" | ||
- subnet_name: testcase | ||
network: <net_address> | ||
network_mask: 255.255.255.255 | ||
description: "filter for autoreload testcase" | ||
|
||
tcp_connect: | ||
filters: *net_filters |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
|
||
export TOPLEVEL=$(git rev-parse --show-toplevel) | ||
export CONTAINER_NAME=pidtree-autoreload-itest-$$ | ||
export OUTPUT_NAME=itest/tmp/itest-autoreload-$$ | ||
export DADDR='127.1.33.7' | ||
|
||
mkdir -p $TOPLEVEL/itest/tmp/autoreload | ||
|
||
function cleanup { | ||
set +e | ||
docker kill $CONTAINER_NAME | ||
rm -f $TOPLEVEL/$OUTPUT_NAME | ||
} | ||
|
||
function create_connect_event { | ||
echo "Creating connection event" | ||
nc -w 2 -l -p 41337 -s $1 & | ||
listener_pid=$! | ||
sleep 1 | ||
nc -w 1 $1 41337 | ||
wait $listener_pid | ||
echo "Connection event completed" | ||
} | ||
|
||
function test_output { | ||
echo "Waiting for pidtree-bcc output, looking for $DADDR" | ||
create_connect_event $DADDR & | ||
connect_pid=$! | ||
tail -n0 -f $OUTPUT_NAME | while read line; do | ||
if echo "$line" | grep "$DADDR"; then | ||
echo "Caught test traffic" | ||
pkill -x --parent $$ tail | ||
break | ||
fi | ||
done | ||
wait $connect_pid | ||
exit 0 | ||
} | ||
|
||
function write_config { | ||
sed "s/<net_address>/$1/g" $TOPLEVEL/itest/config_autoreload.yml > $TOPLEVEL/itest/tmp/autoreload/config.yml | ||
} | ||
|
||
trap cleanup INT EXIT | ||
|
||
touch $TOPLEVEL/$OUTPUT_NAME | ||
|
||
if [ -f /etc/lsb-release ]; then | ||
source /etc/lsb-release | ||
else | ||
echo "WARNING: Could not source /etc/lsb-release, tentatively creating bionic docker image" | ||
DISTRIB_CODENAME=bionic | ||
fi | ||
docker build -t pidtree-itest-base --build-arg OS_RELEASE=$DISTRIB_CODENAME . | ||
docker build -t pidtree-itest itest | ||
|
||
echo "Creating background pidtree-bcc container to catch traffic" | ||
write_config $DADDR | ||
docker run --name $CONTAINER_NAME --rm -d \ | ||
--rm --privileged --cap-add sys_admin --pid host \ | ||
-v $TOPLEVEL/itest/tmp/autoreload:/work/config \ | ||
-v $TOPLEVEL/$OUTPUT_NAME:/work/output \ | ||
pidtree-itest -c /work/config/config.yml -f /work/output -w --health-check-period 1 | ||
|
||
echo "Waiting a bit to let pidtree bootstrap" | ||
sleep 15 | ||
|
||
export -f test_output | ||
export -f create_connect_event | ||
|
||
timeout 10s bash -c test_output | ||
if [ $? -eq 0 ]; then | ||
echo "ERRROR: first connection even should have been filtered" | ||
exit 1 | ||
fi | ||
|
||
echo "Changing configuration values and waiting for hot-swap" | ||
write_config 1.1.1.1 | ||
sleep 5 | ||
|
||
timeout 20s bash -c test_output | ||
if [ $? -eq 0 ]; then | ||
echo "SUCCESS!" | ||
exit 0 | ||
else | ||
echo "FAILED! (timeout)" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.