diff --git a/.zuul.yaml b/.zuul.yaml index d1da3a4a..505d2d2c 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -67,7 +67,6 @@ # parent job variant during job freeze when child jobs are on other branches. description: | Run openstack collections functional tests against a devstack with Octavia plugin enabled - pre-run: ci/playbooks/get_amphora_tarball.yaml # Do not set job.override-checkout or job.required-projects.override-checkout in base job because # else Zuul will use this branch when matching variants for parent jobs during job freeze required-projects: @@ -93,10 +92,6 @@ o-cw: true o-hk: true o-hm: true - devstack_localrc: - OCTAVIA_AMP_IMAGE_FILE: "/tmp/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2" - OCTAVIA_AMP_IMAGE_SIZE: 3 - OCTAVIA_AMP_IMAGE_NAME: "test-only-amphora-x64-haproxy-ubuntu-bionic" - job: name: ansible-collections-openstack-functional-devstack-octavia diff --git a/ci/playbooks/get_amphora_tarball.yaml b/ci/playbooks/get_amphora_tarball.yaml deleted file mode 100644 index 1fcbcdad..00000000 --- a/ci/playbooks/get_amphora_tarball.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- hosts: all - tasks: - - name: Download amphora tarball - get_url: - url: "https://tarballs.openstack.org/octavia/test-images/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2" - dest: /tmp/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2 diff --git a/ci/roles/floating_ip/tasks/main.yml b/ci/roles/floating_ip/tasks/main.yml index 2eb825cc..2d844580 100644 --- a/ci/roles/floating_ip/tasks/main.yml +++ b/ci/roles/floating_ip/tasks/main.yml @@ -1,4 +1,15 @@ --- +- name: List all images + openstack.cloud.image_info: + cloud: "{{ cloud }}" + register: images + +- name: Identify CirrOS image name + set_fact: + image_name: "{{ images.images|community.general.json_query(query)|first }}" + vars: + query: "[?starts_with(name, 'cirros')].name" + - name: Gather information about public network openstack.cloud.networks_info: cloud: "{{ cloud }}" diff --git a/ci/roles/loadbalancer/tasks/main.yml b/ci/roles/loadbalancer/tasks/main.yml index 1c62eefc..70ea6b35 100644 --- a/ci/roles/loadbalancer/tasks/main.yml +++ b/ci/roles/loadbalancer/tasks/main.yml @@ -1,5 +1,25 @@ - --- +- name: Download Amphora tarball + get_url: + url: "https://tarballs.openstack.org/octavia/test-images/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2" + dest: /tmp/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2 + +- name: Upload Amphora image for Octavia to test load balancers + openstack.cloud.image: + cloud: "{{ cloud }}" + container_format: bare + disk_format: qcow2 + filename: /tmp/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2 + is_public: false + name: test-only-amphora-x64-haproxy-ubuntu-bionic + owner: service + properties: + hw_architecture: x86_64 + hw_rng_model: virtio + state: present + tags: + - amphora + - name: Create network {{ network_name }} for LB openstack.cloud.network: cloud: "{{ cloud }}" diff --git a/ci/roles/server/tasks/main.yml b/ci/roles/server/tasks/main.yml index 6362523c..6ffde756 100644 --- a/ci/roles/server/tasks/main.yml +++ b/ci/roles/server/tasks/main.yml @@ -1,4 +1,15 @@ --- +- name: List all images + openstack.cloud.image_info: + cloud: "{{ cloud }}" + register: images + +- name: Identify CirrOS image name + set_fact: + image_name: "{{ images.images|community.general.json_query(query)|first }}" + vars: + query: "[?starts_with(name, 'cirros')].name" + - name: Create network for server openstack.cloud.network: cloud: "{{ cloud }}" diff --git a/ci/roles/server_metadata/tasks/main.yml b/ci/roles/server_metadata/tasks/main.yml index 6fe4941b..16d24c37 100644 --- a/ci/roles/server_metadata/tasks/main.yml +++ b/ci/roles/server_metadata/tasks/main.yml @@ -1,4 +1,15 @@ --- +- name: List all images + openstack.cloud.image_info: + cloud: "{{ cloud }}" + register: images + +- name: Identify CirrOS image name + set_fact: + image_name: "{{ images.images|community.general.json_query(query)|first }}" + vars: + query: "[?starts_with(name, 'cirros')].name" + - name: Create test server openstack.cloud.server: cloud: "{{ cloud }}" diff --git a/ci/run-ansible-tests-collection.sh b/ci/run-ansible-tests-collection.sh index cfde389a..9ee78097 100755 --- a/ci/run-ansible-tests-collection.sh +++ b/ci/run-ansible-tests-collection.sh @@ -95,12 +95,6 @@ if [ "$USE_DEV" -eq 1 ]; then source "$ENVDIR/ansible/hacking/env-setup" fi -# Run the shade Ansible tests -tag_opt="" -if [ -n "$TAGS" ]; then - tag_opt="--tags $TAGS" -fi - # Loop through all ANSIBLE_VAR_ environment variables to allow passing the further for var in $(env | grep -e '^ANSIBLE_VAR_'); do VAR_NAME=${var%%=*} # split variable name from value @@ -110,39 +104,20 @@ for var in $(env | grep -e '^ANSIBLE_VAR_'); do ANSIBLE_VARS+="${ANSIBLE_VAR_NAME}=${ANSIBLE_VAR_VALUE} " # concat variables done -# Until we have a module that lets us determine the image we want from -# within a playbook, we have to find the image here and pass it in. -# We use the openstack client instead of nova client since it can use clouds.yaml. -IMAGE=$(openstack "--os-cloud=$CLOUD" image list -f value -c Name | grep cirros | grep -v -e ramdisk -e kernel) -if [ -z "$IMAGE" ]; then - echo "Failed to find Cirros image" - exit 3 -fi - -# In case of Octavia enabled: -_octavia_image_path="/tmp/test-only-amphora-x64-haproxy-ubuntu-bionic.qcow2" -if systemctl list-units --full -all | grep -Fq "devstack@o-api.service" && \ - test -f "$_octavia_image_path"; then - # Upload apmhora image for Octavia to test load balancers - OCTAVIA_AMP_IMAGE_FILE=${OCTAVIA_AMP_IMAGE_FILE:-"$_octavia_image_path"} - OCTAVIA_AMP_IMAGE_NAME=${OCTAVIA_AMP_IMAGE_NAME:-"test-only-amphora-x64-haproxy-ubuntu-bionic"} - OCTAVIA_AMP_IMAGE_SIZE=${OCTAVIA_AMP_IMAGE_SIZE:-3} - openstack "--os-cloud=$CLOUD" image create \ - --container-format bare \ - --disk-format qcow2 \ - --private \ - --file "$OCTAVIA_AMP_IMAGE_FILE" \ - --project service "$OCTAVIA_AMP_IMAGE_NAME" - openstack "--os-cloud=$CLOUD" image set --tag amphora "$OCTAVIA_AMP_IMAGE_NAME" - # End of Octavia preparement -else - # Run all tasks except for loadbalancer tasks - tag_opt+=" --skip-tags loadbalancer" -fi - # Discover openstacksdk version SDK_VER=$(python -c "import openstack; print(openstack.version.__version__)") +# Choose integration tests +tag_opt="" +if [ -n "$TAGS" ]; then + tag_opt="--tags $TAGS" +fi + +if ! systemctl is-enabled devstack@o-api.service 2>&1; then + # Run all tasks except for loadbalancer if Octavia is not available + tag_opt+=" --skip-tags loadbalancer" +fi + cd ci/ # Run tests @@ -150,5 +125,5 @@ set -o pipefail # shellcheck disable=SC2086 ANSIBLE_COLLECTIONS_PATHS=$TEST_COLLECTIONS_PATHS ansible-playbook \ -vvv ./run-collection.yml \ - -e "sdk_version=${SDK_VER} cloud=${CLOUD} cloud_alt=${CLOUD_ALT} image_name=${IMAGE} ${ANSIBLE_VARS}" \ + -e "sdk_version=${SDK_VER} cloud=${CLOUD} cloud_alt=${CLOUD_ALT} ${ANSIBLE_VARS}" \ ${tag_opt} 2>&1 | sudo tee /opt/stack/logs/test_output.log