From 377f8e389bc9db7695f88f2694b3156d711cc53e Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 16 Apr 2020 15:27:35 +0300 Subject: [PATCH] Fix functional tests Functional tests have been broken by [1] as it has prescedence over host_vars which are defined for functional tests. [1] https://review.opendev.org/#/c/707943/ Change-Id: If687504ed08c34bd3336d31b1ae044b7d633318c --- tests/host_vars/container1.yml | 8 ------- tests/host_vars/container2.yml | 4 ---- tests/host_vars/localhost.yml | 2 -- tests/test-containers-functional.yml | 34 +++++++++------------------- 4 files changed, 11 insertions(+), 37 deletions(-) diff --git a/tests/host_vars/container1.yml b/tests/host_vars/container1.yml index e8a9ae8..2f664fd 100644 --- a/tests/host_vars/container1.yml +++ b/tests/host_vars/container1.yml @@ -3,11 +3,3 @@ ansible_host: 10.100.100.2 ansible_become: True ansible_user: root container_name: container1 -lxc_container_config_list: - - "{{ (hostvars[physical_host | default('localhost')]['ansible_distribution_version'] == '18.04') | ternary('lxc.apparmor.profile', 'lxc.aa_profile') }}=lxc-openstack" - - "lxc.mount.entry=/openstack/{{ inventory_hostname }} opt/test1 none bind,create=dir 0 0" - -lxc_container_commands: | - if [[ ! -d "/opt/test1" ]]; then - mkdir -p "/opt/test1" - fi diff --git a/tests/host_vars/container2.yml b/tests/host_vars/container2.yml index 2db6bd6..0fea757 100644 --- a/tests/host_vars/container2.yml +++ b/tests/host_vars/container2.yml @@ -3,7 +3,3 @@ ansible_host: 10.100.100.3 ansible_become: True ansible_user: root container_name: container2 -lxc_container_config_list: - # The unconfined profile is causing problems with overlayfs. See https://bugs.launchpad.net/openstack-ansible/+bug/1612412 - # Use the lxc2 aa_profile key to test that it is correctly changed in-flight to the required lxc3 key on bionic - - "lxc.aa_profile={{ (lxc_container_backing_store == 'overlayfs') | ternary('lxc-openstack', 'unconfined') }}" diff --git a/tests/host_vars/localhost.yml b/tests/host_vars/localhost.yml index 65ddeaa..6c26f31 100644 --- a/tests/host_vars/localhost.yml +++ b/tests/host_vars/localhost.yml @@ -15,5 +15,3 @@ bridges: - "br-mgmt" - -ansible_python_interpreter: "/usr/bin/python2" diff --git a/tests/test-containers-functional.yml b/tests/test-containers-functional.yml index ab0e81e..b220d8b 100644 --- a/tests/test-containers-functional.yml +++ b/tests/test-containers-functional.yml @@ -32,33 +32,20 @@ # container2 10.100.100.3, 172.16.12.4 assert: that: - - lxc_container_list.stdout | search("container1\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\s+)*10.100.100.2(,\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*\s+") - - lxc_container_list.stdout | search("container2\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\s+)*10.100.100.3(,\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*\s+") - - lxc_container_list.stdout | search("container3\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\s+)*10.100.100.4(,\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*\s+") + - lxc_container_list.stdout is search("container1\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\s+)*10.100.100.2(,\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*\s+") + - lxc_container_list.stdout is search("container2\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\s+)*10.100.100.3(,\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*\s+") + - lxc_container_list.stdout is search("container3\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\s+)*10.100.100.4(,\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*\s+") - name: Check for the presence of the right app armor profile for container1 - command: grep "^{{ (hostvars[physical_host | default('localhost')]['ansible_distribution_version'] == '18.04') | ternary('lxc.apparmor.profile', 'lxc.aa_profile') }} = lxc-openstack$" /var/lib/lxc/container1/config + command: "grep \"^{{ (hostvars[physical_host | default('localhost')]['ansible_os_family'] == 'Debian') | ternary('lxc.apparmor.profile', 'lxc.aa_profile') }} = {{ (hostvars[physical_host | default('localhost')]['ansible_distribution'] == 'Debian') | ternary('unconfined', 'lxc-openstack') }}$\" {{ item }}" register: container1_profile failed_when: container1_profile.rc != 0 - tags: - - skip_ansible_lint - - - name: Check for the presence of the right app armor profile for container2 - command: "grep -E '^{{ (hostvars[physical_host | default('localhost')]['ansible_distribution_version'] == '18.04') | ternary('lxc.apparmor.profile', 'lxc.aa_profile') }} = {{ (lxc_container_backing_store == 'overlayfs') | ternary('lxc-openstack', 'unconfined') }}$' /var/lib/lxc/container2/config" - register: container2_profile - failed_when: container2_profile.rc != 0 - tags: - - skip_ansible_lint - - - name: Check for the lack of presence of an aa_profile for container3 - command: grep "{{ (hostvars[physical_host | default('localhost')]['ansible_distribution_version'] == '18.04') | ternary('lxc.apparmor.profile', 'lxc.aa_profile') }}" /var/lib/lxc/container3/config - register: container3_profile - failed_when: container3_profile.rc == 0 + with_sequence: start=1 end=3 format=/var/lib/lxc/container%x/config tags: - skip_ansible_lint - name: Check for the presence of the right bound mount for container1 - command: grep "lxc.mount.entry = /openstack/container1 opt/test1 none bind,create=dir 0 0" /var/lib/lxc/container1/config + command: grep "lxc.mount.entry = /openstack/log/container1" /var/lib/lxc/container1/config tags: - skip_ansible_lint @@ -79,10 +66,11 @@ hosts: container1 remote_user: root tasks: - - name: Check for the presence of /opt/test1 - command: ls -1 /opt/test1 - register: container1_test_dir - failed_when: container1_test_dir.rc != 0 + - name: Check for the presence of /var/backup + stat: + path: /var/backup + register: container1_backup_dir + failed_when: container1_backup_dir.stat.isdir is not defined tags: - skip_ansible_lint