From eb0bb51fafa01926a0d13021a1f97c333bbdabd8 Mon Sep 17 00:00:00 2001 From: Travis Truman Date: Thu, 14 Jul 2016 14:07:28 -0400 Subject: [PATCH] Adding func_ovs tox environment for neutron ovs testing This tox environment will be run with check experimental for now. Ultimately it should become part of the gate testing for the role. Change-Id: I410f029816590dde819a6c97bde5f159f7a791d1 Implements: blueprint support-openvswitch --- Vagrantfile | 22 ++++++- run_tests.sh | 2 +- .../plugins/ml2/openvswitch_agent.ini.j2 | 1 - tests/{inventory => lxb_inventory} | 6 +- tests/ovs_inventory | 61 +++++++++++++++++++ tests/ovs_test_vars.yml | 8 +++ tests/test-install-neutron.yml | 4 ++ tests/test-neutron-functional.yml | 21 +++++-- tests/test-prepare-host.yml | 5 ++ tox.ini | 24 +++++++- 10 files changed, 142 insertions(+), 12 deletions(-) rename tests/{inventory => lxb_inventory} (85%) create mode 100644 tests/ovs_inventory create mode 100644 tests/ovs_test_vars.yml diff --git a/Vagrantfile b/Vagrantfile index d09fc560..4bf3b548 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,13 +1,31 @@ +# Runs various tests defined in the tox.ini +# +# To run everything but functional tests: +# vagrant up --provision-with bootstrap +# +# To run docs, linters and functional: +# vagrant up +# +# To run docs, linters and func_ovs tests: +# TOX_ENV=func_ovs vagrant up +# Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty64" config.vm.provider "virtualbox" do |v| v.memory = 2048 v.cpus = 2 end - config.vm.provision "shell", inline: <<-SHELL + # Run docs, linters, etc, but no functional tests + config.vm.provision "bootstrap", type: "shell", inline: <<-SHELL sudo su - cd /vagrant apt-get update - ./run_tests.sh + FUNCTIONAL_TEST=false ./run_tests.sh + SHELL + # Run functional tests + config.vm.provision "func_test", type: "shell", inline: <<-SHELL + sudo su - + cd /vagrant + tox -e #{ENV['TOX_ENV'] || "functional"} SHELL end \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh index d9d15b8a..c7f0aa63 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -33,7 +33,7 @@ pip install tox # run through each tox env and execute the test for tox_env in $(awk -F= '/envlist/ {print $2}' tox.ini | sed 's/,/ /g'); do - if [ "${tox_env}" != "functional" ]; then + if [[ "${tox_env}" != "functional" ]] && [[ $tox_env != func_* ]]; then tox -e ${tox_env} elif [ "${tox_env}" == "functional" ]; then if ${FUNCTIONAL_TEST}; then diff --git a/templates/plugins/ml2/openvswitch_agent.ini.j2 b/templates/plugins/ml2/openvswitch_agent.ini.j2 index 6d1cff19..3e345697 100644 --- a/templates/plugins/ml2/openvswitch_agent.ini.j2 +++ b/templates/plugins/ml2/openvswitch_agent.ini.j2 @@ -1,6 +1,5 @@ # {{ ansible_managed }} -# Linux bridge agent physical interface mappings [ovs] {% if neutron_tunnel_types | length > 0 %} local_ip = {{ neutron_local_ip }} diff --git a/tests/inventory b/tests/lxb_inventory similarity index 85% rename from tests/inventory rename to tests/lxb_inventory index 94531861..3699c831 100644 --- a/tests/inventory +++ b/tests/lxb_inventory @@ -1,8 +1,11 @@ [all] -localhost ansible_connection=local ansible_become=True +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 @@ -50,6 +53,7 @@ openstack1 neutron_agent neutron_dhcp_agent neutron_linuxbridge_agent +neutron_openvswitch_agent neutron_metering_agent neutron_l3_agent neutron_lbaas_agent diff --git a/tests/ovs_inventory b/tests/ovs_inventory new file mode 100644 index 00000000..9b50fd33 --- /dev/null +++ b/tests/ovs_inventory @@ -0,0 +1,61 @@ +[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 + +[service_all:children] +rabbitmq_all +galera_all + +[keystone_all] +openstack1 + +[neutron_agent] +openstack1 + +[neutron_dhcp_agent] +openstack1 + +[neutron_linuxbridge_agent] + +[neutron_openvswitch_agent] +openstack1 + +[neutron_metering_agent] +openstack1 + +[neutron_l3_agent] +openstack1 + +[neutron_lbaas_agent] +openstack1 + +[neutron_metadata_agent] +openstack1 + +[neutron_server] +openstack1 + +[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 diff --git a/tests/ovs_test_vars.yml b/tests/ovs_test_vars.yml new file mode 100644 index 00000000..b94522a0 --- /dev/null +++ b/tests/ovs_test_vars.yml @@ -0,0 +1,8 @@ +--- +openstack_host_specific_kernel_modules: + - name: "openvswitch" + pattern: "CONFIG_OPENVSWITCH=" + group: "physical_host" + +neutron_plugin_type: ml2.ovs +neutron_local_ip: "{{ ansible_ssh_host }}" \ No newline at end of file diff --git a/tests/test-install-neutron.yml b/tests/test-install-neutron.yml index 202083dd..78091ef0 100644 --- a/tests/test-install-neutron.yml +++ b/tests/test-install-neutron.yml @@ -106,6 +106,10 @@ set_fact: uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive" when: nodepool.stat.exists | bool + - name: Include OVS testing vars + include_vars: ovs_test_vars.yml + when: + - groups['neutron_openvswitch_agent'] | length > 0 roles: - role: "{{ rolename | basename }}" post_tasks: diff --git a/tests/test-neutron-functional.yml b/tests/test-neutron-functional.yml index 5d1a239a..ab3767cf 100644 --- a/tests/test-neutron-functional.yml +++ b/tests/test-neutron-functional.yml @@ -27,6 +27,14 @@ url: "http://localhost:9696" status_code: 200 +# No assertion around this yet, just useful for debug purposes +# TODO(automagically) - Test for all expected agents and agent status +- name: Neutron agents status + shell: | + . /root/openrc + neutron agent-list + register: agent_list + - name: Ensure that the DHCP agent is alive shell: | . /root/openrc @@ -60,12 +68,13 @@ delay: 10 - name: Check for dhcp network namespace - shell: | - ip netns | grep "^qdhcp" + shell: ip netns register: dhcp_namespace - until: dhcp_namespace.rc == 0 - retries: 5 - delay: 10 + +- name: Make sure the dhcp namespace is present + assert: + that: + - "'qdhcp' in dhcp_namespace.stdout" - name: Check for iptables checksum rule shell: | @@ -74,3 +83,5 @@ until : checksum_rule.rc == 0 retries: 5 delay: 10 + when: + - groups['neutron_linuxbridge_agent'] | length > 0 diff --git a/tests/test-prepare-host.yml b/tests/test-prepare-host.yml index c1d127b4..2899da9e 100644 --- a/tests/test-prepare-host.yml +++ b/tests/test-prepare-host.yml @@ -32,7 +32,12 @@ lxc_container_cache_files: - { src: '/etc/pip.conf', dest: '/etc/pip.conf' } when: nodepool.stat.exists | bool + - name: Include OVS testing vars + include_vars: ovs_test_vars.yml + when: + - groups['neutron_openvswitch_agent'] | length > 0 roles: + - role: "openstack_hosts" - role: "lxc_hosts" lxc_net_address: 10.100.100.1 lxc_net_dhcp_range: 10.100.100.8,10.100.100.253 diff --git a/tox.ini b/tox.ini index 4cf6bc8c..be1a3d52 100644 --- a/tox.ini +++ b/tox.ini @@ -139,7 +139,7 @@ setenv = {[testenv:ansible]setenv} commands = {[testenv:ansible]commands} - ansible-playbook -i {toxinidir}/tests/inventory \ + ansible-playbook -i {toxinidir}/tests/lxb_inventory \ --syntax-check \ --list-tasks \ -e "rolename={toxinidir}" \ @@ -157,6 +157,8 @@ commands = # NOTE(odyssey4me): this target does not use constraints because # it doesn't work in OpenStack-CI yet. Once that's fixed, we can # drop the install_command. +# +# NOTE(automagically): this target tests neutron with linuxbridge install_command = pip install -U --force-reinstall {opts} {packages} deps = @@ -165,11 +167,29 @@ setenv = {[testenv:ansible]setenv} commands = {[testenv:ansible]commands} - ansible-playbook -i {toxinidir}/tests/inventory \ + ansible-playbook -i {toxinidir}/tests/lxb_inventory \ -e "rolename={toxinidir}" \ -e "install_test_packages=True" \ {toxinidir}/tests/test.yml -vvvv +[testenv:func_ovs] +# NOTE(odyssey4me): this target does not use constraints because +# it doesn't work in OpenStack-CI yet. Once that's fixed, we can +# drop the install_command. +# +# NOTE(automagically): this target tests neutron with ovs +install_command = + pip install -U --force-reinstall {opts} {packages} +deps = + {[testenv:ansible]deps} +setenv = + {[testenv:ansible]setenv} +commands = + {[testenv:ansible]commands} + ansible-playbook -i {toxinidir}/tests/ovs_inventory \ + -e "rolename={toxinidir}" \ + -e "install_test_packages=True" \ + {toxinidir}/tests/test.yml -vvvv [testenv:linters] deps =