Updated the settings for Tempest configuration
See the ticket [1] as the reason of the changes.
List of the main changes:
* Ability to set the CUSTOM_PUBLIC_NET_NAME - floating network
in the offline and online methods of execution.
* The cvp.* flavors and images are not passed in tempest config.
* tempest_custom.yaml.clean file has reduced number of options
(the old and irrelevant are removed).
[1] https://mirantis.jira.com/browse/PRODX-39383
Related-PROD: PROD-37187
Change-Id: I31e8c8e4b3d8eda706cbba46b4435d31f8f8eb4e
diff --git a/k8s/workspace/init-workspace.sh b/k8s/workspace/init-workspace.sh
index c25a583..5d7b7e3 100644
--- a/k8s/workspace/init-workspace.sh
+++ b/k8s/workspace/init-workspace.sh
@@ -70,6 +70,7 @@
ewriteln "export MY_CLIENTNAME='ClientName'"
ewriteln "export MY_CLIENTSHORTNAME='clname'"
ewriteln "export MY_PROJNAME='MOS_DEPLOY'"
+CUSTOM_PUBLIC_NET_NAME=""
ewriteln "export MY_PROJFOLDER=/artifacts"
# NS & CLUSTER
@@ -154,12 +155,28 @@
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"
- cmd="openstack network list --external -c Name -f value | head -n1"
- echo "# Running 'kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- sh -c '${cmd}'"
- vPUBNET=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- sh -c "${cmd}")
- echo "-> 'openstack network list --external -c Name -f value | head -n1': '${vPUBNET}'"
- ewriteln "export TEMPEST_CUSTOM_PUBLIC_NET=${vPUBNET}"
+ if [ -n "${CUSTOM_PUBLIC_NET_NAME:-}" ]; then
+ # if CUSTOM_PUBLIC_NET_NAME is set to some specific net, check it is present on the cloud
+ echo "# Checking that the external network ${CUSTOM_PUBLIC_NET_NAME} is present on the cloud"
+ cmd="openstack network show ${CUSTOM_PUBLIC_NET_NAME} -c id -f value 2>/dev/null"
+ echo "# Running 'kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- sh -c '${cmd}'"
+ network_exists=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec "${keystone_pod}" -c keystone-client --stdin -- sh -c "${cmd}")
+ if [ -n "$network_exists" ]; then
+ echo "# Setting TEMPEST_CUSTOM_PUBLIC_NET to ${CUSTOM_PUBLIC_NET_NAME}"
+ ewriteln "export TEMPEST_CUSTOM_PUBLIC_NET=${CUSTOM_PUBLIC_NET_NAME}"
+ else
+ echo "The custom external (floating) network ${CUSTOM_PUBLIC_NET_NAME} is not found on the cloud. Set CUSTOM_PUBLIC_NET_NAME=\"\" to automatically pick some public network."
+ exit 1
+ fi
+ else
+ # else if it is not set by the QA engineer, let's extract the first external network and use it
+ echo "# Extracting network: taking the first found external network"
+ cmd="openstack network list --external -c Name -f value | head -n1"
+ echo "# Running 'kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- sh -c '${cmd}'"
+ vPUBNET=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- sh -c "${cmd}")
+ echo "-> 'openstack network list --external -c Name -f value | head -n1': '${vPUBNET}'"
+ ewriteln "export TEMPEST_CUSTOM_PUBLIC_NET=${vPUBNET}"
+ fi
echo "# Extracting volume types"
cmd_all="openstack volume type list -f value -c Name"
@@ -170,9 +187,9 @@
echo "# Default volume type used: ${vVOLTYPE}"
ewriteln "export TEMPEST_CUSTOM_VOLUME_TYPE=${vVOLTYPE}"
# hardcoded values
- ewriteln "export TEMPEST_CUSTOM_FLAVOR=cvp.tiny"
- ewriteln "export TEMPEST_CUSTOM_IMAGE=cvp.cirros.61"
- ewriteln "export TEMPEST_CUSTOM_IMAGE_ALT=cvp.cirros.62"
+ ewriteln "# export TEMPEST_CUSTOM_FLAVOR=cvp.tiny"
+ ewriteln "# export TEMPEST_CUSTOM_IMAGE=cvp.cirros.61"
+ ewriteln "# export TEMPEST_CUSTOM_IMAGE_ALT=cvp.cirros.62"
#prepare tempest custom yaml
cp /opt/res-files/k8s/yamls/tempest_custom.yaml.clean $MY_PROJFOLDER/yamls/tempest_custom.yaml
ewriteln 'export TEMPEST_CUSTOM_PARAMETERS=$(cat $MY_PROJFOLDER/yamls/tempest_custom.yaml)'
diff --git a/k8s/workspace/update-openstack-resources.sh b/k8s/workspace/update-openstack-resources.sh
index 1998169..75d1216 100644
--- a/k8s/workspace/update-openstack-resources.sh
+++ b/k8s/workspace/update-openstack-resources.sh
@@ -1,6 +1,8 @@
#!/bin/bash
+echo "Sourcing $MY_PROJFOLDER/env.sh"
+. $MY_PROJFOLDER/env.sh
if [ -z ${TEMPEST_CUSTOM_PUBLIC_NET+x} ]; then
- echo "# WARNING: Public network is empty"
+ echo "# WARNING: Public network is empty, please export its name to TEMPEST_CUSTOM_PUBLIC_NET environment variable to use some specific external net in case of several networks. Otherwise random external network will be used."
fi
# mosrc
. $MY_PROJFOLDER/envs/mosrc
@@ -17,10 +19,10 @@
echo " "
kubectl exec toolset --stdin -n qa-space -- bash -c "cat /artifacts/cmp-check/cvp.manifest"
else
- echo "# Creating openstack resources"
+ echo "# Creating openstack resources"
echo " "
kubectl exec toolset --stdin -n qa-space -- bash -c "mkdir /artifacts/cmp-check"
- kubectl exec toolset --tty --stdin -n qa-space -- bash -c "cd /artifacts/cmp-check; bash /opt/cmp-check/prepare.sh -w \$(pwd)"
+ kubectl exec toolset --tty --stdin -n qa-space -- bash -c "cd /artifacts/cmp-check; export CUSTOM_PUBLIC_NET_NAME="${TEMPEST_CUSTOM_PUBLIC_NET:-}"; bash /opt/cmp-check/prepare.sh -w \$(pwd)"
fi
#
@@ -32,12 +34,12 @@
echo "# Getting network details"
netid=$(kubectl exec toolset --stdin -n qa-space -- openstack network show ${TEMPEST_CUSTOM_PUBLIC_NET} -c id -f value)
subnetid=$(kubectl exec toolset --stdin -n qa-space -- openstack subnet list -f value | grep ${netid} | cut -d' ' -f1)
-echo "# image_ref_name -> ${cirros61_name}"
-sed -i "s/image_ref_name/${cirros61_name}/g" $MY_PROJFOLDER/yamls/tempest_custom.yaml
-echo "# image_ref_uuid -> ${cirros61_id}"
-sed -i "s/image_ref_uuid/${cirros61_id}/g" $MY_PROJFOLDER/yamls/tempest_custom.yaml
-echo "# image_ref_alt_uuid -> ${cirros62_id}"
-sed -i "s/image_ref_alt_uuid/${cirros62_id}/g" $MY_PROJFOLDER/yamls/tempest_custom.yaml
+#echo "# image_ref_name -> ${cirros61_name}"
+#sed -i "s/image_ref_name/${cirros61_name}/g" $MY_PROJFOLDER/yamls/tempest_custom.yaml
+#echo "# image_ref_uuid -> ${cirros61_id}"
+#sed -i "s/image_ref_uuid/${cirros61_id}/g" $MY_PROJFOLDER/yamls/tempest_custom.yaml
+#echo "# image_ref_alt_uuid -> ${cirros62_id}"
+#sed -i "s/image_ref_alt_uuid/${cirros62_id}/g" $MY_PROJFOLDER/yamls/tempest_custom.yaml
echo "# s/public_subnet_uuid/ -> ${subnetid}"
sed -i "s/public_subnet_uuid/${subnetid}/g" $MY_PROJFOLDER/yamls/tempest_custom.yaml
echo "# s/public_net_uuid/ -> ${netid}"
diff --git a/k8s/yamls/tempest_custom.yaml.clean b/k8s/yamls/tempest_custom.yaml.clean
index fdcb2f9..0c48f3a 100644
--- a/k8s/yamls/tempest_custom.yaml.clean
+++ b/k8s/yamls/tempest_custom.yaml.clean
@@ -6,24 +6,11 @@
identity:
disable_ssl_certificate_validation: true
compute:
- fixed_network_name: cvp.net.1
- flavor_ref: 1
- flavor_ref_alt: 2
- image_ref: image_ref_uuid
- image_ref_alt: image_ref_alt_uuid
- min_compute_nodes: 3
volume_device_name: vdb
compute_volume_common_az: nova
-object-storage:
- api_prefix: swift/
- endpoint_type: internal
heat_plugin:
- fixed_network_name: cvp.net.1
floating_network_name: public_net_name
network_for_ssh: public_net_name
- fixed_subnet_name: cvp.subnet.1
- image_ref: image_ref_name
- minimal_image_ref: image_ref_name
network:
subnet_id: public_subnet_uuid
public_network_id: public_net_uuid
@@ -31,18 +18,9 @@
network-feature-enabled:
floating_ips: true
validation:
- run_validation: true
ssh_timeout: 30
connect_timeout: 10
ping_timeout: 10
- image_ssh_user: cirros
- image_alt_ssh_user: cirros
- image_ssh_password: gocubsgo
- image_alt_ssh_password: gocubsgo
- ssh_key_type: ecdsa
-octavia:
- availability_zone: nova
- availability_zone2: nova
volume:
volume_type: volume_type_name
- volume_type_multiattach: volume_type_name
+ volume_type_multiattach: volume_type_name
\ No newline at end of file
diff --git a/k8s/yamls/tempest_custom.yaml.example b/k8s/yamls/tempest_custom.yaml.example
new file mode 100644
index 0000000..e105121
--- /dev/null
+++ b/k8s/yamls/tempest_custom.yaml.example
@@ -0,0 +1,45 @@
+auth:
+ tempest_roles: creator
+ admin_username: cvp.admin
+ admin_project_name: cvp.project
+ admin_password: mcp1234
+identity:
+ disable_ssl_certificate_validation: true
+compute:
+ fixed_network_name: cvp.net.1
+ flavor_ref: 1
+ flavor_ref_alt: 2
+ image_ref: image_ref_uuid
+ image_ref_alt: image_ref_alt_uuid
+ min_compute_nodes: 3
+ volume_device_name: vdb
+ compute_volume_common_az: nova
+object-storage:
+ endpoint_type: internal
+heat_plugin:
+ fixed_network_name: cvp.net.1
+ floating_network_name: public_net_name
+ network_for_ssh: public_net_name
+ fixed_subnet_name: cvp.subnet.1
+network:
+ subnet_id: public_subnet_uuid
+ public_network_id: public_net_uuid
+ floating_network_name: public_net_name
+network-feature-enabled:
+ floating_ips: true
+validation:
+ run_validation: true
+ ssh_timeout: 30
+ connect_timeout: 10
+ ping_timeout: 10
+ image_ssh_user: cirros
+ image_alt_ssh_user: cirros
+ image_ssh_password: gocubsgo
+ image_alt_ssh_password: gocubsgo
+ ssh_key_type: ecdsa
+octavia:
+ availability_zone: nova
+ availability_zone2: nova
+volume:
+ volume_type: volume_type_name
+ volume_type_multiattach: volume_type_name
diff --git a/scripts/prepare.sh b/scripts/prepare.sh
index 85d2e40..bc43263 100644
--- a/scripts/prepare.sh
+++ b/scripts/prepare.sh
@@ -294,9 +294,25 @@
process_cmds
# get external network name
- external=$(openstack network list --external -c Name -f value | head -n1)
- echo router set ${router} --external-gateway ${external} >>${cmds}
- process_cmds
+ if [ -n "${CUSTOM_PUBLIC_NET_NAME:-}" ]; then
+ # if CUSTOM_PUBLIC_NET_NAME is set to some specific net, check it is present on the cloud and use it
+ echo "# Checking that the external network ${CUSTOM_PUBLIC_NET_NAME} is present on the cloud"
+ network_exists=$(openstack network show "$CUSTOM_PUBLIC_NET_NAME" -c id -f value 2>/dev/null)
+ if [ -n "$network_exists" ]; then
+ echo router set ${router} --external-gateway ${CUSTOM_PUBLIC_NET_NAME} >>${cmds}
+ process_cmds
+ else
+ echo "# The network ${CUSTOM_PUBLIC_NET_NAME} does not exist"
+ CUSTOM_PUBLIC_NET_NAME=""
+ fi
+ fi
+ if [ -z "${CUSTOM_PUBLIC_NET_NAME:-}" ]; then
+ echo "# Selecting a random external network as an external gateway for the router"
+ # if the custom network is not set or is empty, select the first external network
+ external=$(openstack network list --external -c Name -f value | head -n1)
+ echo router set ${router} --external-gateway ${external} >>${cmds}
+ process_cmds
+ fi
}
function _get_image() {