From 28c66bee59bf1d16333a4155f7aa1658d504fada Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 5 Oct 2017 12:00:44 -0500 Subject: [PATCH] Add functional tests for our different backendstores This change adds several tox functional sections to support our different backend storage options. This change will allow us to create jenkens jobs specific to the various backends to validate they work as we expect them to. Change-Id: Ic1152ae666973af8c01499bb5ca89d8eeaa5f1d2 Depends-On: I70d53cabd0888954f31def924e9f4436398cdebf Signed-off-by: Kevin Carter --- tasks/lxc_container_create_btrfs.yml | 4 +- tests/overrides-btrfs.yml | 16 +++++++ tests/overrides-dir.yml | 16 +++++++ tests/overrides-machinectl.yml | 16 +++++++ tests/overrides-overlayfs.yml | 16 +++++++ tests/overrides-zfs.yml | 19 +++++++++ tests/test-create-btrfs-dev.yml | 60 ++++++++++++++++++++++++++ tests/test-create-zfs-dev.yml | 53 +++++++++++++++++++++++ tests/test.yml | 6 +++ tox.ini | 63 +++++++++++++++++++++++++++- 10 files changed, 265 insertions(+), 4 deletions(-) create mode 100644 tests/overrides-btrfs.yml create mode 100644 tests/overrides-dir.yml create mode 100644 tests/overrides-machinectl.yml create mode 100644 tests/overrides-overlayfs.yml create mode 100644 tests/overrides-zfs.yml create mode 100644 tests/test-create-btrfs-dev.yml create mode 100644 tests/test-create-zfs-dev.yml diff --git a/tasks/lxc_container_create_btrfs.yml b/tasks/lxc_container_create_btrfs.yml index 86856b6..fbc8c1b 100644 --- a/tasks/lxc_container_create_btrfs.yml +++ b/tasks/lxc_container_create_btrfs.yml @@ -13,6 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Not Implemented - fail: - msg: "BTRFS backed containers has not been implemented yet." +- include: lxc_container_cow.yml diff --git a/tests/overrides-btrfs.yml b/tests/overrides-btrfs.yml new file mode 100644 index 0000000..773b1c7 --- /dev/null +++ b/tests/overrides-btrfs.yml @@ -0,0 +1,16 @@ +--- +# Copyright 2015, 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. + +lxc_container_backing_store: btrfs diff --git a/tests/overrides-dir.yml b/tests/overrides-dir.yml new file mode 100644 index 0000000..7537452 --- /dev/null +++ b/tests/overrides-dir.yml @@ -0,0 +1,16 @@ +--- +# Copyright 2015, 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. + +lxc_container_backing_store: dir diff --git a/tests/overrides-machinectl.yml b/tests/overrides-machinectl.yml new file mode 100644 index 0000000..5b451cd --- /dev/null +++ b/tests/overrides-machinectl.yml @@ -0,0 +1,16 @@ +--- +# Copyright 2015, 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. + +lxc_container_backing_store: machinectl diff --git a/tests/overrides-overlayfs.yml b/tests/overrides-overlayfs.yml new file mode 100644 index 0000000..3bb8283 --- /dev/null +++ b/tests/overrides-overlayfs.yml @@ -0,0 +1,16 @@ +--- +# Copyright 2015, 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. + +lxc_container_backing_store: overlayfs diff --git a/tests/overrides-zfs.yml b/tests/overrides-zfs.yml new file mode 100644 index 0000000..7591627 --- /dev/null +++ b/tests/overrides-zfs.yml @@ -0,0 +1,19 @@ +--- +# Copyright 2015, 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. + +# At this time we're only testing ZFS on linux when the OS is Ubuntu. +# If ZFS get support across more distros we can revist this. +lxc_container_backing_store: zfs +lxc_container_zfs_root_name: "pool/lxc" diff --git a/tests/test-create-btrfs-dev.yml b/tests/test-create-btrfs-dev.yml new file mode 100644 index 0000000..41912d2 --- /dev/null +++ b/tests/test-create-btrfs-dev.yml @@ -0,0 +1,60 @@ +--- +# Copyright 2017, BBC R&D +# +# 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: Configure BTRFS backing storage + hosts: localhost + user: root + become: true + connection: local + tasks: + - block: + - name: Install BTRFS packages + package: + name: "{{ zfs_package[ansible_distribution | lower] }}" + state: present + + - name: Create base directories + file: + path: "{{ item }}" + state: "directory" + with_items: + - /openstack + - /var/lib/lxc + + - name: Create sparse lxc-btrfs file + command: "truncate -s 1024G /openstack/lxc-btrfs.img" + args: + creates: /openstack/lxc-btrfs.img + register: lxc_btrfs_create + + - name: Format the lxc-btrfs file + filesystem: + fstype: btrfs + dev: /openstack/lxc-btrfs.img + when: lxc_btrfs_create | changed + + - name: Create the mount points, fstab entries and mount the file systems + mount: + name: /var/lib/lxc + src: /openstack/lxc-btrfs.img + fstype: btrfs + state: mounted + when: + - lxc_container_backing_store == 'btrfs' + vars: + btrfs_package: + ubuntu: "btrfs-tools" + redhat: "btrfs-progs" + suse: "btrfsprogs" diff --git a/tests/test-create-zfs-dev.yml b/tests/test-create-zfs-dev.yml new file mode 100644 index 0000000..a3e83ca --- /dev/null +++ b/tests/test-create-zfs-dev.yml @@ -0,0 +1,53 @@ +--- +# Copyright 2017, BBC R&D +# +# 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: Configure ZFS backing storage + hosts: localhost + user: root + become: true + connection: local + tasks: + - block: + - name: Install ZFS packages + package: + name: "{{ zfs_package[ansible_distribution | lower] }}" + state: present + + - name: Create base directories + file: + path: "{{ item }}" + state: "directory" + with_items: + - /openstack + - /var/lib/lxc + + - name: Create sparse ZFS backing file + command: "truncate -s 1024G /openstack/lxc-zfs.img" + args: + creates: /openstack/lxc-zfs.img + register: lxc_zfs_create + + - name: Create the ZFS pool + command: zpool create pool /openstack/lxc-zfs.img + args: + creates: /pool + + - name: Create the ZFS pool/lxc volume + shell: "(zfs list | grep lxc) || zfs create -o mountpoint=/var/lib/lxc pool/lxc" + when: + - lxc_container_backing_store == 'zfs' + vars: + zfs_package: + ubuntu: "zfsutils-linux" diff --git a/tests/test.yml b/tests/test.yml index 180a70a..4174e2f 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -13,6 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Create a zfs backend +- include: test-create-zfs-dev.yml + +# Create a btrfs backend +- include: test-create-btrfs-dev.yml + # Setup the host - include: common/test-setup-host.yml diff --git a/tox.ini b/tox.ini index 400dd24..d0a1314 100644 --- a/tox.ini +++ b/tox.ini @@ -95,14 +95,75 @@ commands = bash -c "{toxinidir}/tests/common/test-ansible-lint.sh" -[testenv:functional] +# Functional testing for BTRFS backed containers +[testenv:btrfs] deps = {[testenv:ansible]deps} +setenv = + {[testenv]setenv} + ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-btrfs.yml commands = bash -c "{toxinidir}/tests/tests-repo-clone.sh" bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" +# Functional testing for Directory backed containers +[testenv:dir] +deps = + {[testenv:ansible]deps} +setenv = + {[testenv]setenv} + ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-dir.yml +commands = + bash -c "{toxinidir}/tests/tests-repo-clone.sh" + bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" + + +# Functional testing for machinectl backed containers +[testenv:mnctl] +deps = + {[testenv:ansible]deps} +setenv = + {[testenv]setenv} + ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-machinectl.yml +commands = + bash -c "{toxinidir}/tests/tests-repo-clone.sh" + bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" + + +# Functional testing for OverlayFS backed containers +[testenv:ofs] +deps = + {[testenv:ansible]deps} +setenv = + {[testenv]setenv} + ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-overlayfs.yml +commands = + bash -c "{toxinidir}/tests/tests-repo-clone.sh" + bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" + + +# Functional testing for ZFS backed containers +[testenv:zfs] +deps = + {[testenv:ansible]deps} +setenv = + {[testenv]setenv} + ANSIBLE_OVERRIDES={toxinidir}/tests/overrides-zfs.yml +commands = + bash -c "{toxinidir}/tests/tests-repo-clone.sh" + bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" + + +[testenv:functional] +deps = + {[testenv:dir]deps} +setenv = + {[testenv:dir]setenv} +commands = + {[testenv:dir]commands} + + [testenv:linters] deps = {[testenv:ansible]deps}