FIX: OS detection
[csit.git] / resources / libraries / bash / function / common.sh
index 921b588..02c65c8 100644 (file)
@@ -33,6 +33,7 @@ function activate_docker_topology () {
     # - TOPOLOGIES - Available topologies.
     # - NODENESS - Node multiplicity of desired testbed.
     # - FLAVOR - Node flavor string, usually describing the processor.
+    # - IMAGE_VER_FILE - Name of file that contains the image version.
     # Variables set:
     # - WORKING_TOPOLOGY - Path to topology file.
 
@@ -40,7 +41,7 @@ function activate_docker_topology () {
         die "Source failed!"
     }
 
-    device_image="$(< ${CSIT_DIR}/VPP_DEVICE_IMAGE)"
+    device_image="$(< ${CSIT_DIR}/${IMAGE_VER_FILE})"
     case_text="${NODENESS}_${FLAVOR}"
     case "${case_text}" in
         "1n_skx")
@@ -660,6 +661,7 @@ function select_tags () {
     case "${TEST_CODE}" in
         *"3n-hsw"*)
             test_tag_array+=("!drv_avf")
+            test_tag_array+=("!ipsechwNOTnic_intel-xl710")
             ;;
         *"2n-skx"*)
             test_tag_array+=("!ipsechw")
@@ -690,10 +692,15 @@ function select_tags () {
     # We will prefix with perftest to prevent running other tests
     # (e.g. Functional).
     prefix="perftestAND"
+    set +x
     if [[ "${TEST_CODE}" == "vpp-"* ]]; then
         # Automatic prefixing for VPP jobs to limit the NIC used and
         # traffic evaluation to MRR.
-        prefix="${prefix}mrrAND${DEFAULT_NIC}AND"
+        if [[ "${TEST_TAG_STRING-}" == *"nic_"* ]]; then
+            prefix="${prefix}mrrAND"
+        else
+            prefix="${prefix}mrrAND${DEFAULT_NIC}AND"
+        fi
     fi
     for tag in "${test_tag_array[@]}"; do
         if [[ "${tag}" == "!"* ]]; then
@@ -705,6 +712,7 @@ function select_tags () {
             TAGS+=("${prefix}${tag}")
         fi
     done
+    set -x
 }
 
 
@@ -753,6 +761,36 @@ function select_vpp_device_tags () {
     done
 }
 
+function select_os () {
+
+    set -exuo pipefail
+
+    # Variables set:
+    # - VPP_VER_FILE - Name of File in CSIT dir containing vpp stable version.
+    # - IMAGE_VER_FILE - Name of File in CSIT dir containing the image name.
+    # - PKG_SUFFIX - Suffix of OS package file name, "rpm" or "deb."
+
+    os_id=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') || {
+        die "Get OS release failed."
+    }
+
+    case "${os_id}" in
+        "ubuntu"*)
+            IMAGE_VER_FILE="VPP_DEVICE_IMAGE_UBUNTU"
+            VPP_VER_FILE="VPP_STABLE_VER_UBUNTU_BIONIC"
+            PKG_SUFFIX="deb"
+            ;;
+        "centos"*)
+            IMAGE_VER_FILE="VPP_DEVICE_IMAGE_CENTOS"
+            VPP_VER_FILE="VPP_STABLE_VER_CENTOS"
+            PKG_SUFFIX="rpm"
+            ;;
+        *)
+            die "Unable to identify distro or os from ${OS}"
+            ;;
+    esac
+}
+
 
 function select_topology () {