From d4de1d752056d9c56163a9cfb366234c9883f589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Wed, 14 Aug 2019 13:14:31 +0200 Subject: [PATCH] CI: Zun jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Test Zun on CentOS too - Make etcd change also trigger Zun jobs (like kuryr and zun) - Test multinode Zun deployments instead of AIO (more likely to break) - In Zun scenario, stop configuring docker for legacy swarm mode (Zun is no swarm) - Separate test-zun.sh testing script - Show appcontainer to see which node it has been started on Change-Id: I289b1009fe00aedb9b78cbd83298b14da5fd9670 Depends-On: https://review.opendev.org/676736 Signed-off-by: Radosław Piliszek --- tests/run.yml | 14 ++++++++ tests/templates/globals-default.j2 | 2 +- tests/test-openstack.sh | 24 -------------- tests/test-zun.sh | 52 ++++++++++++++++++++++++++++++ zuul.d/base.yaml | 10 ++++++ zuul.d/jobs.yaml | 14 +++++--- zuul.d/project.yaml | 7 ++-- 7 files changed, 90 insertions(+), 33 deletions(-) create mode 100755 tests/test-zun.sh diff --git a/tests/run.yml b/tests/run.yml index a147617db8..527c09cdcd 100644 --- a/tests/run.yml +++ b/tests/run.yml @@ -208,6 +208,13 @@ ACTION: "{{ scenario }}" when: scenario not in ['ironic', 'scenario_nfv'] + - name: Run test-zun.sh script + shell: + cmd: tests/test-zun.sh + executable: /bin/bash + chdir: "{{ kolla_ansible_src_dir }}" + when: "{{ 'zun' in scenario }}" + - name: Run test-scenario-nfv.sh script script: cmd: test-scenario-nfv.sh @@ -338,6 +345,13 @@ chdir: "{{ kolla_ansible_src_dir }}" environment: ACTION: "{{ scenario }}" + + - name: Run test-zun.sh script + shell: + cmd: tests/test-zun.sh + executable: /bin/bash + chdir: "{{ kolla_ansible_src_dir }}" + when: "{{ 'zun' in scenario }}" when: is_upgrade # Bifrost testing. diff --git a/tests/templates/globals-default.j2 b/tests/templates/globals-default.j2 index c016e30983..8bc33f382a 100644 --- a/tests/templates/globals-default.j2 +++ b/tests/templates/globals-default.j2 @@ -68,7 +68,7 @@ enable_cinder_backend_lvm: "yes" enable_zun: "yes" enable_kuryr: "yes" enable_etcd: "yes" -docker_custom_option: " -H unix:///var/run/docker.sock -H tcp://{{ api_interface_address }}:2375 --cluster-store=etcd://{{ api_interface_address }}:2379 --cluster-advertise={{ api_interface_address }}:2375" +docker_configure_for_zun: "yes" {% endif %} {% if scenario == "scenario_nfv" %} diff --git a/tests/test-openstack.sh b/tests/test-openstack.sh index 37724b8c14..ae2dea5903 100755 --- a/tests/test-openstack.sh +++ b/tests/test-openstack.sh @@ -69,30 +69,6 @@ function test_openstack_logged { echo "TESTING: Server deletion" openstack server delete --wait kolla_boot_test echo "SUCCESS: Server deletion" - - if echo $ACTION | grep -q "zun"; then - echo "TESTING: Zun" - openstack appcontainer service list - openstack appcontainer host list - openstack subnet set --no-dhcp demo-subnet - sudo docker pull alpine - sudo docker save alpine | openstack image create alpine --public --container-format docker --disk-format raw - openstack appcontainer run --name test alpine sleep 1000 - attempt=1 - while [[ $(openstack appcontainer show test -f value -c status) != "Running" ]]; do - echo "Container not running yet" - attempt=$((attempt+1)) - if [[ $attempt -eq 10 ]]; then - echo "Container failed to start" - openstack appcontainer show test - return 1 - fi - sleep 10 - done - openstack appcontainer list - openstack appcontainer delete --force --stop test - echo "SUCCESS: Zun" - fi } function test_openstack { diff --git a/tests/test-zun.sh b/tests/test-zun.sh new file mode 100755 index 0000000000..d2d3c265ce --- /dev/null +++ b/tests/test-zun.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -o xtrace +set -o errexit + +export PYTHONUNBUFFERED=1 + +function test_zun_logged { + . /etc/kolla/admin-openrc.sh + . ~/openstackclient-venv/bin/activate + + echo "TESTING: Zun" + openstack appcontainer service list + openstack appcontainer host list + openstack subnet set --no-dhcp demo-subnet + sudo docker pull alpine + sudo docker save alpine | openstack image create alpine --public --container-format docker --disk-format raw + openstack appcontainer run --name test alpine sleep 1000 + attempt=1 + while [[ $(openstack appcontainer show test -f value -c status) != "Running" ]]; do + echo "Container not running yet" + attempt=$((attempt+1)) + if [[ $attempt -eq 10 ]]; then + echo "Container failed to start" + openstack appcontainer show test + return 1 + fi + sleep 10 + done + openstack appcontainer list + openstack appcontainer show test + openstack appcontainer delete --force --stop test + echo "SUCCESS: Zun" +} + +function test_zun { + echo "Testing Zun" + log_file=/tmp/logs/ansible/test-zun + if [[ -f $log_file ]]; then + log_file=${log_file}-upgrade + fi + test_zun_logged > $log_file 2>&1 + result=$? + if [[ $result != 0 ]]; then + echo "Testing Zun failed. See ansible/test-zun for details" + else + echo "Successfully tested Zun. See ansible/test-zun for details" + fi + return $result +} + +test_zun diff --git a/zuul.d/base.yaml b/zuul.d/base.yaml index 87e7c24aae..b910d83880 100644 --- a/zuul.d/base.yaml +++ b/zuul.d/base.yaml @@ -48,3 +48,13 @@ - ^tests/test-ironic.sh vars: scenario: ironic + +- job: + name: kolla-ansible-zun-base + parent: kolla-ansible-base + voting: false + files: + - ^ansible/roles/(zun|kuryr|etcd)/ + - ^tests/test-zun.sh + vars: + scenario: zun diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 113cf27193..d21ea388e6 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -149,15 +149,21 @@ vars: base_distro: centos +- job: + name: kolla-ansible-centos-source-zun + parent: kolla-ansible-zun-base + nodeset: kolla-ansible-centos-multi + vars: + base_distro: centos + install_type: source + - job: name: kolla-ansible-ubuntu-source-zun - parent: kolla-ansible-base - nodeset: kolla-ansible-bionic - voting: false + parent: kolla-ansible-zun-base + nodeset: kolla-ansible-bionic-multi vars: base_distro: ubuntu install_type: source - scenario: zun - job: name: kolla-ansible-centos-source-scenario-nfv diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index c0648870bd..0992a9905e 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -22,10 +22,8 @@ files: ^ansible\/roles\/(cinder|iscsi)\/.* - kolla-ansible-bifrost-centos-source: files: ^ansible\/roles\/bifrost\/.* - - kolla-ansible-ubuntu-source-zun: - files: - - ^ansible/roles/(zun|kuryr)/ - - ^tests/test-openstack.sh + - kolla-ansible-centos-source-zun + - kolla-ansible-ubuntu-source-zun - kolla-ansible-centos-source-scenario-nfv: files: - ^ansible/roles/(barbican|heat|mistral|redis|tacker)/ @@ -57,6 +55,7 @@ periodic: jobs: - kolla-ansible-bifrost-centos-source + - kolla-ansible-centos-source-zun - kolla-ansible-ubuntu-source-zun - kolla-ansible-ubuntu-source-masakari - kolla-ansible-centos-source-masakari