aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.env2
-rw-r--r--tests/2-nodes-hicn-light.yml6
-rw-r--r--tests/2-nodes-vpp-bridge.yml6
-rw-r--r--tests/2-nodes-vpp-memif-replication.yml6
-rw-r--r--tests/2-nodes-vpp-memif.yml6
-rw-r--r--tests/Makefile6
-rwxr-xr-xtests/config.sh4
-rw-r--r--tests/forwarder.robot45
-rw-r--r--tests/hiperf-local.sh21
-rw-r--r--tests/test_forwarder.sh437
10 files changed, 39 insertions, 500 deletions
diff --git a/tests/.env b/tests/.env
index 1d40e4dea..f36c66785 100644
--- a/tests/.env
+++ b/tests/.env
@@ -9,6 +9,6 @@ TEST_VPP_MEMIF=vpp-memif
TEST_VPP_MEMIF_REPLICATION=vpp-memif-replication
# names
-RTC_PRODUCER=b002::1
+RTC_PRODUCER=b002:0:0:0:abcd::/80
RAAQM_PRODUCER=b002::2
PING_PRODUCER=b002::3
diff --git a/tests/2-nodes-hicn-light.yml b/tests/2-nodes-hicn-light.yml
index 318a5ccbd..0aee8cf5e 100644
--- a/tests/2-nodes-hicn-light.yml
+++ b/tests/2-nodes-hicn-light.yml
@@ -58,8 +58,8 @@ services:
sleep 4
- hiperf -z hicnlightng_module -D -S -R -B 4000kbps ${RTC_PRODUCER}/128
- hiperf -z hicnlightng_module -D -S ${RAAQM_PRODUCER}/128
- hicn-ping-server -z hicnlightng_module -d -s 0 -n ${PING_PRODUCER}/128
+ hiperf -q -z hicnlightng_module -S -R -B 4000kbps ${RTC_PRODUCER} -P 2 &
+ hiperf -q -z hicnlightng_module -S ${RAAQM_PRODUCER}/128 &
+ hicn-ping-server -q -z hicnlightng_module -s 0 -n ${PING_PRODUCER}/128 &
tail -f /dev/null
diff --git a/tests/2-nodes-vpp-bridge.yml b/tests/2-nodes-vpp-bridge.yml
index d9426844f..db1fa6fdc 100644
--- a/tests/2-nodes-vpp-bridge.yml
+++ b/tests/2-nodes-vpp-bridge.yml
@@ -98,10 +98,10 @@ services:
sudo vpp -c /etc/vpp/startup.conf
sleep 5
- sudo hiperf -D -S -R -B 4000kbps -z memif_module ${RTC_PRODUCER}/128
+ sudo hiperf -q -S -R -B 4000kbps -z memif_module ${RTC_PRODUCER} -P 2 &
sleep 1
- sudo hiperf -D -S -z memif_module ${RAAQM_PRODUCER}/128
+ sudo hiperf -q -S -z memif_module ${RAAQM_PRODUCER}/128 &
sleep 1
- sudo hicn-ping-server -d -s 0 -n ${PING_PRODUCER}/128 -z memif_module
+ sudo hicn-ping-server -q -s 0 -n ${PING_PRODUCER}/128 -z memif_module &
tail -f /dev/null
diff --git a/tests/2-nodes-vpp-memif-replication.yml b/tests/2-nodes-vpp-memif-replication.yml
index 37f028dac..45de82400 100644
--- a/tests/2-nodes-vpp-memif-replication.yml
+++ b/tests/2-nodes-vpp-memif-replication.yml
@@ -134,10 +134,10 @@ services:
sudo vpp -c /etc/vpp/startup.conf
sleep 10
- sudo hiperf -D -S -R -B 4000kbps -z memif_module ${RTC_PRODUCER}/128
+ sudo hiperf -q -S -R -B 4000kbps -z memif_module ${RTC_PRODUCER} -P 2 &
sleep 5
- sudo hiperf -D -S -z memif_module ${RAAQM_PRODUCER}/128
+ sudo hiperf -q -S -z memif_module ${RAAQM_PRODUCER}/128 &
sleep 5
- sudo hicn-ping-server -d -s 0 -n ${PING_PRODUCER}/128 -z memif_module
+ sudo hicn-ping-server -q -s 0 -n ${PING_PRODUCER}/128 -z memif_module &
tail -f /dev/null
diff --git a/tests/2-nodes-vpp-memif.yml b/tests/2-nodes-vpp-memif.yml
index 034437dbc..48b4a1c1d 100644
--- a/tests/2-nodes-vpp-memif.yml
+++ b/tests/2-nodes-vpp-memif.yml
@@ -107,10 +107,10 @@ services:
sudo vpp -c /etc/vpp/startup.conf
sleep 10
- sudo hiperf -D -S -R -B 4000kbps -z memif_module ${RTC_PRODUCER}/128
+ sudo hiperf -q -S -R -B 4000kbps -z memif_module ${RTC_PRODUCER} -P 2 &
sleep 5
- sudo hiperf -D -S -z memif_module ${RAAQM_PRODUCER}/128
+ sudo hiperf -q -S -z memif_module ${RAAQM_PRODUCER}/128 &
sleep 5
- sudo hicn-ping-server -d -s 0 -n ${PING_PRODUCER}/128 -z memif_module
+ sudo hicn-ping-server -q -s 0 -n ${PING_PRODUCER}/128 -z memif_module &
tail -f /dev/null
diff --git a/tests/Makefile b/tests/Makefile
index 6e85a717e..0f30d6a42 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -30,6 +30,6 @@ down:
functional:
sleep 1 # Wait for the forwarder to be ready
- bash config.sh test_listeners
- bash config.sh test_connections
- bash config.sh test_routes \ No newline at end of file
+ bash config.sh ctrl listeners
+ bash config.sh ctrl connections
+ bash config.sh ctrl routes \ No newline at end of file
diff --git a/tests/config.sh b/tests/config.sh
index d504b1c97..654bad518 100755
--- a/tests/config.sh
+++ b/tests/config.sh
@@ -16,7 +16,7 @@ BASE_IMAGE=${BASE_IMAGE:-hicn}
BUILD_SOFTWARE=${BUILD_SOFTWARE:-1}
set +a
-HIPERF_CMD_RTC="hiperf -n 50 -C -H -R ${RTC_PRODUCER}"
+HIPERF_CMD_RTC="hiperf -q -n 50 -C -H -R ${RTC_PRODUCER} -P 2"
HIPERF_CMD_MEMIF_RTC="${HIPERF_CMD_RTC} -z memif_module"
POSTPROCESS_COMMAND_RAAQM_RTC='tail -n +3 | \
tr -s " " | \
@@ -34,7 +34,7 @@ POSTPROCESS_COMMAND_RAAQM_RTC='tail -n +3 | \
print int(a[0]), int(a[n-1]), int(s/n) \
}"'
-HIPERF_CMD_RAAQM="hiperf -n 50 -i 200 -C -H ${RAAQM_PRODUCER}"
+HIPERF_CMD_RAAQM="hiperf -q -n 50 -i 200 -C -H ${RAAQM_PRODUCER}"
HIPERF_CMD_CBR="${HIPERF_CMD_RAAQM} -W 350 -M 0"
HIPERF_CMD_MEMIF_RAAQM="${HIPERF_CMD_RAAQM} -z memif_module"
HIPERF_CMD_MEMIF_CBR="${HIPERF_CMD_CBR} -z memif_module"
diff --git a/tests/forwarder.robot b/tests/forwarder.robot
deleted file mode 100644
index 60345dbb0..000000000
--- a/tests/forwarder.robot
+++ /dev/null
@@ -1,45 +0,0 @@
-*** Settings ***
-Library Process
-Test Template Run Test
-Test Setup Setup
-Test Teardown Teardown
-Test Timeout 5 seconds
-
-*** Variables ***
-${cmd} bash test_forwarder.sh
-
-*** Test Cases ***
-# Commands
-Add listener test_add_listener
-Remove listener test_remove_listener
-Remove non-existing listener test_remove_non_existing_listener
-Add duplicated listener test_add_duplicated_listener
-List listeners test_list_listeners
-Commands from config file test_commands_from_config
-
-# Ping
-Ping one packet test_ping_one_packet
-Ping two packets test_ping_two_packets
-Ping using CS test_ping_using_cs
-Ping using CS different order test_ping_using_cs_different_order
-Ping timeout test_ping_timeout
-Ping aggregation test_ping_aggregation
-Ping with CS store disabled test_ping_with_cs_store_disabled
-Ping with CS serve disabled test_ping_with_cs_serve_disabled
-Ping with eviction test_ping_with_eviction
-Ping with zero data lifetime test_ping_with_zero_data_lifetime
-
-*** Keywords ***
-Setup
- ${result}= Run Process ${cmd} set_up shell=True
- Log Many stdout: ${result.stdout} stderr: ${result.stderr}
-
-Teardown
- ${result}= Run Process ${cmd} tear_down shell=True
- Log Many stdout: ${result.stdout} stderr: ${result.stderr}
-
-Run Test
- [Arguments] ${test_name}
- ${result}= Run Process ${cmd} ${test_name} shell=True
- Log Many stdout: ${result.stdout} stderr: ${result.stderr}
- Should Be Equal As Integers ${result.rc} 0 \ No newline at end of file
diff --git a/tests/hiperf-local.sh b/tests/hiperf-local.sh
new file mode 100644
index 000000000..1ef11eb72
--- /dev/null
+++ b/tests/hiperf-local.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+set -eo pipefail
+
+if [[ "$(basename $(pwd))" != build* ]]; then
+ echo "Error: launch script from build dir"
+ exit 1
+fi
+
+# Stop forwarder and hiperf if already running
+sudo killall -9 hicn-light-daemon hiperf 2>/dev/null || true
+
+# Start forwarder and hiperf server in background
+ninja && sudo ./build-root/bin/hicn-light-daemon --daemon --log-file /tmp/lite_client.log >/dev/null
+./build-root/bin/hiperf -z hicnlightng_module -S b001::/16 &
+
+# Run hiperf client for 20 seconds
+sleep 1
+./build-root/bin/hiperf -z hicnlightng_module -C b001:: -W 50 -n 20
+
+# Clean up
+sudo killall -9 hicn-light-daemon hiperf
diff --git a/tests/test_forwarder.sh b/tests/test_forwarder.sh
deleted file mode 100644
index aba85d8d8..000000000
--- a/tests/test_forwarder.sh
+++ /dev/null
@@ -1,437 +0,0 @@
-#!/bin/bash
-
-############################################################################
-# CONSTANTS
-############################################################################
-INTERFACE_CMD="ip route get 1 | grep -Po '(?<=(dev )).*(?= src| proto)'"
-ADDRESS_CMD="ip route get 1 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}'"
-CTRL_CMD="docker exec test-hicn \
- /hicn-build/build/build-root/bin/hicn-light-control"
-PING_SERVER_CMD="docker exec -d test-hicn \
- /hicn-build/build/build-root/bin/hicn-ping-server \
- -z hicnlightng_module"
-PING_CLIENT_CMD="docker exec test-hicn \
- /hicn-build/build/build-root/bin/hicn-ping-client \
- -z hicnlightng_module"
-PING_CLIENT_DETACHED_CMD="docker exec -d test-hicn \
- /hicn-build/build/build-root/bin/hicn-ping-client \
- -z hicnlightng_module"
-LISTENER_NAME="udp0"
-CONN_NAME="conn0"
-PREFIX="c001::/64"
-COST=1
-FIVE_SECONDS=5000
-
-############################################################################
-# UTILS
-############################################################################
-set_up() {
- docker build -t hicn-dev .
- run_forwarder
-}
-
-tear_down() {
- docker stop --time 0 test-hicn
-}
-
-get_address() {
- echo $(docker exec test-hicn sh -c "${ADDRESS_CMD}")
-}
-
-get_interface() {
- echo $(docker exec test-hicn sh -c "${INTERFACE_CMD}")
-}
-
-#---------------------------------------------------------------------------
-# Exec
-#---------------------------------------------------------------------------
-run_forwarder() {
- capacity=${1:-"100000"}
- loglevel=${2:-"trace"}
- config=${3:-""}
-
- config_file_arg=""
- if [[ $config != "" ]]; then
- config_file_arg="--config ${config}"
- fi
-
- docker run --rm -d --name test-hicn \
- -v $(pwd)/..:/hicn-build \
- -e LD_LIBRARY_PATH=/hicn-build/build/build-root/lib \
- hicn-dev \
- /hicn-build/build/build-root/bin/hicn-light-daemon \
- --log ${loglevel} --capacity ${capacity} $config_file_arg
-}
-
-exec_controller() {
- command=$1
-
- # Redirect stderr to stdout
- output=$(${CTRL_CMD} ${command} 2>&1)
- assert_exit_code
- echo ${output}
-}
-
-exec_ping_server() {
- data_lifetime=${1:-""}
-
- lifetime_arg=""
- if [[ $data_lifetime != "" ]]; then
- lifetime_arg="-l ${data_lifetime}"
- fi
-
- ${PING_SERVER_CMD} ${lifetime_arg}
-}
-
-exec_ping_client() {
- num_packets=$1
-
- output=$(${PING_CLIENT_CMD} -m ${num_packets})
- assert_exit_code
- echo ${output}
-}
-
-exec_ping_client_detached() {
- num_packets=$1
- interest_lifetime=$2
-
- ${PING_CLIENT_DETACHED_CMD} -m ${num_packets} -l ${interest_lifetime}
-}
-
-#---------------------------------------------------------------------------
-# Asserts
-#---------------------------------------------------------------------------
-assert_exit_code() {
- if [[ $? -ne 0 ]]; then
- exit_with_failure
- fi
-}
-
-assert_forwarder() {
- # Print forwarder logs for debug info
- echo "******** Forwarder Logs ********"
- docker logs test-hicn
- echo "********************************"
-
- output=$(docker logs test-hicn)
- if [[ $output == "" ]]; then
- exit_with_failure
- fi
-
- if [[ "${output}" == *"ERROR"* ]]; then
- exit_with_failure
- fi
-
- if [[ "${output}" == *"Aborted (core dumped)"* ]]; then
- exit_with_failure
- fi
-}
-
-assert_ack() {
- # Print controller logs for debug info
- echo "******** Controller Logs ********"
- echo $1
- echo "********************************"
-
- output=$1
-
- if [[ "$output" == *"Error"* ]]; then
- exit_with_failure
- fi
-}
-
-assert_nack() {
- # Print controller logs for debug info
- echo "******** Controller Logs ********"
- echo $1
- echo "********************************"
-
- output=$1
-
- if [[ "$output" != *"Error"* ]]; then
- exit_with_failure
- fi
-}
-
-assert_ping_client() {
- # Print ping client logs for debug info
- echo "******** Ping Client Logs ********"
- echo $1
- echo "********************************"
-
- ping_client_output=$1
- pkts_sent=$2
- pkts_recv=$3
- pkts_timeout=$4
-
- match_str="Sent: ${pkts_sent} Received: ${pkts_recv} Timeouts: ${pkts_timeout}"
- if [[ ! ${ping_client_output} == *"${match_str}"* ]]; then
- exit_with_failure
- fi
-}
-
-assert_forwarder_stats() {
- satisfied_from_cs=${1:-""}
- no_route_in_fib=${2:-""}
- aggregated=${3:-""}
-
- fwder_stats=$(docker logs test-hicn | grep "Forwarder: received" | tail -n 1)
-
- if [[ $satisfied_from_cs != "" &&
- "${fwder_stats}" != *"satisfied_from_cs = ${satisfied_from_cs}"* ]]; then
- exit_with_failure
- fi
-
- if [[ $no_route_in_fib != "" &&
- "${fwder_stats}" != *"no_route_in_fib = ${no_route_in_fib}"* ]]; then
- exit_with_failure
- fi
-
- if [[ $aggregated != "" &&
- "${fwder_stats}" != *"aggregated = ${aggregated}"* ]]; then
- exit_with_failure
- fi
-}
-
-assert_pkt_cache_stats() {
- total_size=${1:-""}
- pit_size=${2:-""}
- cs_size=${3:-""}
-
- pkt_cache_stats=$(docker logs test-hicn | grep "Packet cache:" | tail -n 1)
-
- if [[ $total_size != "" &&
- "${pkt_cache_stats}" != *"total size = ${total_size}"* ]]; then
- exit_with_failure
- fi
-
- if [[ $pit_size != "" &&
- "${pkt_cache_stats}" != *"PIT size = ${pit_size}"* ]]; then
- exit_with_failure
- fi
-
- if [[ $cs_size != "" &&
- "${pkt_cache_stats}" != *"CS size = ${cs_size}"* ]]; then
- exit_with_failure
- fi
-}
-
-assert_cs_stats() {
- evictions=${1:-""}
-
- cs_stats=$(docker logs test-hicn | grep "Content store:" | tail -n 1)
-
- if [[ $evictions != "" &&
- "${cs_stats}" != *"evictions = ${evictions}"* ]]; then
- exit_with_failure
- fi
-}
-
-############################################################################
-# TEST SUITE
-############################################################################
-
-#---------------------------------------------------------------------------
-# Commands
-#---------------------------------------------------------------------------
-test_add_listener() {
- # Exec hicn-light-control command and capture its output
- INTERFACE=$(get_interface)
- ADDRESS=$(get_address)
- command="add listener udp ${LISTENER_NAME} ${ADDRESS} 9695 ${INTERFACE}"
- ctrl_output=$(exec_controller "${command}")
-
- # Check hicn-light-control and hicn-light-daemon outputs
- assert_ack "$ctrl_output"
- assert_forwarder
-}
-
-test_remove_listener() {
- INTERFACE=$(get_interface)
- ADDRESS=$(get_address)
- command="add listener udp ${LISTENER_NAME} ${ADDRESS} 9695 ${INTERFACE}"
- ctrl_output=$(exec_controller "${command}")
- assert_ack "$ctrl_output"
-
- command="remove listener udp0"
- ctrl_output=$(exec_controller "${command}")
-
- assert_ack "$ctrl_output"
- assert_forwarder
-}
-
-test_remove_non_existing_listener() {
- command="remove listener udp0"
- ctrl_output=$(exec_controller "${command}")
-
- assert_nack "$ctrl_output"
- assert_forwarder
-}
-
-test_add_duplicated_listener() {
- # Exec hicn-light-control command and capture its output
- INTERFACE=$(get_interface)
- ADDRESS=$(get_address)
- command="add listener udp ${LISTENER_NAME} ${ADDRESS} 9695 ${INTERFACE}"
- exec_controller "${command}"
- ctrl_output=$(exec_controller "${command}")
-
- # Check hicn-light-control and hicn-light-daemon outputs
- assert_nack "$ctrl_output"
- assert_forwarder
-}
-
-test_list_listeners() {
- # Exec hicn-light-control command and capture its output
- command="list listener"
- ctrl_output=$(exec_controller "${command}")
-
- # Check hicn-light-control and hicn-light-daemon outputs
- assert_forwarder
- # Only the local listener should be present
- [[ "${ctrl_output}" =~ "inet4://127.0.0.1:9695" ]] && return 0 || exit_with_failure
-}
-
-test_commands_from_config() {
- # Create config file
- INTERFACE=$(get_interface)
- ADDRESS=$(get_address)
- echo "# Teset config file
- add listener udp $LISTENER_NAME $ADDRESS 9695 ${INTERFACE}
- add connection udp $CONN_NAME $ADDRESS 12345 $ADDRESS 9695 ${INTERFACE}
- add route $CONN_NAME $PREFIX $COST
- set strategy c001::/64 random
- " >forwarder.conf
-
- # Restart the forwarder specifying the config file
- tear_down
- run_forwarder "" "" "/hicn-build/tests/forwarder.conf"
- rm forwarder.conf
-
- # Check for errors in the output
- assert_forwarder
-}
-
-#---------------------------------------------------------------------------
-# Ping
-#---------------------------------------------------------------------------
-test_ping_one_packet() {
- # Exec hicn-ping-server
- exec_ping_server
- # Exec hicn-ping-client (w/ 1 packet) and capture its output
- output=$(exec_ping_client 1)
-
- # Check hicn-ping-client (1 pkt sent, 1 pkt received, 0 timeouts)
- # and hicn-light-daemon outputs
- assert_ping_client "${output}" 1 1 0
- assert_forwarder
-}
-
-test_ping_two_packets() {
- exec_ping_server
- output=$(exec_ping_client 2)
-
- assert_ping_client "${output}" 2 2 0
- assert_forwarder
-}
-
-test_ping_using_cs() {
- exec_ping_server
- exec_ping_client 2
- output=$(exec_ping_client 1)
-
- assert_ping_client "${output}" 1 1 0
- assert_forwarder
- assert_forwarder_stats 1
-}
-
-test_ping_using_cs_different_order() {
- exec_ping_server
- exec_ping_client 1
- output=$(exec_ping_client 2)
-
- assert_ping_client "${output}" 2 2 0
- assert_forwarder
- assert_forwarder_stats 1
-}
-
-test_ping_timeout() {
- # Send ping without the ping server being run
- output=$(exec_ping_client 1)
-
- assert_ping_client "${output}" 1 0 1
- assert_forwarder
- assert_forwarder_stats 0 1
-}
-
-test_ping_aggregation() {
- # Send ping without server, waiting for a reply
- exec_ping_client_detached 1 ${FIVE_SECONDS}
- exec_ping_server
- # This new ping interest will be aggregated with the previous one
- # and the forwarder will reply to both ping clients
- output=$(exec_ping_client 1)
-
- assert_ping_client "${output}" 1 1 0
- assert_forwarder
- assert_forwarder_stats "" "" 1
-}
-
-test_ping_with_cs_store_disabled() {
- command="store cache off"
- exec_controller "${command}"
-
- exec_ping_server
- exec_ping_client 1
- output=$(exec_ping_client 1)
-
- assert_ping_client "${output}" 1 1 0
- assert_forwarder
- assert_forwarder_stats 0 "" ""
- # The packet is not stored in the CS
- assert_pkt_cache_stats "" "" 0
-}
-
-test_ping_with_cs_serve_disabled() {
- command="serve cache off"
- exec_controller "${command}"
-
- exec_ping_server
- exec_ping_client 1
- output=$(exec_ping_client 1)
-
- assert_ping_client "${output}" 1 1 0
- assert_forwarder
- assert_forwarder_stats 0 "" ""
- # The packet is stored in the CS, but CS is not used
- assert_pkt_cache_stats "" "" 1
-}
-
-test_ping_with_eviction() {
- # Restart the forwarder with CS capacity = 1
- tear_down
- run_forwarder 1
-
- exec_ping_server
- exec_ping_client 1
- output=$(exec_ping_client 2)
-
- assert_ping_client "${output}" 2 2 0
- assert_forwarder
- # Check if eviction happened
- assert_cs_stats 1
- assert_pkt_cache_stats "" "" 1
-}
-
-test_ping_with_zero_data_lifetime() {
- exec_ping_server 0
- exec_ping_client 1
- output=$(exec_ping_client 1)
-
- assert_ping_client "${output}" 1 1 0
- assert_forwarder
- # The data is not taken from the CS because expired
- assert_forwarder_stats 0 "" ""
-}
-
-"$@"