Skip to content

Commit 1719b07

Browse files
committed
edpm_iscsid: Update and improve molecule tests
Updates to the edpm_iscsid molecule tests include: - Revisions for the new host-based iscsid deployment. - A new scenario to test adoption of a tripleo deployment. - A new scenario to facilitate local development of molecule tests using vagrant.
1 parent 9bbf268 commit 1719b07

File tree

12 files changed

+289
-27
lines changed

12 files changed

+289
-27
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../default/converge.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../default/molecule.yml
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
# Copyright 2025 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
18+
- name: Run the default prepare playbook
19+
import_playbook: ../default/prepare.yml
20+
21+
- name: Prepare the adoption scenario
22+
hosts: all
23+
gather_facts: false
24+
become: true
25+
vars:
26+
test_helper_dir: "../../../../molecule/test-helpers"
27+
tasks:
28+
- name: Load role vars
29+
ansible.builtin.include_vars: ../../defaults/main.yml
30+
31+
- name: Create the containerized iscsid configuration directory
32+
ansible.builtin.file:
33+
path: "{{ edpm_iscsid_tripleo_config_dir }}"
34+
state: directory
35+
36+
- name: Create a dummy iscsid.conf file
37+
ansible.builtin.copy:
38+
content: |
39+
node.session.foo = bar
40+
dest: "{{ edpm_iscsid_tripleo_config_dir }}/iscsid.conf"
41+
42+
- name: Create a dummy IQN
43+
ansible.builtin.copy:
44+
content: |
45+
InitiatorName=iqn.1994-05.com.redhat:abcdef012345
46+
dest: "{{ edpm_iscsid_tripleo_config_dir }}/initiatorname.iscsi"
47+
48+
- name: Create the IQN reset sentinel
49+
ansible.builtin.file:
50+
path: "{{ edpm_iscsid_tripleo_config_dir }}/.initiator_reset"
51+
state: touch
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
# Copyright 2025 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
18+
- name: Run the default verify playbook
19+
import_playbook: ../default/verify.yml
20+
21+
- name: Verify the adoption scenario
22+
hosts: all
23+
gather_facts: false
24+
become: true
25+
vars:
26+
test_helper_dir: "../../../../molecule/test-helpers"
27+
tasks:
28+
- name: Load role vars
29+
ansible.builtin.include_vars: ../../defaults/main.yml
30+
31+
- name: Verify the containerized iscsid config dir was renamed
32+
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_dir.yaml"
33+
vars:
34+
item: "{{ edpm_iscsid_tripleo_config_dir }}.adopted"
35+
36+
- name: Verify the containerized iscsid.conf file was adopted
37+
become: true
38+
ansible.builtin.command: |
39+
grep -q '^node.session.foo = bar$' /etc/iscsi/iscsid.conf
40+
changed_when: false
41+
42+
- name: Verify the IQN file was adopted
43+
ansible.builtin.command: |
44+
grep -q '^InitiatorName=iqn.1994-05.com.redhat:abcdef012345$' /etc/iscsi/initiatorname.iscsi
45+
changed_when: false
46+
47+
- name: Check the status of IQN reset sentinel file
48+
ansible.builtin.stat:
49+
path: /etc/iscsi/.initiator_reset
50+
register: sentinel_exists
51+
52+
- name: Assert the IQN reset sentinel file exists
53+
ansible.builtin.assert:
54+
that:
55+
- sentinel_exists.stat.exists
56+
fail_msg: "The IQN reset sentinel file does not exist"

roles/edpm_iscsid/molecule/default/converge.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,8 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17-
1817
- name: Converge
1918
hosts: all
2019
gather_facts: false
21-
become: true
22-
tasks:
23-
- name: Install iscsid
24-
ansible.builtin.import_role:
25-
name: osp.edpm.edpm_iscsid
26-
tasks_from: install.yml
27-
- name: Configure iscsid
28-
ansible.builtin.import_role:
29-
name: osp.edpm.edpm_iscsid
30-
tasks_from: configure.yml
31-
- name: Run iscsid
32-
ansible.builtin.import_role:
33-
name: osp.edpm.edpm_iscsid
34-
tasks_from: run.yml
20+
roles:
21+
- role: osp.edpm.edpm_iscsid
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
---
22
dependency:
33
name: galaxy
4-
options:
5-
role-file: collections.yml
64
driver:
75
name: delegated
86
options:
97
managed: false
108
ansible_connection_options:
119
ansible_connection: local
1210
platforms:
13-
- name: instance
11+
- name: edpm_iscsid
1412
provisioner:
1513
log: true
1614
name: ansible
1715
scenario:
1816
test_sequence:
19-
- dependency
2017
- destroy
2118
- create
2219
- prepare
2320
- converge
24-
- destroy
21+
- verify
2522
verifier:
2623
name: ansible

