Skip to content

Commit

Permalink
Add test for primary port bindings to validator - See #2105
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-henry committed Aug 24, 2023
1 parent ffb63f3 commit 332b8b2
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions .github/workflows/validate-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ mkdir $TEST_DIR_PREFIX
# How long we will wait for ZT to come online before considering it a failure
MAX_WAIT_SECS=30

ZT_PORT_NODE_1=9996
ZT_PORT_NODE_2=9997

################################################################################
# Multi-node connectivity and performance test #
################################################################################
Expand Down Expand Up @@ -99,14 +102,19 @@ test() {
--xml=yes \
--xml-file=$FILENAME_MEMORY_LOG \
--leak-check=full \
./zerotier-one node1 -p9996 -U >>node_1.log 2>&1 &
./zerotier-one node1 -p$ZT_PORT_NODE_1 -U >>node_1.log 2>&1 &

# Second instance, not run in memory profiler
# Don't set up internet access until _after_ zerotier is running
# This has been a source of stuckness in the past.
$NS2 ip addr del 192.168.1.2/24 dev veth3
$NS2 sudo ./zerotier-one node2 -U -p9997 >>node_2.log 2>&1 &
sleep 1;
$NS2 sudo ./zerotier-one node2 -U -p$ZT_PORT_NODE_2 >>node_2.log 2>&1 &

sleep 5; # New HTTP control plane is a bit sluggish, so we delay here

check_bind_to_correct_ports $ZT_PORT_NODE_1
check_bind_to_correct_ports $ZT_PORT_NODE_2

$NS2 ip addr add 192.168.1.2/24 dev veth3
$NS2 ip route add default via 192.168.1.1

Expand Down Expand Up @@ -458,4 +466,30 @@ check_exit_on_invalid_identity() {
fi
}

################################################################################
# Check that we're binding to the primary port for TCP/TCP6/UDP #
################################################################################

check_bind_to_correct_ports() {
PORT_NUMBER=$1
if [[ $(sudo netstat -anp | grep "$PORT_NUMBER" | grep "zerotier" | grep "tcp") ]];
then
:
else
exit_test_and_generate_report $TEST_FAIL "ZeroTier did not bind to tcp/$1"
fi
if [[ $(sudo netstat -anp | grep "$PORT_NUMBER" | grep "zerotier" | grep "tcp6") ]];
then
:
else
exit_test_and_generate_report $TEST_FAIL "ZeroTier did not bind to tcp6/$1"
fi
if [[ $(sudo netstat -anp | grep "$PORT_NUMBER" | grep "zerotier" | grep "udp") ]];
then
:
else
exit_test_and_generate_report $TEST_FAIL "ZeroTier did not bind to udp/$1"
fi
}

test "$@"

0 comments on commit 332b8b2

Please sign in to comment.