From bd9f0c0723a8a4720eafc939530d606feaff226e Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 6 Aug 2018 19:28:33 +0100 Subject: [PATCH] Clean up tests a bit 1. Remove tests/test-configure-octavia.yml because the 'shade' package does not need to be installed again - this is already done by the role test preparation. 2. Remove the key generation as the keys are already generated in the common tests playbook 'test-prepare-keys.yml'. 3. Add some spacing between tasks to make it more readable. 4. Implement the extra packages needed in test-requirements.txt instead of trying to use a task to install them, because doing it in Ansible makes understanding the venv in relation to the inventory complicated.. 5. Move the vars_files argument to the top of the play to make it easier to find and more uniform with other plays in OSA. 6. Switch from using octavia_ansible_endpoint_type to a hard-coded endpoint, then remove the octavia_ansible_endpoint_type var. 7. Switch from using the 'endpoint_type' argument for the openstack modules to using the more modern 'interface' argument. 8. Remove the 'run_once' argument on the 'Upload key to nova' task because only localhost is targeted, so the argument is moot. 9. Remove the 'Set VIP fact' task in favor of just using the 'vip_output' register in the 'Test the Listener' task. Setting a fact is pointless. 10. To help the existing patches pass, we add python-pip to the distro packages. This will be reverted later once the required changes to remove this requirement have merged. Depends-On: https://review.openstack.org/589248 Change-Id: I46962090f7baf4227e838e125fd318245f2bcb85 --- test-requirements.txt | 7 ++++ tests/test-configure-octavia.yml | 34 ------------------- tests/test-octavia.yml | 57 ++++++++++---------------------- tests/test.yml | 1 - vars/ubuntu.yml | 7 ++-- 5 files changed, 28 insertions(+), 78 deletions(-) create mode 100644 test-requirements.txt delete mode 100644 tests/test-configure-octavia.yml diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..5889b287 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,7 @@ +# These requirements are used in addition to the test-requirements.txt +# set out in the openstack-ansible-tests repository. Requirements here +# should *only* be for the purpose of including in the runtime venv +# for test purposes. Anything that is destined to be used in production +# should not be here, but instead in a *_pip_packages list. + +python-octaviaclient>=1.6.0 # Apache-2.0 diff --git a/tests/test-configure-octavia.yml b/tests/test-configure-octavia.yml deleted file mode 100644 index 6c91f823..00000000 --- a/tests/test-configure-octavia.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -# Copyright 2016, Rackspace US, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: Setup localhost requirements - hosts: localhost - become: True - gather_facts: True - tasks: - - name: Install pip requirements - pip: - name: "shade" - state: "{{ octavia_pip_package_state }}" - extra_args: >- - {{ octavia_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} - {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} - {{ pip_install_options | default('') }} - register: install_packages - until: install_packages is success - retries: 5 - delay: 2 - vars_files: - - common/test-vars.yml diff --git a/tests/test-octavia.yml b/tests/test-octavia.yml index cc97583d..1013e7a8 100644 --- a/tests/test-octavia.yml +++ b/tests/test-octavia.yml @@ -15,14 +15,16 @@ - name: Test Octavia hosts: localhost - user: root - gather_facts: false + connection: local + gather_facts: no + vars_files: + - common/test-vars.yml vars: + ansible_python_interpreter: "{{ ansible_playbook_python }}" octavia_service_user_name: octavia octavia_service_project_name: service octavia_service_user_domain_id: default octavia_service_project_domain_id: default - octavia_ansible_endpoint_type: internal env: OS_ENDPOINT_TYPE: internalURL OS_INTERFACE: internalURL @@ -38,26 +40,6 @@ OS_IDENTITY_API_VERSION: 3 OS_AUTH_VERSION: 3 tasks: - - name: Install pip requirements - pip: - name: "{{ item }}" - state: "{{ octavia_pip_package_state }}" - extra_args: >- - {{ octavia_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} - {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} - {{ pip_install_options | default('') }} - register: install_packages - until: install_packages is success - retries: 5 - delay: 2 - with_items: - - "python-neutronclient" - - "python-glanceclient" - - "shade" - - "python-octaviaclient" - - "python-openstackclient" - - "cmd2<0.9.0" # >=0.9.0 is python3 only - - name: Ensure public network exists os_network: auth: @@ -67,12 +49,13 @@ project_name: "{{ octavia_service_project_name }}" user_domain_name: "{{ octavia_service_user_domain_id }}" project_domain_name: "{{ octavia_service_project_domain_id }}" - endpoint_type: "{{ octavia_ansible_endpoint_type }}" + interface: admin state: present name: "public" provider_network_type: "flat" provider_physical_network: "flat" external: True + - name: Ensure public subnet exists os_subnet: auth: @@ -82,18 +65,12 @@ project_name: "{{ octavia_service_project_name }}" user_domain_name: "{{ octavia_service_user_domain_id }}" project_domain_name: "{{ octavia_service_project_domain_id }}" - endpoint_type: "{{ octavia_ansible_endpoint_type }}" + interface: admin state: present network_name: "public" name: "public-subnet" cidr: "10.1.3.0/24" - - name: Create ssh-key - shell: > - cat /dev/zero | ssh-keygen -q -N "" - args: - creates: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa" - tags: - - skip_ansible_lint + - name: Upload key to nova os_keypair: auth: @@ -103,11 +80,10 @@ project_name: "{{ octavia_service_project_name }}" user_domain_name: "{{ octavia_service_user_domain_id }}" project_domain_name: "{{ octavia_service_project_domain_id }}" - endpoint_type: "{{ octavia_ansible_endpoint_type }}" + interface: admin state: present name: "octavia_key" public_key_file: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa.pub" - run_once: true - name: Create a loadbalancer shell: > @@ -115,6 +91,7 @@ environment: "{{ env }}" tags: - skip_ansible_lint + - name: Wait until LB is active shell: > openstack loadbalancer show test-lb -c provisioning_status -f value @@ -126,12 +103,14 @@ delay: 10 tags: - skip_ansible_lint + - name: Create a listener shell: > openstack loadbalancer listener create --protocol HTTP --protocol-port 80 --name listener test-lb environment: "{{ env }}" tags: - skip_ansible_lint + - name: Wait until Listener is active shell: > openstack loadbalancer show test-lb -c provisioning_status -f value @@ -143,6 +122,7 @@ delay: 10 tags: - skip_ansible_lint + - name: Run Show (for debugging) shell: > openstack loadbalancer show test-lb @@ -159,14 +139,13 @@ register: vip_output tags: - skip_ansible_lint - - name: Set VIP fact - set_fact: - vip: "{{ vip_output.stdout }}" + - name: Test the Listener uri: - url: "http://{{ vip }}" + url: "http://{{ vip_output.stdout }}" status_code: 503 when: test_octavia_amphora | bool + - name: Delete LoadBalancer shell: > openstack loadbalancer delete --cascade test-lb @@ -177,5 +156,3 @@ delay: 15 tags: - skip_ansible_lint - vars_files: - - common/test-vars.yml diff --git a/tests/test.yml b/tests/test.yml index 6e60689e..4b6f6e20 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -35,7 +35,6 @@ - include: common/test-install-nova.yml # Install Octavia -- include: test-configure-octavia.yml - include: test-install-octavia.yml # Test diff --git a/vars/ubuntu.yml b/vars/ubuntu.yml index 6d1f6b35..9834724f 100644 --- a/vars/ubuntu.yml +++ b/vars/ubuntu.yml @@ -17,7 +17,8 @@ cache_timeout: 600 octavia_distro_packages: - - iptables-persistent - - netfilter-persistent - - libxml2-dev - git + - iptables-persistent + - libxml2-dev + - netfilter-persistent + - python-pip