From 71db509df0c4a14598010568f8bb078f6b2841ab Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 6 Sep 2018 09:38:00 -0400 Subject: [PATCH] ceph-volume tests/functional setup playbook for nvme devices Signed-off-by: Alfredo Deza --- .../mixed-type-dmcrypt/group_vars/all | 7 + .../bluestore/mixed-type-dmcrypt/test.yml | 2 +- .../bluestore/mixed-type/group_vars/all | 7 + .../centos7/bluestore/mixed-type/test.yml | 2 +- .../batch/playbooks/setup_mixed_type.yml | 140 ++++++++++++++++++ 5 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/setup_mixed_type.yml diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type-dmcrypt/group_vars/all b/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type-dmcrypt/group_vars/all index 1bd93cff65225..c3335fae601e0 100644 --- a/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type-dmcrypt/group_vars/all +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type-dmcrypt/group_vars/all @@ -23,3 +23,10 @@ ceph_conf_overrides: global: osd_pool_default_pg_num: 8 osd_pool_default_size: 1 + +# The following is only needed for testing purposes and is not part of +# ceph-ansible supported variables + +osd_ids: + - 0 + - 1 diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type-dmcrypt/test.yml b/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type-dmcrypt/test.yml index 165d9da291e2f..aa867bcde1ab7 120000 --- a/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type-dmcrypt/test.yml +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type-dmcrypt/test.yml @@ -1 +1 @@ -../../../playbooks/test_bluestore.yml \ No newline at end of file +../../../playbooks/test.yml \ No newline at end of file diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type/group_vars/all b/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type/group_vars/all index 59d2875af69ee..06b966be52cdf 100644 --- a/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type/group_vars/all +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type/group_vars/all @@ -22,3 +22,10 @@ ceph_conf_overrides: global: osd_pool_default_pg_num: 8 osd_pool_default_size: 1 + +# The following is only needed for testing purposes and is not part of +# ceph-ansible supported variables + +osd_ids: + - 0 + - 1 diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type/test.yml b/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type/test.yml index 165d9da291e2f..aa867bcde1ab7 120000 --- a/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type/test.yml +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/centos7/bluestore/mixed-type/test.yml @@ -1 +1 @@ -../../../playbooks/test_bluestore.yml \ No newline at end of file +../../../playbooks/test.yml \ No newline at end of file diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/setup_mixed_type.yml b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/setup_mixed_type.yml new file mode 100644 index 0000000000000..af29487fb8128 --- /dev/null +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/setup_mixed_type.yml @@ -0,0 +1,140 @@ + +- hosts: osds + become: yes + tasks: + + - name: create the nvme image systemd unit + copy: + content: | + [Unit] + Description=NVMe loop device + After=local-fs.target + Wants=local-fs.target + + [Service] + Type=simple + ExecStart=/bin/bash /opt/ceph-nvme.sh + StandardOutput=journal + StandardError=journal + + [Install] + WantedBy=multi-user.target + dest: "/etc/systemd/system/ceph-nvme.service" + + - name: create the ceph-nvme startup script + copy: + content: | + set -x + set -e + modprobe nvmet + modprobe nvme_loop + modprobe nvme_fabrics + modprobe loop + losetup -v /dev/loop0 /opt/loop0_nvme0 + losetup -l + nvmetcli restore /opt/loop.json + nvme connect -t loop -n testnqn -q hostnqn + nvme list + dest: "/opt/ceph-nvme.sh" + + - name: ensure ceph-nvme is enabled + service: + name: ceph-nvme + state: stopped + enabled: yes + + - name: install nvme dependencies + package: + name: "{{ item }}" + state: present + with_items: + - nvme-cli + - nvmetcli + + - name: enable NVME kernel modules + modprobe: + name: "{{ item }}" + state: present + with_items: + - nvmet + - nvme_loop + - nvme_fabrics + + - name: check if the nvme file is attached to loop0 + command: losetup -l /dev/loop0 + register: losetup_list + + - name: detach current nvme0 file + command: losetup -d /dev/loop0 + when: '"loop0_nvme0" in losetup_list.stdout' + + - name: remove previous nvme0 file + file: + path: /opt/loop0_nvme0 + state: absent + + - name: create a 15GB sparse file for NVMe + command: fallocate -l 15G /opt/loop0_nvme0 + + - name: setup loop device with sparse file + command: losetup /dev/loop0 /opt/loop0_nvme0 + when: + - '"loop0_nvme0" not in losetup_list.stdout' + + - name: create the loop.json file for nvmetcli + copy: + content: | + { + "hosts": [ + { + "nqn": "hostnqn" + } + ], + "ports": [ + { + "addr": { + "adrfam": "", + "traddr": "", + "treq": "not specified", + "trsvcid": "", + "trtype": "loop" + }, + "portid": 1, + "referrals": [], + "subsystems": [ + "testnqn" + ] + } + ], + "subsystems": [ + { + "allowed_hosts": [ + "hostnqn" + ], + "attr": { + "allow_any_host": "0" + }, + "namespaces": [ + { + "device": { + "nguid": "ef90689c-6c46-d44c-89c1-4067801309a8", + "path": "/dev/loop0" + }, + "enable": 1, + "nsid": 1 + } + ], + "nqn": "testnqn" + } + ] + } + dest: "/opt/loop.json" + + - name: setup the /dev/loop0 target with nvmetcli + command: nvmetcli restore /opt/loop.json + + - name: connect the new target as an nvme device + command: nvme connect -t loop -n testnqn -q hostnqn + + - name: debug output for nvme list + command: nvme list -- 2.39.5