]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
tests: add coverage on purge playbook
authorGuillaume Abrioux <gabrioux@redhat.com>
Thu, 7 Nov 2019 12:39:25 +0000 (13:39 +0100)
committerDimitri Savineau <savineau.dimitri@gmail.com>
Fri, 8 Nov 2019 14:06:11 +0000 (09:06 -0500)
This commit adds a playbook to be played before we run purge playbook,
it first creates an rbd image then map an rbd device on client0 so the
purge playbook will try to unmap it.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
tests/functional/rbd_map_devices.yml [new file with mode: 0644]
tox.ini

diff --git a/tests/functional/rbd_map_devices.yml b/tests/functional/rbd_map_devices.yml
new file mode 100644 (file)
index 0000000..8dcaa05
--- /dev/null
@@ -0,0 +1,54 @@
+---
+- hosts: client0
+  gather_facts: false
+  become: yes
+  tasks:
+    - name: check if it is atomic host
+      stat:
+        path: /run/ostree-booted
+      register: stat_ostree
+      tags: always
+
+# all our containerized job are based on atomic os, so we can rely on is_atomic to detect
+# whether we are running a containerized job
+    - name: set_fact is_atomic
+      set_fact:
+        is_atomic: '{{ stat_ostree.stat.exists }}'
+      tags: always
+
+    - name: load rbd module
+      modprobe:
+        name: rbd
+        state: present
+      delegate_to: "{{ item }}"
+      with_items:
+        - mon0
+        - client0
+
+    - name: create an rbd image - non container
+      command: "rbd create --size=1024 test/rbd_test"
+      delegate_to: "mon0"
+      when: not is_atomic
+
+    - name: create an rbd image - container
+      command: "docker run --rm -v /etc/ceph:/etc/ceph --net=host --entrypoint=rbd {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} create --size=1024 test/rbd_test"
+      delegate_to: "mon0"
+      when: is_atomic
+
+    - name: non container
+      when: not is_atomic
+      block:
+        - name: disable features unsupported by the kernel
+          command: rbd feature disable test/rbd_test object-map fast-diff deep-flatten
+
+        - name: map a device
+          command: rbd map test/rbd_test
+
+    - name: container
+      when: is_atomic
+      block:
+        - name: disable features unsupported by the kernel
+          command: "docker run --rm -v /etc/ceph:/etc/ceph --net=host --entrypoint=rbd {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} feature disable test/rbd_test object-map fast-diff deep-flatten"
+
+        - name: map a device
+          command: "docker run --rm --privileged -v /etc/ceph:/etc/ceph -v /dev:/dev --net=host --entrypoint=rbd {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} map test/rbd_test"
diff --git a/tox.ini b/tox.ini
index 43ff9ef9fe4127b2d68e1fcabb2a52d680396626..9e5d3a6f03985c89c0b32b2613ee7dff38e12ea0 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -113,6 +113,12 @@ commands=
 # can be redployed to.
 [purge]
 commands=
+  ansible-playbook -vv -i {changedir}/{env:INVENTORY} {toxinidir}/tests/functional/rbd_map_devices.yml --extra-vars "\
+      ceph_docker_registry={env:CEPH_DOCKER_REGISTRY:docker.io} \
+      ceph_docker_image={env:CEPH_DOCKER_IMAGE:ceph/daemon} \
+      ceph_docker_image_tag={env:CEPH_DOCKER_IMAGE_TAG:latest-master} \
+  "
+
   ansible-playbook -vv -i {changedir}/{env:INVENTORY} {toxinidir}/infrastructure-playbooks/{env:PURGE_PLAYBOOK:purge-cluster.yml} --extra-vars "\
       ireallymeanit=yes \
       remove_packages=yes \