aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEnrico Loparco (eloparco) <eloparco@cisco.com>2022-09-14 08:58:55 +0000
committerEnrico Loparco (eloparco) <eloparco@cisco.com>2022-09-14 13:42:31 +0000
commitab38321508d886f0acd535f0f5f07a3d44e29591 (patch)
treea46dedcd2dce871cf8c381fd06e3c00c46cd3b27 /tests
parent6c9f120f028bcca93fd087afa648f653b208eb35 (diff)
feat(hicn-ping): allow usage of random prefixes/suffixes in hicn-ping
Ref: HICN-783 Signed-off-by: Enrico Loparco (eloparco) <eloparco@cisco.com> Change-Id: I41c804dd639ee15aee9619732f55e39a3baf1385
Diffstat (limited to 'tests')
-rw-r--r--tests/1-node.yml1
-rw-r--r--tests/Makefile13
-rwxr-xr-xtests/config.sh95
-rw-r--r--tests/functional-tests/hicn-light-ping.robot26
4 files changed, 131 insertions, 4 deletions
diff --git a/tests/1-node.yml b/tests/1-node.yml
index eb8c19f34..859d1b838 100644
--- a/tests/1-node.yml
+++ b/tests/1-node.yml
@@ -16,7 +16,6 @@ services:
command:
- |
if [ -d /workspace/build-dev ]; then
- git config --global --add safe.directory \*
sudo ninja -C /workspace/build-dev install
fi
diff --git a/tests/Makefile b/tests/Makefile
index f9c166b8d..a31a6f1a6 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,4 +1,4 @@
-# Use when building for the fist time,
+# Use when building for the first time,
# then `make test` forces a rebuild if local changes
build:
DOCKERFILE=Dockerfile.dev BUILD_SOFTWARE=1 \
@@ -28,8 +28,15 @@ shell:
down:
docker-compose -f 1-node.yml down
-functional:
+functional-ctrl:
sleep 1 # Wait for the forwarder to be ready
bash config.sh ctrl listeners
bash config.sh ctrl connections
- bash config.sh ctrl routes \ No newline at end of file
+ bash config.sh ctrl routes
+
+functional-ping-manifest:
+ bash config.sh ping manifest
+functional-ping-signature:
+ bash config.sh ping signature
+functional-ping-timeout:
+ bash config.sh ping timeout \ No newline at end of file
diff --git a/tests/config.sh b/tests/config.sh
index a6bc6ad2d..16000bff6 100755
--- a/tests/config.sh
+++ b/tests/config.sh
@@ -465,6 +465,97 @@ function ctrl() {
${ctrl_tests[${type}]}
}
+################################################################
+# Test ping
+################################################################
+function test_ping_manifest() {
+ docker exec forwarder bash -c 'hicn-ping-server -a intmanifest >/tmp/ping_server.log 2>&1 &'
+ sleep 1
+
+ # 2 interests w/ 3 suffixes each (1 in header + 2 in manifest)
+ docker exec forwarder bash -c 'hicn-ping-client -m 6 -a 2 intmanifest | grep "Sent" >>/tmp/ping_client.log'
+ sleep 1
+
+ # 2 interests w/ 3 suffixes each + 1 single interest
+ docker exec forwarder bash -c 'hicn-ping-client -m 7 -a 2 intmanifest | grep "Sent" >>/tmp/ping_client.log'
+ sleep 1
+
+ # 2 interests w/ 3 suffixes each + 1 interest w/ 2 suffixes
+ docker exec forwarder bash -c 'hicn-ping-client -m 8 -a 2 intmanifest | grep "Sent" >>/tmp/ping_client.log'
+ sleep 1
+
+ # 2 interests w/ 3 suffixes each + 1 single interest,
+ # using random prefix/suffix generation
+ docker exec forwarder bash -c 'hicn-ping-client -m 7 -a 2 intmanifest -b RANDOM | grep "Sent" >>/tmp/ping_client.log'
+
+ # No 'failed' expected
+ ping_server_logs=$(docker exec forwarder cat /tmp/ping_server.log)
+ if [[ $(echo $ping_server_logs | grep failed | wc -l) -ne 0 ]]; then
+ echo "******** Server logs (ping) ********"
+ echo "$ping_server_logs"
+ exit 1
+ fi
+
+ # No 'Timeouts: 0' expected
+ ping_client_logs=$(docker exec forwarder cat /tmp/ping_client.log)
+ if [[ $(echo $ping_client_logs | grep -v "Timeouts: 0" | wc -l) -ne 0 ]]; then
+ echo "******** Client logs (ping) ********"
+ echo "$ping_client_logs"
+ exit 1
+ fi
+}
+
+function test_ping_wrong_signature() {
+ docker exec forwarder bash -c 'hicn-ping-server -a intmanifest >/tmp/ping_server.log 2>&1 &'
+ sleep 1
+
+ # Signature mismatch ('intmamifest' on server vs 'wrong_sign' on client)
+ docker exec forwarder bash -c 'hicn-ping-client -m 6 -a 2 wrong_sig | grep "Sent" >>/tmp/ping_client.log'
+
+ # 'failed' expected
+ ping_server_logs=$(docker exec forwarder cat /tmp/ping_server.log)
+ if [[ $(echo $ping_server_logs | grep "failed" | wc -l) -eq 0 ]]; then
+ echo "******** Server logs (signature fail) ********"
+ echo "$ping_server_logs"
+ exit 1
+ fi
+}
+
+function test_ping_no_server() {
+ # Server not started to check for ping client timeout
+ docker exec forwarder bash -c 'hicn-ping-client -m 6 | grep "Sent" >>/tmp/ping_client.log'
+
+ # 'Timeouts: 6' expected
+ ping_client_logs=$(docker exec forwarder cat /tmp/ping_client.log)
+ if [[ $(echo $ping_client_logs | grep "Timeouts: 6" | wc -l) -eq 0 ]]; then
+ echo "******** Client logs (timeout) ********"
+ echo "$ping_client_logs"
+ exit 1
+ fi
+}
+
+declare -A ping_tests=(
+ ["manifest"]="test_ping_manifest"
+ ["signature"]="test_ping_wrong_signature"
+ ["timeout"]="test_ping_no_server"
+)
+
+function ping_test_exists() {
+ [[ "${!ping_tests[*]}" =~ ${1} ]] && return 0 || return 1
+}
+
+function ping() {
+ type=$1
+ if ! ping_test_exists "${type}"; then
+ error "Error: hicn-ping test does not exist."
+ exit 1
+ fi
+
+ ${ping_tests[${type}]}
+}
+
+#--------------------------------------------------------------#
+
while (("${#}")); do
case "$1" in
'build')
@@ -510,6 +601,10 @@ while (("${#}")); do
ctrl "${2}"
break
;;
+ 'ping')
+ ping "${2}"
+ break
+ ;;
*)
exit 1
;;
diff --git a/tests/functional-tests/hicn-light-ping.robot b/tests/functional-tests/hicn-light-ping.robot
new file mode 100644
index 000000000..238f49e0e
--- /dev/null
+++ b/tests/functional-tests/hicn-light-ping.robot
@@ -0,0 +1,26 @@
+*** Settings ***
+Resource resources/libraries/robot/common.robot
+Test Setup Run Keywords
+... Build Topology 1-node AND
+... Check Environment
+Test Teardown Run Keywords
+... Destroy Topology
+
+*** Test Cases ***
+Ping with manifest
+ Log to console Test ping with manifest
+ ${result} = Run Process ${EXECDIR}/config.sh ping manifest
+ Log Many stdout: ${result.stdout}
+ Should Be Equal As Integers ${result.rc} 0
+
+Ping wrong signature
+ Log to console Test ping with wrong signature
+ ${result} = Run Process ${EXECDIR}/config.sh ping signature
+ Log Many stdout: ${result.stdout}
+ Should Be Equal As Integers ${result.rc} 0
+
+Ping timeout
+ Log to console Test ping timeout
+ ${result} = Run Process ${EXECDIR}/config.sh ping timeout
+ Log Many stdout: ${result.stdout}
+ Should Be Equal As Integers ${result.rc} 0