Ievgeniia Zadorozhna | 3d76186 | 2024-10-01 19:28:04 +0200 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | tenv=mos |
| 4 | . /opt/si-tests/.sivenv/bin/activate |
| 5 | cd $MY_PROJFOLDER/tmp |
| 6 | . $MY_PROJFOLDER/env.sh |
| 7 | . $MY_PROJFOLDER/envs/mccrc |
| 8 | |
| 9 | if [ -z "$WRITER_PASSWORD" ]; then |
| 10 | echo -e "\nWRITER_PASSWORD is not exported or is empty.\nPlease export WRITER_PASSWORD or edit the /artifacts/env.sh file to set the writer keycloak user password in WRITER_PASSWORD\nExiting...\n" |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | # Configuring the env variables |
| 15 | echo "# Configuring env variables" |
| 16 | unset TARGET_CLUSTER |
| 17 | unset TARGET_NAMESPACE |
| 18 | unset ENV_NAME |
| 19 | export TARGET_NAMESPACE=${MOS_NS} |
| 20 | export TARGET_CLUSTER=${MOS_CLUSTER} |
| 21 | export COMPONENT_TEST_RUN_ON_TARGET_CLUSTER=True |
| 22 | export ENV_NAME=${MOS_CLUSTER} |
| 23 | |
| 24 | public_domain_name=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack get osdpl -o jsonpath='{.items[0].spec.public_domain_name}') |
| 25 | export OS_KEYSTONE_URL="https://keystone.${public_domain_name}/v3" |
| 26 | export SL_TESTS_OS_KEYSTONE_URL=$OS_KEYSTONE_URL |
| 27 | export OS_DOMAIN_NAME=$public_domain_name |
| 28 | export SL_TESTS_OS_DOMAIN_NAME=$public_domain_name |
| 29 | |
| 30 | si_config_file="$MY_PROJFOLDER/envs/si-config.yaml" |
| 31 | if [ ! -f "$si_config_file" ]; then |
| 32 | echo -e "\nFile '$si_config_file' does not exist, creating it..." |
| 33 | touch "$si_config_file" |
| 34 | else |
| 35 | echo "File '$si_config_file' already exists." |
| 36 | fi |
| 37 | cat <<EOF > "$si_config_file" |
| 38 | keycloak_users: |
| 39 | writer: $WRITER_PASSWORD |
| 40 | EOF |
| 41 | export SI_CONFIG=$MY_PROJFOLDER/envs/si-config.yaml |
| 42 | export SI_CONFIG_PATH=$SI_CONFIG |
| 43 | cat $SI_CONFIG |
| 44 | |
| 45 | if [ -z "$KEYCLOAK_URL" ]; then |
| 46 | echo "KEYCLOAK_URL is not exported in the environment variables, getting it from:" |
| 47 | echo "kubectl get cluster kaas-mgmt -o jsonpath='{.status.providerStatus.helm.releases.iam.keycloak.url}'" |
| 48 | KEYCLOAK_URL=$(kubectl get cluster kaas-mgmt -o jsonpath='{.status.providerStatus.helm.releases.iam.keycloak.url}') |
| 49 | else |
| 50 | echo "KEYCLOAK_URL is manually set to $KEYCLOAK_URL" |
| 51 | fi |
| 52 | export KEYCLOAK_URL=$KEYCLOAK_URL |
| 53 | |
| 54 | # Cleaning up |
| 55 | echo "# Cleaning up '/artifacts/tmp/artifacts/'" |
| 56 | [ -d "/artifacts/tmp/artifacts/" ] && rm -rf "/artifacts/tmp/artifacts/" |
| 57 | [ -f "/artifacts/tmp/nosetests.xml" ] && rm "/artifacts/tmp/nosetests.xml" |
| 58 | mkdir "/artifacts/tmp/artifacts/" |
| 59 | |
| 60 | # Show the exported envs |
| 61 | echo "# Exported envs" |
| 62 | env | grep TARGET |
| 63 | env | grep BIN |
| 64 | env | grep KUBE |
| 65 | env | grep K8S | grep -v CONFORMANCE |
| 66 | env | grep SI_CONFIG |
| 67 | env | grep KEYCLOAK |
| 68 | env | grep OS_ |
| 69 | env | grep SL_TESTS |
| 70 | env | grep COMPONENT_TEST_RUN_ON_TARGET_CLUSTER |
| 71 | |
| 72 | # Run tests |
| 73 | echo "# Running the tests" |
| 74 | pytest -vv /opt/si-tests/si_tests/tests/deployment/test_sl_test.py |
| 75 | deactivate |
| 76 | |
| 77 | # Report |
| 78 | if [ -d $MY_PROJFOLDER/reports/${tenv}-stacklight ]; then |
| 79 | echo "# Generating repors" |
| 80 | yes | rm $MY_PROJFOLDER/reports/${tenv}-stacklight/* |
| 81 | else |
| 82 | mkdir $MY_PROJFOLDER/reports/${tenv}-stacklight |
| 83 | fi |
| 84 | cp ./artifacts/*.xml $MY_PROJFOLDER/reports/${tenv}-stacklight/ |
| 85 | cd $MY_PROJFOLDER/reports/ |
| 86 | tparser -f r_xml -d -r $MY_CLIENTSHORTNAME-${tenv}-stacklight-latest.html $MY_PROJFOLDER/reports/${tenv}-stacklight/ |
| 87 | cd $MY_PROJFOLDER |