roles/edpm_iscsid/molecule/default/prepare.yml

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,57 @@
1313
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
16-
- name: Prepare test_deps
16+
17+
- name: Prepare
1718
hosts: all
1819
gather_facts: false
1920
roles:
2021
- role: ../../../../molecule/common/test_deps
21-
test_deps_extra_packages:
22-
- iproute
23-
- podman
24-
- name: Prepare
25-
hosts: instance
26-
roles:
2722
- role: osp.edpm.env_data
23+
24+
- name: Setup DUT
25+
hosts: all
26+
gather_facts: false
27+
vars:
28+
test_helper_dir: "../../../../molecule/test-helpers"
29+
tasks:
30+
- name: Load role vars
31+
ansible.builtin.include_vars: ../../defaults/main.yml
32+
33+
- name: Create systemd unit file for mocked legacy containerized services
34+
become: true
35+
ansible.builtin.copy:
36+
dest: "/etc/systemd/system/{{ legacy_service }}"
37+
content: |
38+
[Unit]
39+
Description=Mock containerized iscsid service
40+
41+
[Service]
42+
ExecStart=sleep 9999
43+
44+
[Install]
45+
WantedBy=multi-user.target
46+
mode: '0644'
47+
loop: "{{ edpm_iscsid_legacy_services }}"
48+
loop_control:
49+
loop_var: legacy_service
50+
51+
- name: Enable and start mocked legacy services
52+
become: true
53+
ansible.builtin.systemd_service:
54+
name: "{{ legacy_service }}"
55+
enabled: true
56+
state: started
57+
daemon_reload: true
58+
loop: "{{ edpm_iscsid_legacy_services }}"
59+
loop_control:
60+
loop_var: legacy_service
61+
62+
- name: Verify mocked legacy services are running
63+
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_systemd_unit.yaml"
64+
vars:
65+
item:
66+
name: "{{ legacy_service }}"
67+
loop: "{{ edpm_iscsid_legacy_services }}"
68+
loop_control:
69+
loop_var: legacy_service
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# Copyright 2025 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: Verify
18+
hosts: all
19+
gather_facts: false
20+
vars:
21+
test_helper_dir: "../../../../molecule/test-helpers"
22+
tasks:
23+
- name: Load role vars
24+
ansible.builtin.include_vars: ../../defaults/main.yml
25+
26+
- name: Verify the CHAP algorithms
27+
become: true
28+
ansible.builtin.command: |
29+
grep -q "^node.session.auth.chap_algs = {{ edpm_iscsid_chap_algs }}" /etc/iscsi/iscsid.conf
30+
changed_when: false
31+
32+
- name: Ensure iscsid service is enabled and running
33+
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_systemd_unit.yaml"
34+
loop:
35+
- { "name": "iscsid.service", "osp_service": false }
36+
37+
- name: Ensure legacy services are disabled and not running
38+
become: true
39+
ansible.builtin.shell: |
40+
! systemctl is-enabled "{{ legacy_service }}" && ! systemctl is-active "{{ legacy_service }}"
41+
changed_when: false
42+
loop: "{{ edpm_iscsid_legacy_services }}"
43+
loop_control:
44+
loop_var: legacy_service
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
*********************************
2+
Vagrant driver installation guide
3+
*********************************
4+
5+
Requirements
6+
============
7+
8+
* Vagrant
9+
* Libvirt
10+
11+
Install
12+
=======
13+
14+
Please refer to the `Virtual environment`_ documentation for installation best
15+
practices. If not using a virtual environment, please consider passing the
16+
widely recommended `'--user' flag`_ when invoking ``pip``.
17+
18+
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
19+
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
20+
21+
.. code-block:: bash
22+
23+
$ pip install 'molecule-plugins[vagrant]\>=23.5.0'
24+
25+
23.5.0+ is required to avoid a bug in the vagrant driver where molecule utils were not being imported correctly.
26+
This molecule env will be used for local development only and the default delegated env will be used for ci. As
27+
As a result, it's important that this scenario merely contains the info required to prepare the VM and calls the prepare, converge, and verify playbooks from default to keep them in sync.
28+
29+
Usage
30+
=====
31+
32+
Edit molecule.yml and update the test_sequence so it executes the sequence
33+
in the comments.
34+
35+
Modify the provisioner playbooks to specify the default or adoption scenarios.
36+
37+
Create a venv, and execute the vagrant test scenario.
38+
39+
.. code-block:: bash
40+
41+
(molecule-venv) $ molecule test --scenario-name vagrant
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../default/collections.yml

0 commit comments

Comments
 (0)