diff --git a/rabbitmq/templates/bin/_rabbitmq-test.sh.tpl b/rabbitmq/templates/bin/_rabbitmq-test.sh.tpl index d17ef1620..84b9e7f9a 100644 --- a/rabbitmq/templates/bin/_rabbitmq-test.sh.tpl +++ b/rabbitmq/templates/bin/_rabbitmq-test.sh.tpl @@ -30,6 +30,24 @@ RABBITMQ_ADMIN_USERNAME=`echo $RABBITMQ_ADMIN_CONNECTION | awk -F'[@]' '{print $ RABBITMQ_ADMIN_PASSWORD=`echo $RABBITMQ_ADMIN_CONNECTION | awk -F'[@]' '{print $1}' \ | awk -F'[//:]' '{print $5}'` +function rabbit_check_node_count () { + echo "Checking node count " + NODES_IN_CLUSTER=$(rabbitmqadmin \ + --host="${RABBIT_HOSTNAME}" \ + --port="${RABBIT_PORT}" \ + --username="${RABBITMQ_ADMIN_USERNAME}" \ + --password="${RABBITMQ_ADMIN_PASSWORD}" \ + list nodes -f bash | wc -w) + if [ "$NODES_IN_CLUSTER" -eq "$RABBIT_REPLICA_COUNT" ]; then + echo "Number of nodes in cluster match number of desired pods ($NODES_IN_CLUSTER)" + else + echo "Number of nodes in cluster ($NODES_IN_CLUSTER) does not match number of desired pods ($RABBIT_REPLICA_COUNT)" + exit 1 + fi +} +# Check node count +rabbit_check_node_count + function rabbit_find_paritions () { echo "Checking cluster partitions" PARTITIONS=$(rabbitmqadmin \ diff --git a/rabbitmq/templates/pod-test.yaml b/rabbitmq/templates/pod-test.yaml index 5fdc01eb5..cc4bddcbb 100644 --- a/rabbitmq/templates/pod-test.yaml +++ b/rabbitmq/templates/pod-test.yaml @@ -41,7 +41,9 @@ spec: {{ tuple $envAll "scripted_test" | include "helm-toolkit.snippets.image" | indent 6 }} env: - name: RABBITMQ_ADMIN_CONNECTION - value: "{{ tuple "oslo_messaging" "internal" "user" "http" $envAll | include "helm-toolkit.endpoints.authenticated_endpoint_uri_lookup" }}" + value: {{ tuple "oslo_messaging" "internal" "user" "http" $envAll | include "helm-toolkit.endpoints.authenticated_endpoint_uri_lookup" | quote }} + - name: RABBIT_REPLICA_COUNT + value: {{ $envAll.Values.pod.replicas.server | quote }} command: - /tmp/rabbitmq-test.sh volumeMounts: