community.general/tests/unit/plugins/modules/test_pacemaker_resource.yaml
Felix Fontein 8f8a0e1d7c
Some checks are pending
EOL CI / EOL Sanity (Ⓐ2.17) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.10) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.12) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.7) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/3/) (push) Waiting to run
nox / Run extra sanity tests (push) Waiting to run
Fix __future__ imports, __metaclass__ = type, and remove explicit UTF-8 encoding statement for Python files (#10886)
* Adjust all __future__ imports:

for i in $(grep -REl "__future__.*absolute_import" plugins/ tests/); do
  sed -e 's/from __future__ import .*/from __future__ import annotations/g' -i $i;
done

* Remove all UTF-8 encoding specifications for Python source files:

for i in $(grep -REl '[-][*]- coding: utf-8 -[*]-' plugins/ tests/); do
  sed -e '/^# -\*- coding: utf-8 -\*-/d' -i $i;
done

* Remove __metaclass__ = type:

for i in $(grep -REl '__metaclass__ = type' plugins/ tests/); do
  sed -e '/^__metaclass__ = type/d' -i $i;
done
2025-10-10 19:52:04 +02:00

570 lines
19 KiB
YAML

# Copyright (c) Dexter Le (dextersydney2001@gmail.com)
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
---
anchors:
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
test_cases:
- id: test_missing_input
input: {}
output:
failed: true
msg: "state is present but all of the following are missing: resource_type, name"
- id: test_present_minimal_input_resource_not_exist
input:
state: present
name: virtual-ip
resource_type:
resource_name: IPaddr2
resource_option:
- "ip=[192.168.2.1]"
output:
changed: true
previous_value: null
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: resource or tag id 'virtual-ip' not found"
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 1
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=hacluster
dc-version=2.1.9-1.fc41-7188dbf
have-watchdog=false
err: ""
- command: [/testbin/pcs, resource, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]", --wait=300]
environ: *env-def
rc: 0
out: "Assumed agent name 'ocf:heartbeat:IPaddr2' (deduced from 'IPAddr2')"
err: ""
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- id: test_present_filled_input_resource_not_exist
input:
state: present
name: virtual-ip
resource_type:
resource_name: IPaddr2
resource_standard: ocf
resource_provider: heartbeat
resource_option:
- "ip=[192.168.2.1]"
resource_operation:
- operation_action: start
operation_option:
- timeout=1200
- operation_action: stop
operation_option:
- timeout=1200
- operation_action: monitor
operation_option:
- timeout=1200
resource_meta:
- test_meta1=123
- test_meta2=456
resource_argument:
argument_action: group
argument_option:
- test_group
resource_clone_ids:
- test_clone
resource_clone_meta:
- test_clone_meta1=789
wait: 200
output:
changed: true
previous_value: null
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: resource or tag id 'virtual-ip' not found"
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 1
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=hacluster
dc-version=2.1.9-1.fc41-7188dbf
have-watchdog=false
err: ""
- command: [/testbin/pcs, resource, create, virtual-ip, ocf:heartbeat:IPaddr2, "ip=[192.168.2.1]", op, start, timeout=1200, op, stop, timeout=1200, op, monitor, timeout=1200, meta, test_meta1=123, meta, test_meta2=456, --group, test_group, clone, test_clone, test_clone_meta1=789, --wait=200]
environ: *env-def
rc: 0
out: "Assumed agent name 'ocf:heartbeat:IPaddr2'"
err: ""
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- id: test_present_minimal_input_resource_exists
input:
state: present
name: virtual-ip
resource_type:
resource_name: IPaddr2
resource_option:
- "ip=[192.168.2.1]"
output:
changed: false
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 1
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=hacluster
dc-version=2.1.9-1.fc41-7188dbf
have-watchdog=false
err: ""
- command: [/testbin/pcs, resource, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]", --wait=300]
environ: *env-def
rc: 1
out: ""
err: "Error: 'virtual-ip' already exists\n"
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- id: test_present_minimal_input_resource_maintenance_mode
input:
state: present
name: virtual-ip
resource_type:
resource_name: IPaddr2
resource_option:
- "ip=[192.168.2.1]"
output:
changed: true
previous_value: null
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: ""
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 0
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=hacluster
dc-version=2.1.9-1.fc41-7188dbf
have-watchdog=false
maintenance-mode=true
err: ""
- command: [/testbin/pcs, resource, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]", --wait=300]
environ: *env-def
rc: 1
out: ""
err: "Error: resource 'virtual-ip' is not running on any node"
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped"
err: ""
- id: test_present_minimal_input_resource_maintenance_mode_version_change
input:
state: present
name: virtual-ip
resource_type:
resource_name: IPaddr2
resource_option:
- "ip=[192.168.2.1]"
output:
changed: true
previous_value: null
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: ""
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 0
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure: corosync
cluster-name: hacluster
dc-version: 2.1.9-1.fc41-7188dbf
have-watchdog: false
maintenance-mode: true
err: ""
- command: [/testbin/pcs, resource, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]", --wait=300]
environ: *env-def
rc: 1
out: ""
err: "Error: resource 'virtual-ip' is not running on any node"
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped"
err: ""
- id: test_absent_minimal_input_resource_not_exist
input:
state: absent
name: virtual-ip
output:
changed: false
previous_value: null
value: null
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: resource or tag id 'virtual-ip' not found"
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 1
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=hacluster
dc-version=2.1.9-1.fc41-7188dbf
have-watchdog=false
err: ""
- command: [/testbin/pcs, resource, remove, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: Resource 'virtual-ip' does not exist.\n"
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: resource or tag id 'virtual-ip' not found"
- id: test_absent_minimal_input_resource_exists
input:
state: absent
name: virtual-ip
output:
changed: true
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
value: null
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 1
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=hacluster
dc-version=2.1.9-1.fc41-7188dbf
have-watchdog=false
err: ""
- command: [/testbin/pcs, resource, remove, virtual-ip]
environ: *env-def
rc: 0
out: ""
err: "Attempting to stop: virtual-ip... Stopped\n"
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: resource or tag id 'virtual-ip' not found"
- id: test_absent_minimal_input_maintenance_mode
input:
state: absent
name: virtual-ip
output:
changed: true
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
value: null
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 0
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=hacluster
dc-version=2.1.9-1.fc41-7188dbf
have-watchdog=false
maintenance-mode=true
err: ""
- command: [/testbin/pcs, resource, remove, virtual-ip, --force]
environ: *env-def
rc: 0
out: ""
err: "Deleting Resource (and group) - virtual-ip"
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: resource or tag id 'virtual-ip' not found"
- id: test_enabled_minimal_input_resource_not_exists
input:
state: enabled
name: virtual-ip
output:
failed: true
msg: "pcs failed with error (rc=1): bundle/clone/group/resource/tag 'virtual-ip' does not exist"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: resource or tag id 'virtual-ip' not found"
- command: [/testbin/pcs, resource, enable, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "bundle/clone/group/resource/tag 'virtual-ip' does not exist"
- id: test_enabled_minimal_input_resource_exists
input:
state: enabled
name: virtual-ip
output:
changed: true
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Starting"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
err: ""
- command: [/testbin/pcs, resource, enable, virtual-ip]
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Starting"
err: ""
- id: test_disable_minimal_input_resource_not_exists
input:
state: disabled
name: virtual-ip
output:
failed: true
msg: "pcs failed with error (rc=1): bundle/clone/group/resource/tag 'virtual-ip' does not exist"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: resource or tag id 'virtual-ip' not found"
- command: [/testbin/pcs, resource, disable, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "bundle/clone/group/resource/tag 'virtual-ip' does not exist"
- id: test_disable_minimal_input_resource_exists
input:
state: disabled
name: virtual-ip
output:
changed: true
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- command: [/testbin/pcs, resource, disable, virtual-ip]
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
err: ""
- id: test_cleanup_minimal_input_initial_resources_not_exist
input:
state: cleanup
output:
changed: false
previous_value: "NO resources configured"
value: "NO resources configured"
mocks:
run_command:
- command: [/testbin/pcs, resource, status]
environ: *env-def
rc: 0
out: "NO resources configured"
err: ""
- command: [/testbin/pcs, resource, cleanup]
environ: *env-def
rc: 0
out: "Cleaned up all resources on all nodes"
err: ""
- command: [/testbin/pcs, resource, status]
environ: *env-def
rc: 0
out: "NO resources configured"
err: ""
- id: test_cleanup_minimal_input_initial_resources_exists
input:
state: cleanup
output:
changed: true
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
value: "NO resources configured"
mocks:
run_command:
- command: [/testbin/pcs, resource, status]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- command: [/testbin/pcs, resource, cleanup]
environ: *env-def
rc: 0
out: "Cleaned up all resources on all nodes"
err: ""
- command: [/testbin/pcs, resource, status]
environ: *env-def
rc: 0
out: "NO resources configured"
err: ""
- id: test_cleanup_specific_minimal_input_initial_resources_exists
input:
state: cleanup
name: virtual-ip
output:
changed: true
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
value: "NO resources configured"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- command: [/testbin/pcs, resource, cleanup, virtual-ip]
environ: *env-def
rc: 0
out: "Cleaned up virtual-ip on X"
err: ""
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: "NO resources configured"
err: ""
- id: test_clone_minimal_input_resource_not_exist
input:
state: cloned
name: virtual-ip
output:
failed: true
msg: "pcs failed with error (rc=1): Error: unable to find group or resource: virtual-ip"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 1
out: ""
err: "Error: resource or tag id 'virtual-ip' not found"
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 1
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=hacluster
dc-version=2.1.9-1.fc41-7188dbf
have-watchdog=false
err: ""
- command: [/testbin/pcs, resource, clone, virtual-ip, --wait=300]
environ: *env-def
rc: 1
out: ""
err: "Error: unable to find group or resource: virtual-ip"
- id: test_clone_filled_input_resource_exists
input:
state: cloned
name: virtual-ip
resource_clone_ids:
- test_clone
resource_clone_meta:
- test_clone_meta1=789
wait: 200
output:
changed: true
previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
value: " * Clone Set: virtual-ip-clone [virtual-ip]\t(ocf:heartbeat:IPAddr2):\t Started"
mocks:
run_command:
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""
- command: [/testbin/pcs, property, config]
environ: *env-def
rc: 1
out: |
Cluster Properties: cib-bootstrap-options
cluster-infrastructure=corosync
cluster-name=hacluster
dc-version=2.1.9-1.fc41-7188dbf
have-watchdog=false
err: ""
- command: [/testbin/pcs, resource, clone, virtual-ip, test_clone, meta, test_clone_meta1=789, --wait=200]
environ: *env-def
rc: 0
out: ""
err: ""
- command: [/testbin/pcs, resource, status, virtual-ip]
environ: *env-def
rc: 0
out: " * Clone Set: virtual-ip-clone [virtual-ip]\t(ocf:heartbeat:IPAddr2):\t Started"
err: ""