Explicitly set K8S_CONFORMANCE_IMAGE_VERSION, update si-tests.tgz

* Due to the issue PRODX-38638, Mirantis artifactory has the
  conformance image only inside the internal artifactory. Thus,
  the si-tests cannot make the request to the public artifactory
  and identify the correct Conformance tests image version and path.
* So, now we are setting K8S_CONFORMANCE_IMAGE_VERSION explicitly
  basing on the K8S server version of MCC and MOS.
* Also, setting the K8S_CONFORMANCE_IMAGE_URL to the public path
  because customers envs have no access to the internal paths.
* Updated k8s/src/si-tests.tgz because it has the fix of PRODX-38638.

Related-PROD: PROD-37187
Change-Id: I37271cd187c579baf2115a53a2338a071f3873f0
(cherry picked from commit e3e2fa35dd5424d5d796ed65bc2ee8b24b1ed651)
diff --git a/k8s/src/si-tests.tgz b/k8s/src/si-tests.tgz
index a55d434..90fb01b 100644
--- a/k8s/src/si-tests.tgz
+++ b/k8s/src/si-tests.tgz
Binary files differ
diff --git a/k8s/workspace/init-workspace.sh b/k8s/workspace/init-workspace.sh
index ab1d165..7b835e7 100644
--- a/k8s/workspace/init-workspace.sh
+++ b/k8s/workspace/init-workspace.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
 ### initial folders
 function ewriteln() {
 	echo ${1} | tee -a $MY_PROJFOLDER/env.sh
@@ -7,6 +8,33 @@
 	# echo "# Running 'kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec {} -c keystone-client --stdin -- "${1}"'"
 	kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- '${1}'
 }
+function get_conformance_image_tag() {
+    kubeconfig_path=$1
+    k8s_server_version=$(kubectl --kubeconfig="$kubeconfig_path" version -o json 2>/dev/null | jq -r '.serverVersion.gitVersion')
+    k8s_short_version=${k8s_server_version:1:4}
+    image_tag=""
+    case $k8s_short_version in
+        "1.18")
+            image_tag="1.18.9-16"
+            ;;
+        "1.19")
+            image_tag="1.19.2-1"
+            ;;
+        "1.20")
+            image_tag="1.20.6-4"
+            ;;
+        "1.21")
+            image_tag="1.21.9-4"
+            ;;
+        "1.24")
+            image_tag="1.24.4-2"
+            ;;
+        "1.27")
+            image_tag="1.27.6-2"
+            ;;
+    esac
+    echo "$image_tag"
+}
 
 export MY_PROJFOLDER=/artifacts
 echo "# Using folder '$MY_PROJFOLDER'"
@@ -60,6 +88,16 @@
 ewriteln "export HELM_BINARY_PATH=$(which helm)"
 ewriteln "export K8S_CONFORMANCE_CONCURRENCY=10"
 
+printf "\n\n# Writing additional options for K8S conformance tests for MCC cluster...\n"
+mcc_kubeconfig_path="$MY_PROJFOLDER/envs/mcc-kubeconfig.yaml"
+mcc_conformance_image_tag=$(get_conformance_image_tag "$mcc_kubeconfig_path")
+if [ -z "$mcc_conformance_image_tag" ]; then
+    echo "Could not identify K8S_CONFORMANCE_IMAGE_VERSION for MCC."
+fi
+mcc_conformance_image_url="mirantis.azurecr.io/lcm/kubernetes/k8s-conformance:v${mcc_conformance_image_tag}"
+ewriteln "export MCC_K8S_CONFORMANCE_IMAGE_VERSION='${mcc_conformance_image_tag}'"
+ewriteln "export MCC_K8S_CONFORMANCE_IMAGE_URL='${mcc_conformance_image_url}'"
+
 # extract MOS kubeconfig
 echo " "
 printf "\n\nExtracting mos-kubeconfig.yaml"
@@ -104,6 +142,16 @@
     ewriteln "export SI_BINARIES_DIR=$(which helm | rev | cut -d'/' -f2- | rev)"
     ewriteln "export HELM_BINARY_PATH=$(which helm)"
 
