From: Guillaume Abrioux Date: Thu, 7 Nov 2019 12:39:25 +0000 (+0100) Subject: tests: add coverage on purge playbook X-Git-Tag: v6.0.0alpha1~225 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db77fbda15bf9f79f8122559b01b6625005ae29c;p=ceph-ansible.git tests: add coverage on purge playbook 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 --- diff --git a/tests/functional/rbd_map_devices.yml b/tests/functional/rbd_map_devices.yml new file mode 100644 index 000000000..8dcaa053d --- /dev/null +++ b/tests/functional/rbd_map_devices.yml @@ -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 43ff9ef9f..9e5d3a6f0 100644 --- 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 \