code and doc updates for vagrant VM dev/test environ setup
[csit.git] / resources / libraries / bash / function / common.sh
index fa4b8e7..9db0ac8 100644 (file)
@@ -45,7 +45,7 @@ function activate_docker_topology () {
     device_image="$(< ${CSIT_DIR}/${IMAGE_VER_FILE})"
     case_text="${NODENESS}_${FLAVOR}"
     case "${case_text}" in
-        "1n_skx" | "1n_tx2")
+        "1n_skx" | "1n_tx2" | "1n_spr")
             # We execute reservation over csit-shim-dcr (ssh) which runs sourced
             # script's functions. Env variables are read from ssh output
             # back to localhost for further processing.
@@ -311,31 +311,37 @@ function deactivate_docker_topology () {
     # Variables read:
     # - NODENESS - Node multiplicity of desired testbed.
     # - FLAVOR - Node flavor string, usually describing the processor.
+    # - CSIT_NO_CLEANUP - Variable to disable cleaning up the environment.
 
     set -exuo pipefail
 
-    case_text="${NODENESS}_${FLAVOR}"
-    case "${case_text}" in
-        "1n_skx" | "1n_tx2")
-            ssh="ssh root@172.17.0.1 -p 6022"
-            env_vars=$(env | grep CSIT_ | tr '\n' ' ' ) || die
-            # The "declare -f" output is long and boring.
-            set +x
-            ${ssh} "$(declare -f); deactivate_wrapper ${env_vars}" || {
-                die "Topology cleanup via shim-dcr failed!"
-            }
-            set -x
-            ;;
-        "1n_vbox")
-            enter_mutex || die
-            clean_environment || {
-                die "Topology cleanup locally failed!"
-            }
-            exit_mutex || die
-            ;;
-        *)
-            die "Unknown specification: ${case_text}!"
-    esac
+    if [[ ${CSIT_NO_CLEANUP:-0} -eq 0 ]]; then
+        case_text="${NODENESS}_${FLAVOR}"
+        case "${case_text}" in
+            "1n_skx" | "1n_tx2" | "1n_spr")
+                ssh="ssh root@172.17.0.1 -p 6022"
+                env_vars=$(env | grep CSIT_ | tr '\n' ' ' ) || die
+                # The "declare -f" output is long and boring.
+                set +x
+                ${ssh} "$(declare -f); deactivate_wrapper ${env_vars}" || {
+                    die "Topology cleanup via shim-dcr failed!"
+                }
+                set -x
+                ;;
+            "1n_vbox")
+                enter_mutex || die
+                clean_environment || {
+                    die "Topology cleanup locally failed!"
+                }
+                exit_mutex || die
+                ;;
+            *)
+                die "Unknown specification: ${case_text}!"
+        esac
+    else
+        echo "CSIT_NO_CLEANUP environment variable is set"
+        echo "Environment Cleanup Abandoned"
+    fi
 }
 
 
@@ -436,6 +442,10 @@ function get_test_code () {
             NODENESS="1n"
             FLAVOR="skx"
             ;;
+        *"1n-spr"*)
+            NODENESS="1n"
+            FLAVOR="spr"
+            ;;
         *"1n-tx2"*)
             NODENESS="1n"
             FLAVOR="tx2"
@@ -452,6 +462,30 @@ function get_test_code () {
             NODENESS="3n"
             FLAVOR="aws"
             ;;
+        *"1n-c6gn"*)
+            NODENESS="1n"
+            FLAVOR="c6gn"
+            ;;
+        *"2n-c6gn"*)
+            NODENESS="2n"
+            FLAVOR="c6gn"
+            ;;
+        *"3n-c6gn"*)
+            NODENESS="3n"
+            FLAVOR="c6gn"
+            ;;
+        *"1n-c6in"*)
+            NODENESS="1n"
+            FLAVOR="c6in"
+            ;;
+        *"2n-c6in"*)
+            NODENESS="2n"
+            FLAVOR="c6in"
+            ;;
+        *"3n-c6in"*)
+            NODENESS="3n"
+            FLAVOR="c6in"
+            ;;
         *"2n-zn2"*)
             NODENESS="2n"
             FLAVOR="zn2"
