summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLuca Muscariello <muscariello@ieee.org>2022-04-22 17:55:01 +0200
committerMauro Sardara <msardara@cisco.com>2022-04-26 15:30:21 +0200
commita1ac96f497719b897793ac14b287cb8d840651c1 (patch)
tree12c608fe352c21d944b0340ce8d3f0be0fb23b11 /tests
parent1ac07d842a3a6ce0fb7fa4039241c8ec1a71419b (diff)
HICN-722: Updates on transport, RTC, manifest usage for RTC, infra.
Co-authored-by: Mauro Sardara <msardara@cisco.com> Co-authored-by: Jordan Augé <jordan.auge+fdio@cisco.com> Co-authored-by: Michele Papalini <micpapal@cisco.com> Co-authored-by: Angelo Mantellini <manangel@cisco.com> Co-authored-by: Jacques Samain <jsamain@cisco.com> Co-authored-by: Olivier Roques <oroques+fdio@cisco.com> Co-authored-by: Enrico Loparco <eloparco@cisco.com> Co-authored-by: Giulio Grassi <gigrassi@cisco.com> manifest: optimize manifest processing manifest: add FEC parameters to manifests manifest: refactor verification process manifest: report auth alerts in hiperf instead of aborting manifest: remove FEC buffer callback in consumer manifest: refactor and enable manifests by default manifest: update manifest header with transport parameters manifest: batch interests for first manifest from RTC producer manifest: refactor processing of RTC manifests manifest: update manifest-related socket options of consumers manifest: update unit tests for manifests manifest: pack manifest headers manifest: verify FEC packets auth: add consumer socket option to set max unverified delay manifest: process manifests after full FEC decoding manifest: manage forward jumps in RTC verifier fec: remove useless fec codes rs: add new code rate rs: add new code rate rs: add new code rate rs: add new code rate libtransport: increase internal packet cache size remove internal cisco info in cmake manifest: add option to set manifest capacity data_input_node.c: add information about adj_index[VLIB_RX] on received data packetsi sysrepo plugin: update build Change-Id: I0cf64d91bd0a1b7cad4eeaa9871f58f5f10434af Signed-off-by: Mauro Sardara <msardara@cisco.com> Signed-off-by: Luca Muscariello <muscariello@ieee.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/.env1
-rw-r--r--tests/1-node.yml26
-rw-r--r--tests/2-nodes-hicn-light.yml2
-rw-r--r--tests/2-nodes.yml1
-rw-r--r--tests/Makefile35
-rwxr-xr-xtests/config.sh232
-rw-r--r--tests/functional-tests/hicn-light-control.robot29
-rw-r--r--tests/resources/libraries/robot/common.robot2
8 files changed, 324 insertions, 4 deletions
diff --git a/tests/.env b/tests/.env
index 35c861bda..1d40e4dea 100644
--- a/tests/.env
+++ b/tests/.env
@@ -1,4 +1,5 @@
# Topologies
+TOPOLOGY_1_NODE=1-node
TOPOLOGY_2_NODES=2-nodes
# Container names
diff --git a/tests/1-node.yml b/tests/1-node.yml
new file mode 100644
index 000000000..5cd8bd46c
--- /dev/null
+++ b/tests/1-node.yml
@@ -0,0 +1,26 @@
+version: "3"
+services:
+ client:
+ build:
+ context: ..
+ dockerfile: ${DOCKERFILE}
+ args:
+ BASE_IMAGE: ${BASE_IMAGE}
+ image: hicn-base
+ privileged: true
+ container_name: forwarder
+ working_dir: /workspace
+ volumes:
+ - ..:/workspace
+ entrypoint: [/bin/bash, -ex, -c]
+ command:
+ - |
+ if [ -d /workspace/build-dev ]; then
+ ninja -C /workspace/build-dev install
+ fi
+
+ sudo ip addr add 192.168.1.1/24 dev eth0
+ sudo hicn-light-daemon \
+ --daemon --log-file /tmp/lite_client.log
+
+ tail -f /dev/null
diff --git a/tests/2-nodes-hicn-light.yml b/tests/2-nodes-hicn-light.yml
index e62a6c705..318a5ccbd 100644
--- a/tests/2-nodes-hicn-light.yml
+++ b/tests/2-nodes-hicn-light.yml
@@ -25,7 +25,7 @@ services:
sudo hicn-light-daemon \
--daemon \
--log-file /tmp/lite_client.log \
- --config /tmp/hicn-light.conf --capacity 0
+ --config /tmp/hicn-light.conf
tail -f /dev/null
diff --git a/tests/2-nodes.yml b/tests/2-nodes.yml
index ce87e5876..72dcc2298 100644
--- a/tests/2-nodes.yml
+++ b/tests/2-nodes.yml
@@ -6,6 +6,7 @@ services:
dockerfile: ${DOCKERFILE}
args:
BASE_IMAGE: ${BASE_IMAGE}
+ image: hicn-base
privileged: true
stdin_open: true
hostname: client
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 000000000..6e85a717e
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,35 @@
+# Use when building for the fist time,
+# then `make test` forces a rebuild if local changes
+build:
+ BASE_IMAGE=hicn DOCKERFILE=Dockerfile.dev BUILD_SOFTWARE=1 \
+ docker-compose -f build.yml up --force-recreate --remove-orphans
+
+# Rebuild from scratch (to avoid cmake cache)
+rebuild:
+ BASE_IMAGE=hicn DOCKERFILE=Dockerfile.dev BUILD_SOFTWARE=1 \
+ REBUILD=1 \
+ docker-compose -f build.yml up --force-recreate --remove-orphans
+
+# Force base image creation from scratch
+rebase:
+ DOCKERFILE=Dockerfile.dev \
+ docker-compose -f build.yml build --pull --no-cache
+
+# If local changes, hicn is re-built
+test:
+ docker-compose -f 1-node.yml up --force-recreate --remove-orphans -d
+
+log:
+ docker exec forwarder tail -f -n +1 /tmp/lite_client.log
+
+shell:
+ docker exec -it forwarder bash
+
+down:
+ docker-compose -f 1-node.yml 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
diff --git a/tests/config.sh b/tests/config.sh
index bcd27e0b9..d504b1c97 100755
--- a/tests/config.sh
+++ b/tests/config.sh
@@ -118,7 +118,6 @@ function conf_exists() {
[[ "${configurations[*]}" =~ ${1} ]] && return 0 || return 1
}
-
# test-name client/server link-model
function setchannel() {
if ! conf_exists "${1}"; then
@@ -184,8 +183,16 @@ function setup() {
error "Error: topology does not exist."
fi
+ if [[ "${topology}" == "1-node" && "${conf}" == "None" ]]; then
+ docker-compose -f "${topology}".yml build
+ docker-compose -f "${topology}".yml up --remove-orphans --force-recreate -d
+
+ sleep 1
+ return
+ fi
+
if ! conf_exists "${conf}"; then
- error "Error: topology does not exist."
+ error "Error: topology conf does not exist."
fi
docker-compose -f "${topology}".yml -f "${topology}-${conf}".yml build
@@ -219,6 +226,11 @@ function stop() {
error "Error: topology does not exist."
fi
+ if [[ "${topology}" == "1-node" && "${conf}" == "None" ]]; then
+ docker-compose -f "${topology}".yml down || true
+ return
+ fi
+
if ! conf_exists "${conf}"; then
error "Error: tect configuration does not exist."
fi
@@ -240,6 +252,216 @@ function runtest() {
echo "${@}" | sudo -i
}
+################################################################
+# Test commands (hicn-light-control)
+################################################################
+INTERFACE="eth0"
+ADDRESS="192.168.1.1"
+LISTENER_NAME="udp0"
+LISTENER_NAME_2="udp1"
+CONN_NAME="conn0"
+CONN_NAME_2="conn1"
+PREFIX="b001::/16"
+COST=1
+
+#---------------------------------------------------------------
+# Helpers
+#---------------------------------------------------------------
+function exec_command() {
+ command=$1
+
+ output=$(docker exec forwarder hicn-light-control $command 2>&1)
+ echo "$output"
+}
+
+function assert_cmd_success() {
+ command=$1
+ output=$(exec_command "${command}")
+
+ if [[ -z "$output" ]]; then
+ echo "OK"
+ else
+ echo "FAILED"
+ exit 0
+ fi
+}
+
+function assert_cmd_failure() {
+ command=$1
+ output=$(exec_command "${command}")
+
+ if [[ ! -z "$output" ]]; then
+ echo "OK"
+ else
+ echo "FAILED"
+ exit 0
+ fi
+}
+
+#---------------------------------------------------------------
+# Tests for listeners, connections, routes
+#---------------------------------------------------------------
+function test_listeners() {
+ echo -n "Add listeners: "
+ command="add listener udp $LISTENER_NAME $ADDRESS 9695 $INTERFACE"
+ _=$(exec_command "${command}")
+ command="add listener udp $LISTENER_NAME_2 127.0.0.1 12345 $INTERFACE"
+ assert_cmd_success "${command}"
+
+ echo -n "List listeners: "
+ command="list listener"
+ output=$(exec_command "${command}")
+
+ if [[ "${output}" =~ "udp0 inet4://192.168.1.1:9695" &&
+ "${output}" =~ "udp1 inet4://127.0.0.1:12345" &&
+ "${output}" =~ "interface=lo" &&
+ "${output}" =~ "interface=$INTERFACE" &&
+ ! "${output}" =~ "ERROR" ]]; then
+ echo "OK"
+ else
+ echo "FAILED"
+ echo $output
+ exit 0
+ fi
+
+ echo -n "Remove listener using symbolic: "
+ command="remove listener $LISTENER_NAME"
+ assert_cmd_success "${command}"
+
+ echo -n "Remove listener using ID: "
+ command="remove listener 2"
+ assert_cmd_success "${command}"
+
+ echo -n "Remove non-existing listener using symbolic: "
+ command="remove listener $LISTENER_NAME_2"
+ assert_cmd_failure "${command}"
+
+ echo -n "Remove non-existing listener using ID: "
+ command="remove listener 5"
+ assert_cmd_failure "${command}"
+
+ echo -n "Add duplicated listener (same symbolic): "
+ command="add listener udp $LISTENER_NAME $ADDRESS 9695 $INTERFACE"
+ _=$(exec_command "${command}")
+ command="add listener udp $LISTENER_NAME 127.0.0.1 12345 $INTERFACE"
+ assert_cmd_failure "${command}"
+
+ echo -n "Add duplicated listener (same endpoints): "
+ command="add listener udp $LISTENER_NAME $ADDRESS 9695 $INTERFACE"
+ _=$(exec_command "${command}")
+ command="add listener udp $LISTENER_NAME_2 $ADDRESS 9695 $INTERFACE"
+ assert_cmd_failure "${command}"
+}
+
+function test_connections() {
+ echo -n "Add connections: "
+ command="add listener udp $LISTENER_NAME $ADDRESS 9695 $INTERFACE"
+ _=$(exec_command "${command}")
+ command="add connection udp $CONN_NAME $ADDRESS 9695 $ADDRESS 9695 $INTERFACE"
+ _=$(exec_command "${command}")
+ command="add connection udp $CONN_NAME_2 $ADDRESS 12345 $ADDRESS 9695 $INTERFACE"
+ assert_cmd_success "${command}"
+
+ echo -n "List connections: "
+ command="list connection"
+ output=$(exec_command "${command}")
+
+ if [[ "${output}" =~ "inet4://192.168.1.1:12345" &&
+ "${output}" =~ "inet4://192.168.1.1:9695" &&
+ "${output}" =~ "conn0" && "${output}" =~ "conn1" &&
+ ! "${output}" =~ "ERROR" ]]; then
+ echo "OK"
+ else
+ echo "FAILED"
+ echo $output
+ exit 0
+ fi
+
+ echo -n "Remove connection using symbolic: "
+ command="remove connection $CONN_NAME"
+ assert_cmd_success "${command}"
+
+ echo -n "Remove connection using ID: "
+ command="remove connection 2"
+ assert_cmd_success "${command}"
+
+ echo -n "Remove non-existing connection using symbolic: "
+ command="remove connection $CONN_NAME"
+ assert_cmd_failure "${command}"
+
+ echo -n "Remove non-existing connection using ID: "
+ command="remove connection 5"
+ assert_cmd_failure "${command}"
+
+ echo -n "Add duplicated connection (same symbolic): "
+ command="add connection udp $CONN_NAME $ADDRESS 9695 $ADDRESS 9695 $INTERFACE"
+ _=$(exec_command "${command}")
+ command="add connection udp $CONN_NAME $ADDRESS 9695 $ADDRESS 12345 $INTERFACE"
+ assert_cmd_failure "${command}"
+
+ # This case is allowed, success code is returned and symbolic is not updated
+ echo -n "Add duplicated connection (different symbolic, same endpoints): "
+ command="add connection udp $CONN_NAME_2 $ADDRESS 9695 $ADDRESS 9695 $INTERFACE"
+ assert_cmd_success "${command}"
+}
+
+function test_routes() {
+ echo -n "Add route: "
+ command="add listener udp $LISTENER_NAME $ADDRESS 9695 $INTERFACE"
+ _=$(exec_command "${command}")
+ command="add connection udp $CONN_NAME $ADDRESS 9695 $ADDRESS 9695 $INTERFACE"
+ _=$(exec_command "${command}")
+ command="add route $CONN_NAME $PREFIX $COST"
+ assert_cmd_success "${command}"
+
+ echo -n "List routes: "
+ command="list route"
+ output=$(exec_command "${command}")
+
+ if [[ "${output}" =~ "b001::" && "${output}" =~ "16" &&
+ ! "${output}" =~ "ERROR" ]]; then
+ echo "OK"
+ else
+ echo "FAILED"
+ echo "$output"
+ exit 0
+ fi
+
+ echo -n "Remove route using symbolic: "
+ command="remove route $CONN_NAME $PREFIX"
+ assert_cmd_success "${command}"
+
+ echo -n "Remove route using ID: "
+ command="add route $CONN_NAME $PREFIX $COST"
+ _=$(exec_command "${command}")
+ command="remove route 1 $PREFIX"
+ assert_cmd_success "${command}"
+
+ echo -n "Remove non-existing route using symbolic: "
+ command="remove connection $CONN_NAME $PREFIX"
+ assert_cmd_failure "${command}"
+
+ echo -n "Remove non-existing route using ID: "
+ command="remove route 5 $PREFIX"
+ assert_cmd_failure "${command}"
+}
+
+declare -A ctrl_tests=(
+ ["listeners"]="test_listeners"
+ ["connections"]="test_connections"
+ ["routes"]="test_routes"
+)
+
+function ctrl() {
+ type=$1
+ if [[ ! -v "ctrl_tests[${type}]" ]]; then
+ error "Error: hicn-light-contrl test does not exist."
+ exit 1
+ fi
+
+ ${ctrl_tests[${type}]}
+}
+
while (("${#}")); do
case "$1" in
'build')
@@ -281,9 +503,13 @@ while (("${#}")); do
runtest "${@:2}"
break
;;
- *)
+ 'ctrl')
+ ctrl "${2}"
break
;;
+ *)
+ exit 1
+ ;;
esac
done
diff --git a/tests/functional-tests/hicn-light-control.robot b/tests/functional-tests/hicn-light-control.robot
new file mode 100644
index 000000000..e29fc51d6
--- /dev/null
+++ b/tests/functional-tests/hicn-light-control.robot
@@ -0,0 +1,29 @@
+*** 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 ***
+Listeners
+ Log to console Test listeners
+ ${result} = Run Process ${EXECDIR}/config.sh ctrl listeners
+ Log Many stdout: ${result.stdout}
+ Should Be Equal As Integers ${result.rc} 0
+ Should Not Contain ${result.stdout} FAILED
+
+Connections
+ Log to console Test connections
+ ${result} = Run Process ${EXECDIR}/config.sh ctrl connections
+ Log Many stdout: ${result.stdout}
+ Should Be Equal As Integers ${result.rc} 0
+ Should Not Contain ${result.stdout} FAILED
+
+Routes
+ Log to console Test routes
+ ${result} = Run Process ${EXECDIR}/config.sh ctrl routes
+ Log Many stdout: ${result.stdout}
+ Should Be Equal As Integers ${result.rc} 0
+ Should Not Contain ${result.stdout} FAILED
diff --git a/tests/resources/libraries/robot/common.robot b/tests/resources/libraries/robot/common.robot
index c1e3f20a4..7550db788 100644
--- a/tests/resources/libraries/robot/common.robot
+++ b/tests/resources/libraries/robot/common.robot
@@ -13,6 +13,7 @@ Build Topology
${result_setup} = Run Process ${EXECDIR}/config.sh build setup ${TEST_TOPOLOGY} ${TEST_CONFIGURATION}
Log to console Done
Log Many stdout: ${result_setup.stdout} stderr: ${result_setup.stderr}
+ Should Be Equal As Integers ${result_setup.rc} 0
Check Environment
${result} = Run Process docker ps
@@ -21,3 +22,4 @@ Check Environment
Destroy Topology
${result_teardown} = Run Process ${EXECDIR}/config.sh stopall
Log Many stdout: ${result_teardown.stdout} stderr: ${result_teardown.stderr}
+ Should Be Equal As Integers ${result_teardown.rc} 0