+    printf "\n\n# Writing additional options for K8S conformance tests for MOS cluster...\n"
+    mos_kubeconfig_path="$MY_PROJFOLDER/envs/mos-kubeconfig.yaml"
+    mos_conformance_image_tag=$(get_conformance_image_tag "$mos_kubeconfig_path")
+    if [ -z "$mos_conformance_image_tag" ]; then
+        echo "Could not identify K8S_CONFORMANCE_IMAGE_VERSION for MOS."
+    fi
+    mos_conformance_image_url="mirantis.azurecr.io/lcm/kubernetes/k8s-conformance:v${mos_conformance_image_tag}"
+    ewriteln "export MOS_K8S_CONFORMANCE_IMAGE_VERSION='${mos_conformance_image_tag}'"
+    ewriteln "export MOS_K8S_CONFORMANCE_IMAGE_URL='${mos_conformance_image_url}'"
+
     echo " "
     keystone_pod=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml get pod -n openstack -o=custom-columns=NAME:.metadata.name | grep keystone-client)
     echo "# Extracting network: taking the first found external network"
diff --git a/k8s/workspace/run-conformance-mcc.sh b/k8s/workspace/run-conformance-mcc.sh
index 5a6db04..c6b8be4 100644
--- a/k8s/workspace/run-conformance-mcc.sh
+++ b/k8s/workspace/run-conformance-mcc.sh
@@ -12,6 +12,22 @@
 export K8S_CONFORMANCE_RUN_NETPOLICY_TESTS=False
 echo "Run network policy tests is ${K8S_CONFORMANCE_CONCURRENCY} for MCC"
 
+if [ -z "$MCC_K8S_CONFORMANCE_IMAGE_VERSION" ]; then
+  echo "Error: Failed to determine Kubernetes Conformance image version. Please export K8S_CONFORMANCE_IMAGE_VERSION, for example, export K8S_CONFORMANCE_IMAGE_VERSION=1.xx.x-x"
+  exit 1
+else
+  echo "Using K8S Conformance image version ${MCC_K8S_CONFORMANCE_IMAGE_VERSION}"
+  export K8S_CONFORMANCE_IMAGE_VERSION=${MCC_K8S_CONFORMANCE_IMAGE_VERSION}
+fi
+
+if [ -z "$MCC_K8S_CONFORMANCE_IMAGE_URL" ]; then
+  echo "Error: Failed to determine Kubernetes Conformance image path. Please export K8S_CONFORMANCE_IMAGE_URL, for example, export K8S_CONFORMANCE_IMAGE_URL=mirantis.azurecr.io/lcm/kubernetes/k8s-conformance:v1.xx.x-x"
+  exit 1
+else
+  echo "Using K8S Conformance image path ${MCC_K8S_CONFORMANCE_IMAGE_URL}"
+  export K8S_CONFORMANCE_IMAGE_URL=${MCC_K8S_CONFORMANCE_IMAGE_URL}
+fi
+
 # Run tests
 pytest /opt/si-tests/si_tests/tests/deployment/test_k8s_conformance.py
 unset TARGET_CLUSTER
diff --git a/k8s/workspace/run-conformance-mos.sh b/k8s/workspace/run-conformance-mos.sh
index a528b3d..737c4ff 100644
--- a/k8s/workspace/run-conformance-mos.sh
+++ b/k8s/workspace/run-conformance-mos.sh
@@ -11,6 +11,22 @@
 export K8S_CONFORMANCE_RUN_NETPOLICY_TESTS=False
 echo "Run network policy tests is ${K8S_CONFORMANCE_CONCURRENCY} for MCC"
 
+if [ -z "$MOS_K8S_CONFORMANCE_IMAGE_VERSION" ]; then
+  echo "Error: Failed to determine Kubernetes Conformance image version. Please export K8S_CONFORMANCE_IMAGE_VERSION, for example, export K8S_CONFORMANCE_IMAGE_VERSION=1.xx.x-x"
+  exit 1
+else
+  echo "Using K8S Conformance image version ${MOS_K8S_CONFORMANCE_IMAGE_VERSION}"
+  export K8S_CONFORMANCE_IMAGE_VERSION=${MOS_K8S_CONFORMANCE_IMAGE_VERSION}
+fi
+
+if [ -z "$MOS_K8S_CONFORMANCE_IMAGE_URL" ]; then
+  echo "Error: Failed to determine Kubernetes Conformance image path. Please export K8S_CONFORMANCE_IMAGE_URL, for example, export K8S_CONFORMANCE_IMAGE_URL=mirantis.azurecr.io/lcm/kubernetes/k8s-conformance:v1.xx.x-x"
+  exit 1
+else
+  echo "Using K8S Conformance image path ${MOS_K8S_CONFORMANCE_IMAGE_URL}"
+  export K8S_CONFORMANCE_IMAGE_URL=${MOS_K8S_CONFORMANCE_IMAGE_URL}
+fi
+
 # Run tests
 pytest /opt/si-tests/si_tests/tests/deployment/test_k8s_conformance.py
 unset TARGET_CLUSTER