@@ -509,6 +543,8 @@ function get_test_tag_string () {
     # Variables set:
     # - TEST_TAG_STRING - The string following trigger word in gerrit comment.
     #   May be empty, or even not set on event types not adding comment.
+    # Variables exported optionally:
+    # - GRAPH_NODE_VARIANT - Node variant to test with, set if found in trigger.
 
     # TODO: ci-management scripts no longer need to perform this.
 
@@ -642,6 +678,24 @@ function prepare_topology () {
             }
             terraform_apply || die "Failed to call terraform apply."
             ;;
+        "1n_c6gn" | "2n_c6gn" | "3n_c6gn")
+            export TF_VAR_testbed_name="${TEST_CODE}"
+            TERRAFORM_MODULE_DIR="terraform-aws-${NODENESS}-c6gn"
+            terraform_init || die "Failed to call terraform init."
+            trap "terraform_destroy" ERR EXIT || {
+                die "Trap attempt failed, please cleanup manually. Aborting!"
+            }
+            terraform_apply || die "Failed to call terraform apply."
+            ;;
+        "1n_c6in" | "2n_c6in" | "3n_c6in")
+            export TF_VAR_testbed_name="${TEST_CODE}"
+            TERRAFORM_MODULE_DIR="terraform-aws-${NODENESS}-c6in"
+            terraform_init || die "Failed to call terraform init."
+            trap "terraform_destroy" ERR EXIT || {
+                die "Trap attempt failed, please cleanup manually. Aborting!"
+            }
+            terraform_apply || die "Failed to call terraform apply."
+            ;;
     esac
 }
 
@@ -815,7 +869,7 @@ function select_tags () {
 
     # NIC SELECTION
     case "${TEST_CODE}" in
-        *"1n-aws"*)
+        *"1n-aws"* | *"1n-c6gn"* | *"1n-c6in"*)
             start_pattern='^  SUT:'
             ;;
         *)
@@ -865,6 +919,12 @@ function select_tags () {
         *"1n-aws"* | *"2n-aws"* | *"3n-aws"*)
             default_nic="nic_amazon-nitro-50g"
             ;;
+        *"1n-c6gn"* | *"2n-c6gn"* | *"3n-c6gn"*)
+            default_nic="nic_amazon-nitro-100g"
+            ;;
+        *"1n-c6in"* | *"2n-c6in"* | *"3n-c6in"*)
+            default_nic="nic_amazon-nitro-200g"
+            ;;
         *)
             default_nic="nic_intel-x710"
             ;;
@@ -883,6 +943,9 @@ function select_tags () {
     awk_nics_sub_cmd+='gsub("vic1227","10ge2p1vic1227");'
     awk_nics_sub_cmd+='gsub("vic1385","40ge2p1vic1385");'
     awk_nics_sub_cmd+='gsub("nitro-50g","50ge1p1ENA");'
+    awk_nics_sub_cmd+='gsub("nitro-100g","100ge1p1ENA");'
+    awk_nics_sub_cmd+='gsub("nitro-200g","200ge1p1ENA");'
+    awk_nics_sub_cmd+='gsub("virtual","1ge1p82540em");'
     awk_nics_sub_cmd+='if ($9 =="drv_avf") drv="avf-";'
     awk_nics_sub_cmd+='else if ($9 =="drv_rdma_core") drv ="rdma-";'
     awk_nics_sub_cmd+='else if ($9 =="drv_mlx5_core") drv ="mlx5-";'
@@ -981,7 +1044,6 @@ function select_tags () {
             test_tag_array+=("!ipsechw")
             ;;
         *"2n-spr"*)
-            test_tag_array+=("!ipsechw")
             ;;
         *"2n-tx2"*)
             test_tag_array+=("!ipsechw")
@@ -999,10 +1061,8 @@ function select_tags () {
         *"3n-snr"*)
             ;;
         *"3na-spr"*)
-            test_tag_array+=("!ipsechw")
             ;;
         *"3nb-spr"*)
-            test_tag_array+=("!ipsechw")
             ;;
         *"3n-tsh"*)
             test_tag_array+=("!drv_avf")
@@ -1011,6 +1071,12 @@ function select_tags () {
         *"1n-aws"* | *"2n-aws"* | *"3n-aws"*)
             test_tag_array+=("!ipsechw")
             ;;
+        *"1n-c6gn"* | *"2n-c6gn"* | *"3n-c6gn"*)
+            test_tag_array+=("!ipsechw")
+            ;;
+        *"1n-c6in"* | *"2n-c6in"* | *"3n-c6in"*)
+            test_tag_array+=("!ipsechw")
+            ;;
     esac
 
     # We will add excluded NICs.
