From 942531a8d8c76856f72818d4d00fc6e6b3086e23 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 22 Feb 2018 16:40:45 -0600 Subject: [PATCH] add minimal functional tests Change-Id: Ie76759e6c162270fd3e767d4719b885b57a7539b Signed-off-by: Kevin Carter --- tasks/main.yml | 2 +- tasks/nspawn_volume.yml | 4 ++ tests/inventory | 2 +- tests/test.yml | 93 ++++++++++++++++++++++++----------------- zuul.d/jobs.yaml | 36 ++++++++++++++++ zuul.d/project.yaml | 9 ++-- 6 files changed, 102 insertions(+), 44 deletions(-) create mode 100644 zuul.d/jobs.yaml diff --git a/tasks/main.yml b/tasks/main.yml index 39c1f8d..f87917e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -92,7 +92,7 @@ state: directory owner: root group: systemd-journal - mode: "2755" + mode: "02755" with_items: - /var/log/journal notify: diff --git a/tasks/nspawn_volume.yml b/tasks/nspawn_volume.yml index 8e145ce..431be08 100644 --- a/tasks/nspawn_volume.yml +++ b/tasks/nspawn_volume.yml @@ -27,6 +27,8 @@ register: machines_create args: executable: /bin/bash + tags: + - skip_ansible_lint rescue: - name: Create volume file (fallback) shell: | @@ -34,6 +36,8 @@ register: machines_create args: executable: /bin/bash + tags: + - skip_ansible_lint - name: Systemd machinectl mount block: diff --git a/tests/inventory b/tests/inventory index df8b5f6..32a8738 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,2 +1,2 @@ [all] -localhost ansible_connection=local +localhost ansible_connection=local physical_host=localhost diff --git a/tests/test.yml b/tests/test.yml index 7fb6091..b2dcc68 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -82,54 +82,69 @@ roles: - role: "nspawn_hosts" - nspawn_net_address: 10.100.100.1 - nspawn_net_bridge: nspawnbr0 - nspawn_kernel_options: - - { key: 'fs.inotify.max_user_instances', value: 1024 } + nspawn_container_base_name: "test-container" nspawn_container_cache_files: - src: files/container-file-copy-test.txt dest: /tmp/file-copied-from-deployment-host.txt post_tasks: - - name: Get sysctl content - set_fact: - sysctl_conf: "{{ lookup('file', '/etc/sysctl.conf') }}" - - name: Check for nspawn bridge stat: - path: /sys/class/net/nspawnbr0/bridge/bridge_id - register: nspawn_bridge_file - - - name: Check dnsmasq is running - shell: ps auxfww | grep -w 'dnsmasq -u nspawn-dnsmasq' + path: /sys/class/net/nspawn0/upper_mv-nspawn0 changed_when: false - - - name: DEBIAN - Get deployed interface file contents, without Ansible managed line - set_fact: - interface_file: "{{ lookup('pipe', 'cat /etc/network/interfaces.d/nspawn-net-bridge.cfg | tail -n +3') }}" - when: ansible_os_family | lower == "debian" - - - name: RHEL - Get deployed interface file contents, without Ansible managed line - set_fact: - interface_file: "{{ lookup('pipe', 'cat /etc/sysconfig/network-scripts/ifcfg-nspawnbr0 | tail -n +3') }}" - when: ansible_os_family | lower == "redhat" - - - name: SUSE - Get deployed interface file contents, without Ansible managed line - set_fact: - interface_file: "{{ lookup('pipe', 'cat /etc/sysconfig/network/ifcfg-nspawnbr0 | tail -n +3') }}" - when: ansible_os_family | lower == "suse" - - - name: Get bridge interface facts - setup: - filter: ansible_nspawnbr0 - register: nspawnbr0_facts + register: nspawn_interface_file - name: Check role functions assert: that: - - interface_file | search('.*nspawnbr0.*') - - interface_file | search('.*10.100.100.1.*') - - interface_file | search('.*255.255.255.0.*') - - sysctl_conf | search('fs.inotify.max_user_instances.*') - - "nspawn_bridge_file.stat.exists" - - "nspawnbr0_facts.ansible_facts.ansible_nspawnbr0.ipv4.address | match('10.100.100.1')" + - "nspawn_interface_file.stat.exists" + + - name: Check dnsmasq is running + command: systemctl status dnsmasq-mv-nspawn0.service + changed_when: false + tags: + - skip_ansible_lint + + - name: Check for machines mount + command: "systemctl status var-lib-machines.mount" + changed_when: false + tags: + - skip_ansible_lint + + - name: Check dnsmasq is running + command: systemctl status dnsmasq-mv-nspawn0.service + changed_when: false + tags: + - skip_ansible_lint + + - name: Check for valid BTRFS file system + command: "btrfs filesystem show /var/lib/machines" + changed_when: false + + - name: Check for base container + command: "machinectl show-image test-container" + changed_when: false + + - name: Ensure images can be cloned + command: "machinectl clone test-container test1" + changed_when: false + + - name: Ensure images can be removed + command: "machinectl remove test1" + changed_when: false + + - name: Ensure images can be marked read-only + command: "machinectl read-only test-container yes" + changed_when: false + + - name: Ensure a read-only image is read-only + file: + path: /var/lib/machines/test-container/test-file + state: touch + failed_when: + - read_only_test | success + register: read_only_test + + - name: Remove base image + command: "machinectl remove test-container" + changed_when: false diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml new file mode 100644 index 0000000..176488b --- /dev/null +++ b/zuul.d/jobs.yaml @@ -0,0 +1,36 @@ +--- +# Copyright 2017, 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. + +- job: + name: openstack-ansible-nspawn-container-create + parent: openstack-ansible-cross-repo-functional + required-projects: + - name: openstack/openstack-ansible-nspawn_container_create + vars: + osa_test_repo: "openstack/openstack-ansible-nspawn_container_create" + +# - job: +# name: openstack-ansible-nspawn-ubuntu-xenial +# parent: openstack-ansible-nspawn-container-create + +# - job: +# name: openstack-ansible-nspawn-centos-7 +# parent: openstack-ansible-nspawn-container-create +# nodeset: centos-7 + +# - job: +# name: openstack-ansible-nspawn-opensuse-423 +# parent: openstack-ansible-nspawn-container-create +# nodeset: opensuse-423 diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 0beb801..c19b4d6 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -17,12 +17,15 @@ jobs: - openstack-ansible-linters - openstack-ansible-functional-centos-7 + # - openstack-ansible-functional-opensuse-423 - openstack-ansible-functional-ubuntu-xenial - experimental: - jobs: - - openstack-ansible-integrated-deploy-aio + # - openstack-ansible-nspawn-centos-7 + # - openstack-ansible-nspawn-opensuse-423 + # - openstack-ansible-nspawn-ubuntu-xenial + gate: jobs: - openstack-ansible-linters - openstack-ansible-functional-centos-7 + # - openstack-ansible-functional-opensuse-423 - openstack-ansible-functional-ubuntu-xenial