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 <gabrioux@redhat.com>
(cherry picked from commit db77fbda15)
pull/4974/head
Guillaume Abrioux 2019-11-07 13:39:25 +01:00 committed by Dimitri Savineau
parent 5db0b239f6
commit 01095f1f4c
2 changed files with 61 additions and 2 deletions

View File

@ -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"

View File

@ -45,8 +45,13 @@ commands=
# can be redployed to.
[purge]
commands=
cp {toxinidir}/infrastructure-playbooks/{env:PURGE_PLAYBOOK:purge-cluster.yml} {toxinidir}/{env:PURGE_PLAYBOOK:purge-cluster.yml}
ansible-playbook -vv -i {changedir}/{env:INVENTORY} {toxinidir}/{env:PURGE_PLAYBOOK:purge-cluster.yml} --extra-vars "\
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-luminous} \
"
ansible-playbook -vv -i {changedir}/{env:INVENTORY} {toxinidir}/infrastructure-playbooks/{env:PURGE_PLAYBOOK:purge-cluster.yml} --extra-vars "\
ireallymeanit=yes \
remove_packages=yes \
ceph_stable_release={env:CEPH_STABLE_RELEASE:luminous} \