diff --git a/tests/run.yml b/tests/run.yml index c24044ac78..a147617db8 100644 --- a/tests/run.yml +++ b/tests/run.yml @@ -222,6 +222,13 @@ chdir: "{{ kolla_ansible_src_dir }}" when: scenario == "ironic" + - name: Run test-masakari.sh script + script: + cmd: test-masakari.sh + executable: /bin/bash + chdir: "{{ kolla_ansible_src_dir }}" + when: scenario == "masakari" + - name: Run reconfigure.sh script script: cmd: reconfigure.sh diff --git a/tests/templates/globals-default.j2 b/tests/templates/globals-default.j2 index c61a08e700..c016e30983 100644 --- a/tests/templates/globals-default.j2 +++ b/tests/templates/globals-default.j2 @@ -83,3 +83,7 @@ enable_barbican: "yes" enable_ironic: "yes" ironic_dnsmasq_dhcp_range: "10.42.0.2,10.42.0.254" {% endif %} + +{% if scenario == "masakari" %} +enable_masakari: "yes" +{% endif %} diff --git a/tests/templates/inventory.j2 b/tests/templates/inventory.j2 index 1051592032..8b5633b28a 100644 --- a/tests/templates/inventory.j2 +++ b/tests/templates/inventory.j2 @@ -381,6 +381,16 @@ network [manila-data:children] manila +# Masakari +[masakari-api:children] +control + +[masakari-engine:children] +control + +[masakari-monitors:children] +compute + # Swift [swift-proxy-server:children] swift diff --git a/tests/test-masakari.sh b/tests/test-masakari.sh new file mode 100755 index 0000000000..4601a2b589 --- /dev/null +++ b/tests/test-masakari.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +set -o xtrace +set -o errexit +set -o pipefail + +# Enable unbuffered output for Ansible in Jenkins. +export PYTHONUNBUFFERED=1 + +function test_masakari_logged { + + # Source OpenStack credentials + . /etc/kolla/admin-openrc.sh + + # Activate virtualenv to access Masakari client + . ~/openstackclient-venv/bin/activate + + # NOTE:(gtrellu) Masakari client/API has a bug which generate a mismatch + # between what the client send and what the API should received. + CLIENT_OPTS="--os-ha-api-version 1.0" + + # Get the first Nova compute + if ! HYPERVISOR=$(openstack hypervisor list -f value -c 'Hypervisor Hostname' | head -n1); then + echo "Unable to get Nova hypervisor list" + return 1 + fi + + # Create Masakari segment + if ! openstack $CLIENT_OPTS segment create test_segment auto COMPUTE; then + echo "Unable to create Masakari segment" + return 1 + fi + + # Add Nova compute to Masakari segment + if ! openstack $CLIENT_OPTS segment host create $HYPERVISOR COMPUTE SSH test_segment; then + echo "Unable to add Nova hypervisor to Masakari segment" + return 1 + fi + + # Delete Masakari segment + if ! openstack $CLIENT_OPTS segment delete test_segment; then + echo "Unable to delete Masakari segment" + return 1 + fi + + # Exit virtualenv + deactivate +} + +function test_masakari { + echo "Testing Masakari" + test_masakari_logged > /tmp/logs/ansible/test-masakari 2>&1 + result=$? + if [[ $result != 0 ]]; then + echo "Testing Masakari failed. See ansible/test-masakari for details" + else + echo "Successfully tested Masakari. See ansible/test-masakari for details" + fi + return $result +} + +test_masakari diff --git a/tools/setup_gate.sh b/tools/setup_gate.sh index e5da68d985..758214094c 100755 --- a/tools/setup_gate.sh +++ b/tools/setup_gate.sh @@ -19,6 +19,9 @@ function setup_openstack_clients { if [[ $ACTION == ironic ]]; then ~/openstackclient-venv/bin/pip install python-ironicclient fi + if [[ $ACTION == masakari ]]; then + ~/openstackclient-venv/bin/pip install python-masakariclient + fi } function setup_config { @@ -58,6 +61,9 @@ EOF if [[ $ACTION == "ironic" ]]; then GATE_IMAGES+=",dnsmasq,ironic,iscsid" fi + if [[ $ACTION == "masakari" ]]; then + GATE_IMAGES+=",masakari" + fi cat <