From 085713af3914ed475985b82dc2ec1a72882fc697 Mon Sep 17 00:00:00 2001 From: Logan V Date: Fri, 9 Sep 2016 22:24:04 -0500 Subject: [PATCH] Add functional testing for Calico Change-Id: I2f3e3aac1da800b41055bcb82cb7c4e07a20d8e2 --- tests/ansible-role-requirements.yml | 4 -- tests/calico_inventory | 58 +++++++++++++++++++++++++++++ tests/calico_test_vars.yml | 18 +++++++++ tests/lxb_inventory | 2 + tests/ovs_inventory | 2 + tests/test-calico-functional.yml | 31 +++++++++++++++ tests/test-install-infra.yml | 8 ++++ tests/test-install-neutron.yml | 7 ++++ tests/test-neutron-functional.yml | 4 ++ tox.ini | 17 +++++++++ 10 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 tests/calico_inventory create mode 100644 tests/calico_test_vars.yml create mode 100644 tests/test-calico-functional.yml diff --git a/tests/ansible-role-requirements.yml b/tests/ansible-role-requirements.yml index 4f686169..28c2dce0 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -42,10 +42,6 @@ src: https://git.openstack.org/openstack/openstack-ansible-rabbitmq_server scm: git version: master -- name: bird - scm: git - src: https://github.com/logan2211/ansible-bird - version: master - name: etcd scm: git src: https://github.com/logan2211/ansible-etcd diff --git a/tests/calico_inventory b/tests/calico_inventory new file mode 100644 index 00000000..707decf6 --- /dev/null +++ b/tests/calico_inventory @@ -0,0 +1,58 @@ +[all] +localhost ansible_connection=local ansible_ssh_host=127.0.0.1 ansible_become=True +infra1 ansible_host=10.100.100.2 ansible_become=True ansible_user=root +openstack1 ansible_host=10.100.100.3 ansible_become=True ansible_user=root + +[physical_host] +localhost + +[all_containers] +infra1 +openstack1 + +[rabbitmq_all] +infra1 + +[galera_all] +infra1 + +[etcd_all] +infra1 + +[etcd:children] +etcd_all + +[service_all:children] +rabbitmq_all +galera_all +etcd_all + +[keystone_all] +openstack1 + +[neutron_calico_dhcp_agent] +openstack1 + +[neutron_server] +openstack1 + +[neutron_agent] +[neutron_dhcp_agent] +[neutron_linuxbridge_agent] +[neutron_openvswitch_agent] +[neutron_metering_agent] +[neutron_l3_agent] +[neutron_lbaas_agent] +[neutron_metadata_agent] + +[neutron_all:children] +neutron_agent +neutron_dhcp_agent +neutron_linuxbridge_agent +neutron_openvswitch_agent +neutron_metering_agent +neutron_l3_agent +neutron_lbaas_agent +neutron_metadata_agent +neutron_server +neutron_calico_dhcp_agent diff --git a/tests/calico_test_vars.yml b/tests/calico_test_vars.yml new file mode 100644 index 00000000..af2429aa --- /dev/null +++ b/tests/calico_test_vars.yml @@ -0,0 +1,18 @@ +--- +# Copyright 2016, Logan Vig +# +# 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. + +neutron_plugin_type: ml2.calico +neutron_provider_networks: + network_types: '' diff --git a/tests/lxb_inventory b/tests/lxb_inventory index 3699c831..c608ca47 100644 --- a/tests/lxb_inventory +++ b/tests/lxb_inventory @@ -49,6 +49,8 @@ openstack1 [neutron_server] openstack1 +[neutron_calico_dhcp_agent] + [neutron_all:children] neutron_agent neutron_dhcp_agent diff --git a/tests/ovs_inventory b/tests/ovs_inventory index 9b50fd33..6fbb33eb 100644 --- a/tests/ovs_inventory +++ b/tests/ovs_inventory @@ -49,6 +49,8 @@ openstack1 [neutron_server] openstack1 +[neutron_calico_dhcp_agent] + [neutron_all:children] neutron_agent neutron_dhcp_agent diff --git a/tests/test-calico-functional.yml b/tests/test-calico-functional.yml new file mode 100644 index 00000000..b5b927b7 --- /dev/null +++ b/tests/test-calico-functional.yml @@ -0,0 +1,31 @@ +--- +# Copyright 2016, Logan Vig +# +# 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: Ensure Calico services are running + command: pgrep -a {{ item }} + with_items: + - calico-felix + - calico-dhcp-age + +- name: Ensure that the Calico Felix agent is alive + shell: | + . /root/openrc + neutron agent-list | grep calico-felix + register: calico_felix_agent + until: calico_felix_agent.stdout.find(':-)') != -1 + when: + - groups['neutron_calico_dhcp_agent'] | length > 0 + retries: 5 + delay: 10 diff --git a/tests/test-install-infra.yml b/tests/test-install-infra.yml index cb2adc51..694f08f1 100644 --- a/tests/test-install-infra.yml +++ b/tests/test-install-infra.yml @@ -17,6 +17,11 @@ hosts: service_all user: root gather_facts: true + pre_tasks: + - name: Include Calico testing vars + include_vars: calico_test_vars.yml + when: + - groups['neutron_calico_dhcp_agent'] | length > 0 roles: - role: "rabbitmq_server" rabbitmq_cookie_token: secrete @@ -30,3 +35,6 @@ galera_wsrep_provider_options: - { option: "gcache.size", value: "32M" } galera_server_id: "{{ inventory_hostname | string_2_int }}" + - role: "etcd" + when: + - groups['neutron_calico_dhcp_agent'] | length > 0 diff --git a/tests/test-install-neutron.yml b/tests/test-install-neutron.yml index 78091ef0..ff6260a2 100644 --- a/tests/test-install-neutron.yml +++ b/tests/test-install-neutron.yml @@ -110,9 +110,16 @@ include_vars: ovs_test_vars.yml when: - groups['neutron_openvswitch_agent'] | length > 0 + - name: Include Calico testing vars + include_vars: calico_test_vars.yml + when: + - groups['neutron_calico_dhcp_agent'] | length > 0 roles: - role: "{{ rolename | basename }}" post_tasks: - include: test-neutron-functional.yml + - include: test-calico-functional.yml + when: + - "{{ neutron_plugin_type == 'ml2.calico' }}" vars_files: - test-vars.yml diff --git a/tests/test-neutron-functional.yml b/tests/test-neutron-functional.yml index 38afd2d1..7d68ce89 100644 --- a/tests/test-neutron-functional.yml +++ b/tests/test-neutron-functional.yml @@ -41,6 +41,8 @@ neutron agent-list | grep DHCP register: neutron_dhcp_agent until: neutron_dhcp_agent.stdout.find(':-)') != -1 + when: + - groups['neutron_dhcp_agent'] | length > 0 retries: 5 delay: 10 @@ -97,6 +99,8 @@ assert: that: - "'qdhcp' in dhcp_namespace.stdout" + when: + - groups['neutron_dhcp_agent'] | length > 0 - name: Check for iptables checksum rule shell: | diff --git a/tox.ini b/tox.ini index 04f069e5..e4841b4d 100644 --- a/tox.ini +++ b/tox.ini @@ -204,6 +204,23 @@ commands = {toxinidir}/tests/test.yml -vvvv {[testenv:func_logs]commands} +[testenv:calico] +# NOTE(logan): this target tests neutron with calico +install_command = + {[testenv:func_base]install_command} +deps = + {[testenv:ansible]deps} +setenv = + {[testenv:ansible]setenv} +commands = + {[testenv:ansible]commands} + ansible-playbook -i {toxinidir}/tests/calico_inventory \ + -e "rolename={toxinidir}" \ + -e "install_test_packages=True" \ + {toxinidir}/tests/test.yml -vvvv + bash -c 'mkdir -p {toxinidir}/logs' + bash -c 'rsync -av --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true' + [testenv:linters] deps =