@@ -1018,19 +1084,15 @@ function select_tags () {
 
     TAGS=()
     prefix=""
-
-    set +x
     if [[ "${TEST_CODE}" == "vpp-"* ]]; then
         if [[ "${TEST_CODE}" != *"device"* ]]; then
-            # Automatic prefixing for VPP perf jobs to limit the NIC used and
-            # traffic evaluation to MRR.
-            if [[ "${TEST_TAG_STRING-}" == *"nic_"* ]]; then
-                prefix="${prefix}mrrAND"
-            else
-                prefix="${prefix}mrrAND${default_nic}AND"
+            # Automatic prefixing for VPP perf jobs to limit the NIC used.
+            if [[ "${TEST_TAG_STRING-}" != *"nic_"* ]]; then
+                prefix="${default_nic}AND"
             fi
         fi
     fi
+    set +x
     for tag in "${test_tag_array[@]}"; do
         if [[ "${tag}" == "!"* ]]; then
             # Exclude tags are not prefixed.
@@ -1079,7 +1141,7 @@ function select_topology () {
             TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*vpp_device*.template )
             TOPOLOGIES_TAGS="2_node_single_link_topo"
             ;;
-        "1n_skx" | "1n_tx2")
+        "1n_skx" | "1n_tx2" | "1n_spr")
             TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*vpp_device*.template )
             TOPOLOGIES_TAGS="2_node_single_link_topo"
             ;;
@@ -1147,6 +1209,30 @@ function select_topology () {
             TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*3n-aws*.yaml )
             TOPOLOGIES_TAGS="3_node_single_link_topo"
             ;;
+        "1n_c6gn")
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*1n-c6gn*.yaml )
+            TOPOLOGIES_TAGS="1_node_single_link_topo"
+            ;;
+        "2n_c6gn")
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*2n-c6gn*.yaml )
+            TOPOLOGIES_TAGS="2_node_single_link_topo"
+            ;;
+        "3n_c6gn")
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*3n-c6gn*.yaml )
+            TOPOLOGIES_TAGS="3_node_single_link_topo"
+            ;;
+        "1n_c6in")
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*1n-c6in*.yaml )
+            TOPOLOGIES_TAGS="1_node_single_link_topo"
+            ;;
+        "2n_c6in")
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*2n-c6in*.yaml )
+            TOPOLOGIES_TAGS="2_node_single_link_topo"
+            ;;
+        "3n_c6in")
+            TOPOLOGIES=( "${TOPOLOGIES_DIR}"/*3n-c6in*.yaml )
+            TOPOLOGIES_TAGS="3_node_single_link_topo"
+            ;;
         *)
             # No falling back to default, that should have been done
             # by the function which has set NODENESS and FLAVOR.
@@ -1173,7 +1259,20 @@ function set_environment_variables () {
 
     case "${TEST_CODE}" in
         *"1n-aws"* | *"2n-aws"* | *"3n-aws"*)
-            # T-Rex 2.88+ workaround for ENA NICs.
+            export TREX_RX_DESCRIPTORS_COUNT=1024
+            export TREX_EXTRA_CMDLINE="--mbuf-factor 19"
+            export TREX_CORE_COUNT=6
+            # Settings to prevent duration stretching.
+            export PERF_TRIAL_STL_DELAY=0.1
+            ;;
+        *"1n-c6gn"* | *"2n-c6gn"* | *"3n-c6gn"*)
+            export TREX_RX_DESCRIPTORS_COUNT=1024
+            export TREX_EXTRA_CMDLINE="--mbuf-factor 19"
+            export TREX_CORE_COUNT=6
+            # Settings to prevent duration stretching.
+            export PERF_TRIAL_STL_DELAY=0.1
+            ;;
+        *"1n-c6in"* | *"2n-c6in"* | *"3n-c6in"*)
             export TREX_RX_DESCRIPTORS_COUNT=1024
             export TREX_EXTRA_CMDLINE="--mbuf-factor 19"
             export TREX_CORE_COUNT=6
@@ -1227,6 +1326,14 @@ function untrap_and_unreserve_testbed () {
                 TERRAFORM_MODULE_DIR="terraform-aws-${NODENESS}-${FLAVOR}-c5n"
                 terraform_destroy || die "Failed to call terraform destroy."
                 ;;
+            *"1n-c6gn"* | *"2n-c6gn"* | *"3n-c6gn"*)
+                TERRAFORM_MODULE_DIR="terraform-aws-${NODENESS}-${FLAVOR}"
+                terraform_destroy || die "Failed to call terraform destroy."
+                ;;
+            *"1n-c6in"* | *"2n-c6in"* | *"3n-c6in"*)
+                TERRAFORM_MODULE_DIR="terraform-aws-${NODENESS}-${FLAVOR}"
+                terraform_destroy || die "Failed to call terraform destroy."
+                ;;
             *)
                 ;;
         esac