feat(core): Change external testbed detection" 66/41266/2
authorpmikus <[email protected]>
Tue, 16 Jul 2024 11:49:01 +0000 (13:49 +0200)
committerPeter Mikus <[email protected]>
Tue, 16 Jul 2024 12:03:17 +0000 (12:03 +0000)
Signed-off-by: Peter Mikus <[email protected]>
Change-Id: Id005feac8104bb0b7da08d8dd9baaa3c5117e157

resources/libraries/bash/function/ansible.sh
resources/libraries/bash/function/common.sh

index 6cf4d16..587c59c 100644 (file)
@@ -27,11 +27,17 @@ function ansible_adhoc () {
 
     set -exuo pipefail
 
-    case "$FLAVOR" in
-        "aws" | "c6in" | "c6gn" | "c7gn")
+    case "${TEST_CODE}" in
+        *"1n-aws" | *"2n-aws" | *"3n-aws")
             INVENTORY_PATH="cloud_inventory"
             ;;
-        "x-"*)
+        *"2n-c7gn" | *"3n-c7gn")
+            INVENTORY_PATH="cloud_inventory"
+            ;;
+        *"1n-c6in" | *"2n-c6in" | *"3n-c6in")
+            INVENTORY_PATH="cloud_inventory"
+            ;;
+        *"-x-2n"* | *"-x-3n"*)
             INVENTORY_PATH="external_inventory"
             ;;
         *)
@@ -72,11 +78,17 @@ function ansible_playbook () {
 
     set -exuo pipefail
 
-    case "$FLAVOR" in
-        "aws" | "c6in" | "c6gn" | "c7gn")
+    case "${TEST_CODE}" in
+        *"1n-aws" | *"2n-aws" | *"3n-aws")
+            INVENTORY_PATH="cloud_inventory"
+            ;;
+        *"2n-c7gn" | *"3n-c7gn")
+            INVENTORY_PATH="cloud_inventory"
+            ;;
+        *"1n-c6in" | *"2n-c6in" | *"3n-c6in")
             INVENTORY_PATH="cloud_inventory"
             ;;
-        "x-"*)
+        *"-x-2n"* | *"-x-3n"*)
             INVENTORY_PATH="external_inventory"
             ;;
         *)
index 8a46fc3..4771712 100644 (file)
@@ -17,11 +17,6 @@ set -exuo pipefail
 # This library defines functions used by multiple entry scripts.
 # Keep functions ordered alphabetically, please.
 
-# TODO: Add a link to bash style guide.
-# TODO: Consider putting every die into a {} block,
-#   the code might become more readable (but longer).
-
-
 function activate_docker_topology () {
 
     # Create virtual vpp-device topology. Output of the function is topology
@@ -536,13 +531,15 @@ function get_test_code () {
             NODENESS="3n"
             FLAVOR="alt"
             ;;
-        *"2n-x-"*)
-            NODENESS="2n"
-            FLAVOR="${TEST_CODE#*2n-}"
+        *"-x-2n"*)
+            TESTBED="${TEST_CODE#${TEST_CODE%2n*}}"
+            NODENESS="${TESTBED%-${TEST_CODE#*-x-2n*-}}"
+            FLAVOR="${TEST_CODE#*-x-2n*-}"
             ;;
-        *"3n-x-"*)
-            NODENESS="3n"
-            FLAVOR="${TEST_CODE#*3n-}"
+        *"-x-3n"*)
+            TESTBED="${TEST_CODE#${TEST_CODE%3n*}}"
+            NODENESS="${TESTBED%-${TEST_CODE#*-x-3n*-}}"
+            FLAVOR="${TEST_CODE#*-x-3n*-}"
             ;;
     esac
 }
@@ -982,7 +979,7 @@ function select_tags () {
         *"1n-c6in" | *"2n-c6in" | *"3n-c6in")
             default_nic="nic_amazon-nitro-200g"
             ;;
-        *"2n-x-"* | *"3n-x-"*)
+        *"-x-2n"* | *"-x-3n"*)
             default_nic="nic_intel-e810cq"
             ;;
         *)
@@ -1148,7 +1145,7 @@ function select_tags () {
         *"1n-c6in" | *"2n-c6in" | *"3n-c6in")
             test_tag_array+=("!ipsechw")
             ;;
-        *"2n-x-"* | *"3n-x-"*)
+        *"-x-2n"* | *"-x-3n"*)
             ;;
     esac
 
@@ -1301,12 +1298,12 @@ function select_topology () {
             TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*3nb_spr_*.yaml )
             TOPOLOGIES_TAGS="3_node_*_link_topo"
             ;;
-        "2n_x"*)
-            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*2n_"${FLAVOR}"*.yaml )
+        "x_2n"*)
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*_x_"${NODENESS}-${FLAVOR}"*.yaml )
             TOPOLOGIES_TAGS="2_node_single_link_topo"
             ;;
-        "3n_x"*)
-            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*3n_"${FLAVOR}"*.yaml )
+        "x_3n"*)
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*_x_"${NODENESS}-${FLAVOR}"*.yaml )
             TOPOLOGIES_TAGS="3_node_single_link_topo"
             ;;
         *)
@@ -1362,7 +1359,7 @@ function set_environment_variables () {
             # Maciek's workaround for Zen2 with lower amount of cores.
             export TREX_CORE_COUNT=14
             ;;
-        *"2n-x-"* | *"3n-x-"* )
+        *"-x-2n"* | *"-x-3n"* )
             export TREX_CORE_COUNT=6
             export TREX_PORT_MTU=9000
             ;;