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