From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- .../tests/functional/batch/playbooks/noop.yml | 12 ++ .../batch/playbooks/setup_mixed_type.yml | 215 +++++++++++++++++++++ .../tests/functional/batch/playbooks/test.yml | 64 ++++++ .../functional/batch/playbooks/test_explicit.yml | 64 ++++++ .../tests/functional/batch/playbooks/test_zap.yml | 34 ++++ 5 files changed, 389 insertions(+) create mode 100644 src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/noop.yml create mode 100644 src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/setup_mixed_type.yml create mode 100644 src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test.yml create mode 100644 src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_explicit.yml create mode 100644 src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_zap.yml (limited to 'src/ceph-volume/ceph_volume/tests/functional/batch/playbooks') diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/noop.yml b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/noop.yml new file mode 100644 index 000000000..5922ecf2e --- /dev/null +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/noop.yml @@ -0,0 +1,12 @@ +--- + +# Allows to always include a 'setup.yml' file in functional tests, and execute +# only on the ones that actually need it + +- hosts: all + gather_facts: no + + tasks: + + - debug: + msg: "This is an empty setup playbook. The current scenario didn't need any work done" 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 000000000..1fa9f66fc --- /dev/null +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/setup_mixed_type.yml @@ -0,0 +1,215 @@ +--- +- hosts: osds + become: yes + tasks: + + - name: install lvm2 + package: + name: lvm2 + state: present + - name: tell lvm to ignore loop devices + lineinfile: + path: /etc/lvm/lvm.conf + line: "\tfilter = [ 'r|loop.*|' ]" + insertafter: 'devices {' + - name: lvm allow changes depsite duplicate PVIDs + lineinfile: + path: /etc/lvm/lvm.conf + line: ' allow_changes_with_duplicate_pvs = 1' + insertafter: '^devices {' + regexp: 'allow_changes_with_duplicate_pvs = 0' + - name: create mount points + command: "mkdir /opt/{{ item }}" + loop: + - vdd + - vde + ignore_errors: yes + + - name: add part + shell: echo "type=83" | sfdisk /dev/{{ item }} + loop: + - vdd + - vde + + - name: add fs + command: "mkfs.ext4 /dev/{{ item }}1" + loop: + - vdd + - vde + + - name: mount additional drives + command: "mount /dev/{{ item }}1 /opt/{{ item }}" + loop: + - vdd + - vde + + - 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 + mount /dev/vdd1 /opt/vdd + mount /dev/vde1 /opt/vde + modprobe nvmet + modprobe nvme_loop + modprobe nvme_fabrics + modprobe loop + losetup -v /dev/loop0 /opt/vdd/loop0_nvme0 + losetup -v /dev/loop1 /opt/vde/loop1_nvme1 + losetup -l + nvmetcli restore /opt/loop.json + nvme connect -t loop -n testnqn1 -q hostnqn + nvme connect -t loop -n testnqn2 -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: detach nvme files from loop devices + command: "losetup -d /dev/{{ item }}" + failed_when: false + loop: + - loop0 + - loop1 + + - name: remove previous nvme files + file: + path: "{{ item }}" + state: absent + loop: + - /opt/vdd/loop0_nvme0 + - /opt/vde/loop1_nvme1 + + - name: create 20GB sparse files for NVMe + command: "fallocate -l 20G {{ item }}" + loop: + - /opt/vdd/loop0_nvme0 + - /opt/vde/loop1_nvme1 + + - name: setup loop devices with sparse files 0 + command: "losetup /dev/loop0 /opt/vdd/loop0_nvme0" + failed_when: false + + - name: setup loop devices with sparse files 1 + command: "losetup /dev/loop1 /opt/vde/loop1_nvme1" + failed_when: false + + - 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": [ + "testnqn1", + "testnqn2" + ] + } + ], + "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": "testnqn1" + }, + { + "allowed_hosts": [ + "hostnqn" + ], + "attr": { + "allow_any_host": "0" + }, + "namespaces": [ + { + "device": { + "nguid": "ef90689c-6c46-d44c-89c1-4067801309a7", + "path": "/dev/loop1" + }, + "enable": 1, + "nsid": 2 + } + ], + "nqn": "testnqn2" + } + ] + } + 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{{ item }} -q hostnqn" + loop: + - 1 + - 2 + + - name: debug output for nvme list + command: nvme list diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test.yml b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test.yml new file mode 100644 index 000000000..5d5bc59f2 --- /dev/null +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test.yml @@ -0,0 +1,64 @@ + +- hosts: osds + become: yes + tasks: + + - name: stop ceph-osd daemons + service: + name: "ceph-osd@{{ item }}" + state: stopped + with_items: "{{ osd_ids }}" + +- hosts: mons + become: yes + tasks: + + - name: mark osds down + command: "ceph --cluster {{ cluster }} osd down osd.{{ item }}" + with_items: "{{ osd_ids }}" + - name: purge osds + command: "ceph --cluster {{ cluster }} osd purge osd.{{ item }} --yes-i-really-mean-it" + with_items: "{{ osd_ids }}" + +- hosts: osds + become: yes + tasks: + + - name: zap devices used for OSDs + command: "ceph-volume --cluster {{ cluster }} lvm zap {{ item }} --destroy" + with_items: "{{ devices }}" + environment: + CEPH_VOLUME_DEBUG: 1 + + - name: batch create devices again + command: "ceph-volume --cluster {{ cluster }} lvm batch --yes --{{ osd_objectstore|default('bluestore') }} {{ '--dmcrypt' if dmcrypt|default(false) else '' }} {{ devices | join(' ') }}" + environment: + CEPH_VOLUME_DEBUG: 1 + + - name: ensure batch create is idempotent + command: "ceph-volume --cluster {{ cluster }} lvm batch --yes --{{ osd_objectstore|default('bluestore') }} {{ '--dmcrypt' if dmcrypt|default(false) else '' }} {{ devices | join(' ') }}" + register: batch_cmd + failed_when: false + environment: + CEPH_VOLUME_DEBUG: 1 + + - name: check batch idempotency + fail: + msg: "lvm batch failed idempotency check" + when: + - batch_cmd.rc != 0 + - "'strategy changed' not in batch_cmd.stderr" + + - name: run batch --report to see if devices get filtered + command: "ceph-volume --cluster {{ cluster }} lvm batch --report --format=json --{{ osd_objectstore|default('bluestore') }} {{ '--dmcrypt' if dmcrypt|default(false) else '' }} {{ devices | join(' ') }}" + register: report_cmd + failed_when: false + environment: + CEPH_VOLUME_DEBUG: 1 + + - name: check batch --report idempotency + fail: + msg: "lvm batch --report failed idempotency check" + when: + - report_cmd.rc != 0 + - "'strategy changed' not in report_cmd.stderr" diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_explicit.yml b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_explicit.yml new file mode 100644 index 000000000..1ff0acc9d --- /dev/null +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_explicit.yml @@ -0,0 +1,64 @@ + +- hosts: osds + become: yes + tasks: + + - name: stop ceph-osd daemons + service: + name: "ceph-osd@{{ item }}" + state: stopped + with_items: "{{ osd_ids }}" + +- hosts: mons + become: yes + tasks: + + - name: mark osds down + command: "ceph --cluster {{ cluster }} osd down osd.{{ item }}" + with_items: "{{ osd_ids }}" + - name: purge osds + command: "ceph --cluster {{ cluster }} osd purge osd.{{ item }} --yes-i-really-mean-it" + with_items: "{{ osd_ids }}" + +- hosts: osds + become: yes + vars: + external_devices: "{{ '--db-devices' if osd_objectstore == 'bluestore' else '--journal-devices' }}" + tasks: + + - name: zap devices used for OSDs + command: "ceph-volume --cluster {{ cluster }} lvm zap {{ item }} --destroy" + with_items: "{{ devices }}" + environment: + CEPH_VOLUME_DEBUG: 1 + + - name: batch create devices again + command: "ceph-volume --cluster {{ cluster }} lvm batch --yes --{{ osd_objectstore|default('bluestore') }} {{ '--dmcrypt' if dmcrypt|default(false) else '' }} {{ devices[:2] | join(' ') }} {{ external_devices }} {{ devices[2:] | join(' ') }}" + environment: + CEPH_VOLUME_DEBUG: 1 + + - name: ensure batch create is idempotent when all data devices are filtered + command: "ceph-volume --cluster {{ cluster }} lvm batch --yes --{{ osd_objectstore|default('bluestore') }} {{ '--dmcrypt' if dmcrypt|default(false) else '' }} {{ devices[:2] | join(' ') }} {{ external_devices }} {{ devices[2:] | join(' ') }}" + register: batch_cmd + failed_when: false + environment: + CEPH_VOLUME_DEBUG: 1 + + - name: check batch idempotency + fail: + msg: "lvm batch failed idempotency check" + when: + - batch_cmd.rc != 0 + + - name: run batch --report to see if devices get filtered + command: "ceph-volume --cluster {{ cluster }} lvm batch --report --format=json --{{ osd_objectstore|default('bluestore') }} {{ '--dmcrypt' if dmcrypt|default(false) else '' }} {{ devices[:2] | join(' ') }} {{ external_devices }} {{ devices[2:] | join(' ') }}" + register: report_cmd + failed_when: false + environment: + CEPH_VOLUME_DEBUG: 1 + + - name: check batch --report idempotency + fail: + msg: "lvm batch --report failed idempotency check" + when: + - report_cmd.rc != 0 diff --git a/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_zap.yml b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_zap.yml new file mode 100644 index 000000000..9d63df9e0 --- /dev/null +++ b/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/test_zap.yml @@ -0,0 +1,34 @@ + +- hosts: osds + become: yes + tasks: + + - name: stop ceph-osd daemons + service: + name: "ceph-osd@{{ item }}" + state: stopped + with_items: "{{ osd_ids }}" + + +- hosts: mons + become: yes + tasks: + + - name: mark osds down + command: "ceph --cluster {{ cluster }} osd down osd.{{ item }}" + with_items: "{{ osd_ids }}" + - name: purge osds + command: "ceph --cluster {{ cluster }} osd purge osd.{{ item }} --yes-i-really-mean-it" + with_items: "{{ osd_ids }}" + + +- hosts: osds + become: yes + tasks: + + - name: zap devices used for OSDs + command: "ceph-volume --cluster {{ cluster }} lvm zap --osd-id {{ item }} --destroy" + with_items: "{{ osd_ids }}" + environment: + CEPH_VOLUME_DEBUG: 1 + -- cgit v1.2.3