From 8f0126b90b2f4dc8671d9cbd469eeaba25062f5d Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Sun, 26 Jun 2022 14:15:14 +0200 Subject: [PATCH] Added running end2end tests against mocked environments Details: * Added a new target 'end2end_mocked' to the Makefile that runs the end2end tests against mock environments defined with a new HMC inventory file (mocked_inventory.yaml) and a new HMC vault file (mocked_vault.yaml). * Added the new make target to the GitHub Actions test workflow. * Added new mock files that define a mocked HMC for thee tests: * mocked_z14_classic.yaml - for an HMC managing a z14 in classic mode * mocked_z14_dpm.yaml - for an HMC managing a z14 in DPM mode * Enabled testing with mock support in the existing end2end testcases: * test_zhmc_partition.py * test_zhmc_user.py * Increased the minimum version of zhmcclient to 1.3.1, in order to pick up the fix for the filepath AttributeError. Signed-off-by: Andreas Maier --- .github/workflows/test.yml | 6 + Makefile | 8 +- docs/source/release_notes.rst | 9 + minimum-constraints.txt | 2 +- requirements.txt | 2 +- tests/end2end/mocked_inventory.yaml | 54 ++ tests/end2end/mocked_vault.yaml | 35 ++ tests/end2end/mocked_z14_classic.yaml | 462 ++++++++++++++++++ tests/end2end/mocked_z14_dpm.yaml | 677 ++++++++++++++++++++++++++ tests/end2end/test_zhmc_partition.py | 4 +- tests/end2end/test_zhmc_user.py | 10 +- 11 files changed, 1262 insertions(+), 7 deletions(-) create mode 100644 tests/end2end/mocked_inventory.yaml create mode 100644 tests/end2end/mocked_vault.yaml create mode 100644 tests/end2end/mocked_z14_classic.yaml create mode 100644 tests/end2end/mocked_z14_dpm.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f2801838..9e2187e02 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -138,6 +138,12 @@ jobs: # TESTCASES: test_partition.py run: | make test + - name: Run mocked end2end test + env: + PACKAGE_LEVEL: ${{ matrix.package_level }} + # TESTCASES: test_partition.py + run: | + make end2end_mocked - name: Send coverage result to coveralls.io env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index 219d09163..cd96b77c3 100644 --- a/Makefile +++ b/Makefile @@ -168,7 +168,8 @@ help: @echo ' docslocal - Build the documentation from local repo contents in: $(doc_build_local_dir)' @echo ' linkcheck - Check links in documentation' @echo ' all - Do all of the above' - @echo ' end2end - Run end2end tests' + @echo ' end2end - Run end2end tests using environment defined by TESTINVENTORY' + @echo ' end2end_mocked - Run end2end tests using mocked environment' @echo ' upload - Publish the collection to Ansible Galaxy' @echo ' uploadhub - Publish the collection to Ansible AutomationHub' @echo ' clobber - Remove any produced files' @@ -245,6 +246,11 @@ end2end: _check_version develop_$(pymn).done bash -c 'PYTHONWARNINGS=default ANSIBLE_LIBRARY=$(module_py_dir) PYTHONPATH=. TESTEND2END_LOAD=true pytest -v $(pytest_opts) $(test_dir)/end2end' @echo '$@ done.' +.PHONY: end2end_mocked +end2end_mocked: _check_version develop_$(pymn).done + bash -c 'PYTHONWARNINGS=default ANSIBLE_LIBRARY=$(module_py_dir) PYTHONPATH=. TESTEND2END_LOAD=true TESTINVENTORY=$(test_dir)/end2end/mocked_inventory.yaml TESTVAULT=$(test_dir)/end2end/mocked_vault.yaml pytest -v $(pytest_opts) $(test_dir)/end2end' + @echo '$@ done.' + .PHONY: upload upload: _check_version $(dist_file) ifneq ($(findstring dev,$(collection_version)),) diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst index 6af680400..e62104e99 100644 --- a/docs/source/release_notes.rst +++ b/docs/source/release_notes.rst @@ -44,6 +44,15 @@ Availability: `AutomationHub`_, `Galaxy`_, `GitHub`_ * Added support for Ansible 6.0.0 by adding an ignore-2.13.txt file to the sanity tests. (issue #533) +* Added a new make target 'end2end_mocked' that runs the end2end + tests against mock environments defined with a new HMC inventory file + (mocked_inventory.yaml) and a new HMC vault file (mocked_vault.yaml), + and new mock files mocked_z14_classic.yaml and mocked_z14_dpm.yaml. + (part of issue #396) + +* Increased the minimum version of zhmcclient to 1.3.1, in order to pick + up fixes. (part of issue #396) + **Cleanup:** **Known issues:** diff --git a/minimum-constraints.txt b/minimum-constraints.txt index 2721b62a9..61c36cb34 100644 --- a/minimum-constraints.txt +++ b/minimum-constraints.txt @@ -91,7 +91,7 @@ ansible==2.9.0.0 requests==2.22.0; python_version <= '3.9' requests==2.25.0; python_version >= '3.10' -zhmcclient==1.3.0 +zhmcclient==1.3.1 # Indirect dependencies for installation (must be consistent with requirements.txt) diff --git a/requirements.txt b/requirements.txt index 593ea4a39..655c1a0b5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ requests>=2.22.0; python_version <= '3.9' requests>=2.25.0; python_version >= '3.10' # git+https://github.com/zhmcclient/python-zhmcclient@master#egg=zhmcclient -zhmcclient>=1.3.0 +zhmcclient>=1.3.1 # Indirect dependencies are not specified in this file, unless needed to solve versioning issues: diff --git a/tests/end2end/mocked_inventory.yaml b/tests/end2end/mocked_inventory.yaml new file mode 100644 index 000000000..a4389a028 --- /dev/null +++ b/tests/end2end/mocked_inventory.yaml @@ -0,0 +1,54 @@ +--- +# HMC inventory file with mocked HMCs for end2end tests run by GitHub Actions +# +# This file defines only mocked HMCs (using the zhmcclient mock +# support) for the purpose of end2end tests against these HMCs. +# The file must have the format defined in +# zhmcclient/testutils/hmc_inventory_file.py of the python-zhmcclient project. +# +# HMC inventory files conform to the format of HMC inventory files in YAML +# format and define specific additional variables for HMCs. +# +# Brief description of the HMC inventory file format: +# +# all: # the top-level HMC group +# hosts: +# : # DNS hostname, IP address, or nickname of HMC +# description: +# contact: +# access_via: +# ansible_host: # if real HMC and nickname is used +# mock_file: # if mocked HMC +# cpcs: +# : +# : +# : # additional variables for HMC +# vars: +# : # additional variables for all HMCs in group +# children: +# : # a child HMC group +# hosts: ... # variables are inherited from parent group +# vars: ... +# children: ... + +all: + hosts: + mocked_z14_classic: + description: "Mocked z14 in classic mode" + mock_file: "mocked_z14_classic.yaml" + cpcs: + CPC1: + machine_type: "2964" + dpm_enabled: false + mocked_z14_dpm: + description: "Mocked z14 in DPM mode" + mock_file: "mocked_z14_dpm.yaml" + cpcs: + CPC1: + machine_type: "3906" + dpm_enabled: true + children: + default: + hosts: + mocked_z14_classic: + mocked_z14_dpm: diff --git a/tests/end2end/mocked_vault.yaml b/tests/end2end/mocked_vault.yaml new file mode 100644 index 000000000..0001cec89 --- /dev/null +++ b/tests/end2end/mocked_vault.yaml @@ -0,0 +1,35 @@ +--- +# HMC vault file with mocked HMCs for end2end tests run by GitHub Actions +# +# This file defines the credentials for mocked HMCs for use by the +# zhmcclient.testutils module of the python-zhmcclient project. +# +# The file must have the format defined in +# zhmcclient/testutils/hmc_vault_file.py of the python-zhmcclient project. +# +# HMC vault files conform to the format of Ansible vault files in YAML +# format and define specific variables for HMC authentication. +# +# Brief description of the file format: +# +# hmc_auth: +# : # DNS hostname, IP address, or nickname of HMC +# userid: +# password: +# verify: +# ca_certs: +# : # allowed but ignored +# +# Notes for this example file: +# * To use this example file, copy it to `~/.zhmc_vault.yaml` which is the +# default path name used. + +hmc_auth: + mocked_z14_classic: + userid: ensadmin + password: password + verify: false + mocked_z14_dpm: + userid: ensadmin + password: password + verify: false diff --git a/tests/end2end/mocked_z14_classic.yaml b/tests/end2end/mocked_z14_classic.yaml new file mode 100644 index 000000000..c87823a51 --- /dev/null +++ b/tests/end2end/mocked_z14_classic.yaml @@ -0,0 +1,462 @@ +--- +# Definition of a mocked HMC for end2end tests run by GitHub Actions. +# The file must have the format defined in FAKED_HMC_DEFINITION_SCHEMA in +# zhmcclient_mock/_session.py of the python-zhmcclient project. +# +# This mocked HMC manages a single z14 in classic mode. + +hmc_definition: + host: hmc1 + api_version: '2.40' + + consoles: + - properties: + # class: created automatically + # parent: created automatically + object-uri: /api/console + object-id: hmc1 + name: HMC1 + description: "primary HMC" + ip-swapping-available: true + is-auto-switch-enabled: false + is-locked: false + paired-role: '' + version: 2.14.1 + machine-info: + machine-type: '2461' + machine-serial: DK67009 + machine-model: TW1 + network-info: + this-hmc: + - domain-name: boeblingen.de.ibm.com + is-private: false + hmc-name: HMCM12 + ipv4-address: + - ip-address: 9.152.151.47 + subnet-mask: 255.255.254.0 + interface-name: eth0 + mac: 00106f0d8409 + ipv6-address: + - prefix-length: 64 + ip-address: fe80:0:0:0:210:6fff:fe0d:8409 + paired-hmc: null + ec-mcl-description: + ec: + - number: P41499 + part-number: 01LL062 + mcl: + - level: '333' + type: retrieved + last-update: 1650524126000 + - level: '333' + type: activated + last-update: 1650526481000 + - level: '327' + type: accepted + last-update: 1642750400000 + - level: '333' + type: installable-concurrent + last-update: null + - level: '328' + type: removable-concurrent + last-update: null + description: Hardware Management Console Framework + type: SYSTEM + - number: P41470 + part-number: 01LL058 + mcl: + - level: '2' + type: retrieved + last-update: 1566551669000 + - level: '2' + type: activated + last-update: 1566551779000 + - level: '2' + type: accepted + last-update: 1566553286000 + - level: '2' + type: installable-concurrent + last-update: null + - level: '000' + type: removable-concurrent + last-update: null + description: Hardware Management Console Platform Firmware + type: HMCBIOS + + users: + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + object-id: pedebug + name: PEDEBUG + description: "Product engineering level user" + allow-management-interfaces: true + allow-remote-access: true + authentication-type: local + default-group-uri: null + disable-delay: 1 + disabled: false + disruptive-pw-required: true + disruptive-text-required: false + email-address: null + force-password-change: false + force-shared-secret-key-change: null + idle-timeout: 0 + inactivity-timeout: 0 + is-locked: false + ldap-server-definition-uri: null + max-failed-logins: 3 + max-web-services-api-sessions: 1000 + min-pw-change-time: 0 + multi-factor-authentication-required: false + password: bla + password-expires: -1 + password-rule-uri: /api/console/password-rules/passwordrule1 + replication-overwrite-possible: false + session-timeout: 0 + type: system-defined + userid-on-ldap-server: null + verify-timeout: 15 + web-services-api-session-idle-timeout: 360 + user-roles: + - /api/user-roles/hmc-all-system-managed-objects + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + object-id: user1 + name: USER1 + description: "Standard user 1" + allow-management-interfaces: true + allow-remote-access: true + authentication-type: local + default-group-uri: null + disable-delay: 1 + disabled: false + disruptive-pw-required: true + disruptive-text-required: false + email-address: null + force-password-change: false + force-shared-secret-key-change: null + idle-timeout: 0 + inactivity-timeout: 0 + is-locked: false + ldap-server-definition-uri: null + max-failed-logins: 3 + max-web-services-api-sessions: 1000 + min-pw-change-time: 0 + multi-factor-authentication-required: false + password: bla + password-expires: -1 + password-rule-uri: /api/console/password-rules/passwordrule1 + replication-overwrite-possible: false + session-timeout: 0 + type: standard + userid-on-ldap-server: null + verify-timeout: 15 + web-services-api-session-idle-timeout: 360 + user-roles: + - /api/user-roles/hmc-all-system-managed-objects + + user_roles: + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + object-id: hmc-all-system-managed-objects + name: hmc-all-system-managed-objects + description: "All system managed objects" + associated-system-defined-user-role-uri: null + is-inheritance-enabled: false + is-locked: false + replication-overwrite-possible: false + type: system-defined + permissions: + - permitted-object: partition + permitted-object-type: object-class + - permitted-object: cpc + permitted-object-type: object-class + + user_patterns: + - properties: + element-id: userpattern1 + name: User pattern 1 + + password_rules: + - properties: + element-id: passwordrule1 + name: Password rule 1 + - properties: + element-id: Basic + name: Basic + + tasks: + - properties: + # class: created automatically + # parent: created automatically + # element-uri: created automatically + element-id: new-performance-policy + name: new-performance-policy + description: Create a new performance policy for the workload + view-only-mode-supported: false + + ldap_server_definitions: + - properties: + element-id: lsd1 + name: LDAP server definition 1 + + storage_groups: + - properties: + object-id: sg1 + name: Storage group 1 + shared: false + type: fcp + fulfillment-state: complete + storage_volumes: + - properties: + element-id: sv1 + name: Storage volume 1 + fulfillment-state: complete + site: 10.0 + usage: boot + + cpcs: + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + object-id: cpc1 + name: "CPC1" + description: "Faked CPC CPC1 (z13 in DPM mode)" + acceptable-status: [active] + additional-status: '' + auto-start-list: [] + cbu-activation-date: 0 + cbu-expiration-date: 0 + cbu-number-of-tests-left: 0 + cpc-node-descriptor: '00' + cpc-power-cap-allowed: null + cpc-power-cap-current: null + cpc-power-cap-maximum: null + cpc-power-cap-minimum: null + cpc-power-capping-state: null + cpc-power-consumption: 5818 + cpc-power-rating: 28000 + cpc-power-save-allowed: allowed + cpc-power-saving-state: high-performance + cpc-power-saving: high-performance + cpc-serial-number: "0000000CPC1" + degraded-status: [not-degraded] + dpm-enabled: false + has-automatic-se-switch-enabled: false + has-hardware-messages: true + has-temporary-capacity-change-allowed: false + has-unacceptable-status: true + iml-mode: lpar + is-cbu-activated: false + is-cbu-enabled: false + is-cbu-installed: false + is-cpacf-enabled: true + is-ensemble-member: false + is-locked: false + is-on-off-cod-activated: false + is-on-off-cod-enabled: true + is-on-off-cod-installed: false + is-real-cbu-available: false + is-service-required: true + lan-interface1-address: 00106f0d81cb + lan-interface1-type: ethernet + lan-interface2-address: 00106f0d81cc + lan-interface2-type: ethernet + last-energy-advice-time: 1654609202407 + machine-model: 'M01' + machine-serial-number: "0000000CPC1" + machine-type: '3906' + management-enablement-level: manage + maximum-alternate-storage-sites: 1 + maximum-hipersockets: 32 + maximum-partitions: 85 + msu-permanent-plus-billable: 3068 + msu-permanent-plus-temporary: 3068 + msu-permanent: 3068 + network1-ipv4-alt-ipaddr: null + network1-ipv4-mask: 255.255.254.0 + network1-ipv4-pri-ipaddr: 9.152.151.39 + network2-ipv4-alt-ipaddr: null + network2-ipv4-mask: 0.0.0.0 + network2-ipv4-pri-ipaddr: null + network2-ipv6-info: [] + on-off-cod-activation-date: 0 + processor-count-aap: 0 + processor-count-cbp: 0 + processor-count-defective: 0 + processor-count-general-purpose: 20 + processor-count-icf: 0 + processor-count-ifl: 10 + processor-count-iip: 3 + processor-count-pending-aap: 0 + processor-count-pending-cbp: 0 + processor-count-pending-general-purpose: 0 + processor-count-pending-icf: 0 + processor-count-pending-ifl: 0 + processor-count-pending-iip: 0 + processor-count-pending-service-assist: 0 + processor-count-pending: 0 + processor-count-service-assist: 5 + processor-count-spare: 0 + se-version: 2.14.1 + software-model-permanent-plus-billable: '720' + software-model-permanent-plus-temporary: '720' + software-model-permanent: '720' + status: active + storage-customer-available: 1105920 + storage-customer-central: 16384 + storage-customer-expanded: 0 + storage-customer: 1114112 + storage-hardware-system-area: 196608 + storage-total-installed: 1310720 + storage-vfm-increment-size: 16 + storage-vfm-total: 0 + zcpc-ambient-temperature: 24.0 + zcpc-dew-point: 12.199999809265137 + zcpc-exhaust-temperature: 30.0 + zcpc-heat-load-forced-air: 19865 + zcpc-heat-load-water: 0 + zcpc-heat-load: 19865 + zcpc-humidity: 47 + zcpc-maximum-potential-heat-load: 25714 + zcpc-maximum-potential-power: 7531 + zcpc-power-cap-allowed: null + zcpc-power-cap-current: null + zcpc-power-cap-maximum: null + zcpc-power-cap-minimum: null + zcpc-power-capping-state: null + zcpc-power-consumption: 5818 + zcpc-power-rating: 28000 + zcpc-power-save-allowed: under-group-control + zcpc-power-saving-state: high-performance + zcpc-power-saving: high-performance + available-features-list: + - name: dpm-storage-management + description: The DPM storage management approach in which FCP and FICON storage + resources are defined in Storage Groups, which are attached to Partitions. + state: true + ec-mcl-description: + action: + - pending: false + type: channel-config + activation: current + - pending: false + type: coupling-facility-reactivation + activation: current + - pending: false + type: power-on-reset-tracking + activation: current + - pending: false + type: zhybrid-blades-activation + activation: current + - pending: false + type: channel-config + activation: next + - pending: false + type: coupling-facility-reactivation + activation: next + - pending: false + type: power-on-reset-tracking + activation: next + - pending: false + type: zhybrid-blades-activation + activation: next + ec: + - number: P41414 + part-number: 01LL001 + mcl: + - level: '373' + type: retrieved + last-update: 1650509077817 + - level: '373' + type: activated + last-update: 1650531050817 + - level: '364' + type: accepted + last-update: 1649742886817 + - level: '373' + type: installable-concurrent + last-update: 943916400817 + - level: '365' + type: removable-concurrent + last-update: 943916400817 + description: SE Framework + type: Base EC + - number: P41415 + part-number: 01LL002 + mcl: + - level: '000' + type: retrieved + last-update: null + - level: '000' + type: activated + last-update: null + - level: '000' + type: accepted + last-update: null + - level: '000' + type: installable-concurrent + last-update: null + - level: '000' + type: removable-concurrent + last-update: null + description: Concurrent Upgrade Sync Point + type: Other Optional EC + network1-ipv6-info: + - prefix: 64 + pri-ip-address: fe80::210:6fff:fe0d:81cb%eth0 + type: link-local + alt-ip-address: fe80::210:6fff:fe0d:820b%eth0 + + lpars: + - properties: + object-id: lpar1 + name: "LPAR1" + partition-number: 0x41 + partition-identifier: 0x41 + status: "operating" + activation-mode: "linux" + next-activation-profile-name: "LPAR1" + last-used-activation-profile: "LPAR1" + - properties: + object-id: lpar2 + name: "LPAR2" + partition-number: 0x42 + partition-identifier: 0x42 + status: "not-activated" + activation-mode: "not-set" + next-activation-profile-name: "LPAR2" + last-used-activation-profile: "LPAR2" + + reset_activation_profiles: + - properties: + name: "CPC1" + iocds-name: "ABC" + + load_activation_profiles: + - properties: + name: "STANDARDLOAD" + ipl-type: "ipltype-standard" + ipl-address: "189AB" + - properties: + name: "SCSILOAD" + ipl-type: "ipltype-scsi" + worldwide-port-name: "1234" + logical-unit-number: "1234" + boot-record-lba: "1234" + disk-partition-id: 0 + + image_activation_profiles: + - properties: + name: "LPAR1" + # TODO: Add more properties + - properties: + name: "LPAR2" + # TODO: Add more properties diff --git a/tests/end2end/mocked_z14_dpm.yaml b/tests/end2end/mocked_z14_dpm.yaml new file mode 100644 index 000000000..ac80cb172 --- /dev/null +++ b/tests/end2end/mocked_z14_dpm.yaml @@ -0,0 +1,677 @@ +--- +# Definition of a mocked HMC for end2end tests run by GitHub Actions. +# The file must have the format defined in FAKED_HMC_DEFINITION_SCHEMA in +# zhmcclient_mock/_session.py of the python-zhmcclient project. +# +# This mocked HMC manages a single z14 in DPM mode. + +hmc_definition: + host: hmc1 + api_version: '2.40' + + consoles: + - properties: + # class: created automatically + # parent: created automatically + object-uri: /api/console + object-id: hmc1 + name: HMC1 + description: "primary HMC" + ip-swapping-available: true + is-auto-switch-enabled: false + is-locked: false + paired-role: '' + version: 2.14.1 + machine-info: + machine-type: '2461' + machine-serial: DK67009 + machine-model: TW1 + network-info: + this-hmc: + - domain-name: boeblingen.de.ibm.com + is-private: false + hmc-name: HMCM12 + ipv4-address: + - ip-address: 9.152.151.47 + subnet-mask: 255.255.254.0 + interface-name: eth0 + mac: 00106f0d8409 + ipv6-address: + - prefix-length: 64 + ip-address: fe80:0:0:0:210:6fff:fe0d:8409 + paired-hmc: null + ec-mcl-description: + ec: + - number: P41499 + part-number: 01LL062 + mcl: + - level: '333' + type: retrieved + last-update: 1650524126000 + - level: '333' + type: activated + last-update: 1650526481000 + - level: '327' + type: accepted + last-update: 1642750400000 + - level: '333' + type: installable-concurrent + last-update: null + - level: '328' + type: removable-concurrent + last-update: null + description: Hardware Management Console Framework + type: SYSTEM + - number: P41470 + part-number: 01LL058 + mcl: + - level: '2' + type: retrieved + last-update: 1566551669000 + - level: '2' + type: activated + last-update: 1566551779000 + - level: '2' + type: accepted + last-update: 1566553286000 + - level: '2' + type: installable-concurrent + last-update: null + - level: '000' + type: removable-concurrent + last-update: null + description: Hardware Management Console Platform Firmware + type: HMCBIOS + + users: + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + object-id: pedebug + name: PEDEBUG + description: "Product engineering level user" + allow-management-interfaces: true + allow-remote-access: true + authentication-type: local + default-group-uri: null + disable-delay: 1 + disabled: false + disruptive-pw-required: true + disruptive-text-required: false + email-address: null + force-password-change: false + force-shared-secret-key-change: null + idle-timeout: 0 + inactivity-timeout: 0 + is-locked: false + ldap-server-definition-uri: null + max-failed-logins: 3 + max-web-services-api-sessions: 1000 + min-pw-change-time: 0 + multi-factor-authentication-required: false + password: bla + password-expires: -1 + password-rule-uri: /api/console/password-rules/passwordrule1 + replication-overwrite-possible: false + session-timeout: 0 + type: system-defined + userid-on-ldap-server: null + verify-timeout: 15 + web-services-api-session-idle-timeout: 360 + user-roles: + - /api/user-roles/hmc-all-system-managed-objects + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + object-id: user1 + name: USER1 + description: "Standard user 1" + allow-management-interfaces: true + allow-remote-access: true + authentication-type: local + default-group-uri: null + disable-delay: 1 + disabled: false + disruptive-pw-required: true + disruptive-text-required: false + email-address: null + force-password-change: false + force-shared-secret-key-change: null + idle-timeout: 0 + inactivity-timeout: 0 + is-locked: false + ldap-server-definition-uri: null + max-failed-logins: 3 + max-web-services-api-sessions: 1000 + min-pw-change-time: 0 + multi-factor-authentication-required: false + password: bla + password-expires: -1 + password-rule-uri: /api/console/password-rules/passwordrule1 + replication-overwrite-possible: false + session-timeout: 0 + type: standard + userid-on-ldap-server: null + verify-timeout: 15 + web-services-api-session-idle-timeout: 360 + user-roles: + - /api/user-roles/hmc-all-system-managed-objects + + user_roles: + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + object-id: hmc-all-system-managed-objects + name: hmc-all-system-managed-objects + description: "All system managed objects" + associated-system-defined-user-role-uri: null + is-inheritance-enabled: false + is-locked: false + replication-overwrite-possible: false + type: system-defined + permissions: + - permitted-object: partition + permitted-object-type: object-class + - permitted-object: cpc + permitted-object-type: object-class + + user_patterns: + - properties: + element-id: userpattern1 + name: User pattern 1 + + password_rules: + - properties: + element-id: passwordrule1 + name: Password rule 1 + - properties: + element-id: Basic + name: Basic + + tasks: + - properties: + # class: created automatically + # parent: created automatically + # element-uri: created automatically + element-id: new-performance-policy + name: new-performance-policy + description: Create a new performance policy for the workload + view-only-mode-supported: false + + ldap_server_definitions: + - properties: + element-id: lsd1 + name: LDAP server definition 1 + + storage_groups: + - properties: + object-id: sg1 + name: Storage group 1 + shared: false + type: fcp + fulfillment-state: complete + storage_volumes: + - properties: + element-id: sv1 + name: Storage volume 1 + fulfillment-state: complete + site: 10.0 + usage: boot + + cpcs: + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + object-id: cpc1 + name: "CPC1" + description: "Faked CPC CPC1 (z13 in DPM mode)" + acceptable-status: [active] + additional-status: '' + auto-start-list: [] + cbu-activation-date: 0 + cbu-expiration-date: 0 + cbu-number-of-tests-left: 0 + cpc-node-descriptor: '00' + cpc-power-cap-allowed: null + cpc-power-cap-current: null + cpc-power-cap-maximum: null + cpc-power-cap-minimum: null + cpc-power-capping-state: null + cpc-power-consumption: 5818 + cpc-power-rating: 28000 + cpc-power-save-allowed: allowed + cpc-power-saving-state: high-performance + cpc-power-saving: high-performance + cpc-serial-number: "0000000CPC1" + degraded-status: [not-degraded] + dpm-enabled: true + has-automatic-se-switch-enabled: false + has-hardware-messages: true + has-temporary-capacity-change-allowed: false + has-unacceptable-status: true + iml-mode: dpm + is-cbu-activated: false + is-cbu-enabled: false + is-cbu-installed: false + is-cpacf-enabled: true + is-ensemble-member: false + is-locked: false + is-on-off-cod-activated: false + is-on-off-cod-enabled: true + is-on-off-cod-installed: false + is-real-cbu-available: false + is-service-required: true + lan-interface1-address: 00106f0d81cb + lan-interface1-type: ethernet + lan-interface2-address: 00106f0d81cc + lan-interface2-type: ethernet + last-energy-advice-time: 1654609202407 + machine-model: 'M01' + machine-serial-number: "0000000CPC1" + machine-type: '3906' + management-enablement-level: manage + maximum-alternate-storage-sites: 1 + maximum-hipersockets: 32 + maximum-partitions: 85 + msu-permanent-plus-billable: 3068 + msu-permanent-plus-temporary: 3068 + msu-permanent: 3068 + network1-ipv4-alt-ipaddr: null + network1-ipv4-mask: 255.255.254.0 + network1-ipv4-pri-ipaddr: 9.152.151.39 + network2-ipv4-alt-ipaddr: null + network2-ipv4-mask: 0.0.0.0 + network2-ipv4-pri-ipaddr: null + network2-ipv6-info: [] + on-off-cod-activation-date: 0 + processor-count-aap: 0 + processor-count-cbp: 0 + processor-count-defective: 0 + processor-count-general-purpose: 20 + processor-count-icf: 0 + processor-count-ifl: 10 + processor-count-iip: 3 + processor-count-pending-aap: 0 + processor-count-pending-cbp: 0 + processor-count-pending-general-purpose: 0 + processor-count-pending-icf: 0 + processor-count-pending-ifl: 0 + processor-count-pending-iip: 0 + processor-count-pending-service-assist: 0 + processor-count-pending: 0 + processor-count-service-assist: 5 + processor-count-spare: 0 + se-version: 2.14.1 + software-model-permanent-plus-billable: '720' + software-model-permanent-plus-temporary: '720' + software-model-permanent: '720' + status: active + storage-customer-available: 1105920 + storage-customer-central: 16384 + storage-customer-expanded: 0 + storage-customer: 1114112 + storage-hardware-system-area: 196608 + storage-total-installed: 1310720 + storage-vfm-increment-size: 16 + storage-vfm-total: 0 + zcpc-ambient-temperature: 24.0 + zcpc-dew-point: 12.199999809265137 + zcpc-exhaust-temperature: 30.0 + zcpc-heat-load-forced-air: 19865 + zcpc-heat-load-water: 0 + zcpc-heat-load: 19865 + zcpc-humidity: 47 + zcpc-maximum-potential-heat-load: 25714 + zcpc-maximum-potential-power: 7531 + zcpc-power-cap-allowed: null + zcpc-power-cap-current: null + zcpc-power-cap-maximum: null + zcpc-power-cap-minimum: null + zcpc-power-capping-state: null + zcpc-power-consumption: 5818 + zcpc-power-rating: 28000 + zcpc-power-save-allowed: under-group-control + zcpc-power-saving-state: high-performance + zcpc-power-saving: high-performance + available-features-list: + - name: dpm-storage-management + description: The DPM storage management approach in which FCP and FICON storage + resources are defined in Storage Groups, which are attached to Partitions. + state: true + ec-mcl-description: + action: + - pending: false + type: channel-config + activation: current + - pending: false + type: coupling-facility-reactivation + activation: current + - pending: false + type: power-on-reset-tracking + activation: current + - pending: false + type: zhybrid-blades-activation + activation: current + - pending: false + type: channel-config + activation: next + - pending: false + type: coupling-facility-reactivation + activation: next + - pending: false + type: power-on-reset-tracking + activation: next + - pending: false + type: zhybrid-blades-activation + activation: next + ec: + - number: P41414 + part-number: 01LL001 + mcl: + - level: '373' + type: retrieved + last-update: 1650509077817 + - level: '373' + type: activated + last-update: 1650531050817 + - level: '364' + type: accepted + last-update: 1649742886817 + - level: '373' + type: installable-concurrent + last-update: 943916400817 + - level: '365' + type: removable-concurrent + last-update: 943916400817 + description: SE Framework + type: Base EC + - number: P41415 + part-number: 01LL002 + mcl: + - level: '000' + type: retrieved + last-update: null + - level: '000' + type: activated + last-update: null + - level: '000' + type: accepted + last-update: null + - level: '000' + type: installable-concurrent + last-update: null + - level: '000' + type: removable-concurrent + last-update: null + description: Concurrent Upgrade Sync Point + type: Other Optional EC + network1-ipv6-info: + - prefix: 64 + pri-ip-address: fe80::210:6fff:fe0d:81cb%eth0 + type: link-local + alt-ip-address: fe80::210:6fff:fe0d:820b%eth0 + + capacity_groups: + - properties: + # class: created automatically + # parent: created automatically + # element-uri: created automatically + element-id: testgroup + name: TESTGROUP + description: 'Capacity group TESTGROUP' + absolute-general-purpose-proc-cap: 5.0 + absolute-ifl-proc-cap: 0.0 + capping-enabled: true + class: capacity-group + short-name: TESTGRPT + partition-uris: + - /api/partitions/0a796b76-e9e6-11eb-80e2-00106f0d81c9 + + adapters: + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + object-id: osa1 + name: "OSA1" + description: "Faked OSA adapter OSA1 in CPC1" + adapter-id: "108" + status: active + state: online + physical-channel-status: operating + type: osd + adapter-family: osa + detected-card-type: "osa-express-6s-1000base-t" + card-location: "A14B-D104J.01-D204J.01" + configured-capacity: 63 + maximum-total-capacity: 1920 + ports: + - properties: + element-id: port0 + name: "Port 0" + description: "Faked port 0 of OSA adapter OSA1 in CPC1" + index: 0 + - properties: + element-id: port1 + name: "Port 1" + description: "Faked port 1 of OSA adapter OSA1 in CPC1" + index: 1 + - properties: + object-id: fcp1 + name: "FCP1" + description: "Faked FCP adapter FCP1 in CPC1" + adapter-id: "118" + status: active + state: online + physical-channel-status: operating + type: fcp + adapter-family: ficon + detected-card-type: "ficon-express-16s" + card-location: "A14B-D114J.01" + configured-capacity: 63 + maximum-total-capacity: 1920 + ports: + - properties: + element-id: port0 + name: "Port 0" + description: "Faked port 0 of FCP adapter FCP1 in CPC1" + index: 0 + + virtual_switches: + - properties: + object-id: vs-osa1 + name: "Virtual Switch for OSA1" + description: "Faked Virtual Switch for OSA adapter OSA1 in CPC1" + backing-adapter-uri: /api/adapters/osa1 + port: 0 + + partitions: + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + # nic-uris: created automatically + # hba-uris: created automatically + # virtual-function-uris: created automatically + # storage-group-uris: created automatically + object-id: part1 + name: "PART1" + description: "Linux partition PART1 on CPC1" + acceptable-status: [active] + access-basic-counter-set: false + access-basic-sampling: false + access-coprocessor-group-set: false + access-crypto-activity-counter-set: false + access-diagnostic-sampling: false + access-extended-counter-set: false + access-global-performance-data: false + access-problem-state-counter-set: false + auto-start: false + autogenerate-partition-id: true + boot-configuration-selector: 0 + boot-device: test-operating-system + boot-ftp-host: null + boot-ftp-insfile: null + boot-ftp-username: null + boot-iso-image-name: null + boot-iso-ins-file: null + boot-logical-unit-number: '' + boot-network-device: null + boot-os-specific-parameters: '' + boot-record-lba: '0' + boot-removable-media-type: null + boot-removable-media: null + boot-storage-device: null + boot-storage-volume: null + boot-timeout: 60 + boot-world-wide-port-name: '' + cp-absolute-processor-capping-value: 1.0 + cp-absolute-processor-capping: false + cp-processing-weight-capped: false + cp-processors: 1 + crypto-configuration: null + current-cp-processing-weight: 1 + current-ifl-processing-weight: 1 + degraded-adapters: [] + has-unacceptable-status: true + ifl-absolute-processor-capping-value: 1.0 + ifl-absolute-processor-capping: false + ifl-processing-weight-capped: false + ifl-processors: 0 + initial-cp-processing-weight: 100 + initial-ifl-processing-weight: 100 + initial-memory: 4096 + ipl-load-parameter: '' + is-locked: false + maximum-cp-processing-weight: 999 + maximum-ifl-processing-weight: 999 + maximum-memory: 4096 + minimum-cp-processing-weight: 1 + minimum-ifl-processing-weight: 1 + os-name: '' + os-type: '' + os-version: '' + partition-id: null + permit-aes-key-import-functions: true + permit-cross-partition-commands: false + permit-des-key-import-functions: true + processor-management-enabled: false + processor-mode: shared + reserve-resources: false + reserved-memory: 0 + short-name: PAR2 + status: stopped + threads-per-processor: 1 + type: linux + available-features-list: + - name: dpm-storage-management + description: The DPM storage management approach in which FCP and FICON + storage resources are defined in Storage Groups, which are attached to + Partitions. + state: true + + nics: + - properties: + element-id: nic1 + name: "OSA1-NIC1" + description: "NIC1 backed by OSA1" + type: osd + device-number: '0010' + virtual-switch-uri: /api/virtual-switches/vs-osa1 + + - properties: + # class: created automatically + # parent: created automatically + # object-uri: created automatically + # nic-uris: created automatically + # hba-uris: created automatically + # virtual-function-uris: created automatically + # storage-group-uris: created automatically + object-id: part2 + name: "PART2" + description: "SSC partition PART2 on CPC1" + acceptable-status: [active] + access-basic-counter-set: false + access-basic-sampling: false + access-coprocessor-group-set: false + access-crypto-activity-counter-set: false + access-diagnostic-sampling: false + access-extended-counter-set: false + access-global-performance-data: false + access-problem-state-counter-set: false + auto-start: false + autogenerate-partition-id: true + boot-configuration-selector: 0 + boot-device: test-operating-system + boot-ftp-host: null + boot-ftp-insfile: null + boot-ftp-username: null + boot-iso-image-name: null + boot-iso-ins-file: null + boot-logical-unit-number: '' + boot-network-device: null + boot-os-specific-parameters: '' + boot-record-lba: '0' + boot-removable-media-type: null + boot-removable-media: null + boot-storage-device: null + boot-storage-volume: null + boot-timeout: 60 + boot-world-wide-port-name: '' + cp-absolute-processor-capping-value: 1.0 + cp-absolute-processor-capping: false + cp-processing-weight-capped: false + cp-processors: 1 + crypto-configuration: null + current-cp-processing-weight: 1 + current-ifl-processing-weight: 1 + degraded-adapters: [] + has-unacceptable-status: true + ifl-absolute-processor-capping-value: 1.0 + ifl-absolute-processor-capping: false + ifl-processing-weight-capped: false + ifl-processors: 0 + initial-cp-processing-weight: 100 + initial-ifl-processing-weight: 100 + initial-memory: 4096 + ipl-load-parameter: '' + is-locked: false + maximum-cp-processing-weight: 999 + maximum-ifl-processing-weight: 999 + maximum-memory: 4096 + minimum-cp-processing-weight: 1 + minimum-ifl-processing-weight: 1 + os-name: '' + os-type: '' + os-version: '' + partition-id: null + permit-aes-key-import-functions: true + permit-cross-partition-commands: false + permit-des-key-import-functions: true + processor-management-enabled: false + processor-mode: shared + reserve-resources: false + reserved-memory: 0 + short-name: PAR2 + status: stopped + threads-per-processor: 1 + type: ssc + available-features-list: + - name: dpm-storage-management + description: The DPM storage management approach in which FCP and FICON + storage resources are defined in Storage Groups, which are attached to + Partitions. + state: true + + nics: + - properties: + element-id: nic1 + name: "OSA1-NIC1" + description: "NIC1 backed by OSA1" + type: osd + device-number: '0010' + virtual-switch-uri: /api/virtual-switches/vs-osa1 diff --git a/tests/end2end/test_zhmc_partition.py b/tests/end2end/test_zhmc_partition.py index ae1e8a58c..5ae60c89d 100644 --- a/tests/end2end/test_zhmc_partition.py +++ b/tests/end2end/test_zhmc_partition.py @@ -143,6 +143,8 @@ def test_partition_facts( hmc_auth = dict(userid=hd.userid, password=hd.password, ca_certs=hd.ca_certs, verify=hd.verify) + faked_session = session if hd.mock_file else None + # Determine a random existing partition of the desired type to test. partitions = cpc.partitions.list() typed_partitions = [p for p in partitions @@ -165,7 +167,7 @@ def test_partition_facts( 'expand_storage_groups': False, 'expand_crypto_adapters': False, 'log_file': None, - '_faked_session': None, + '_faked_session': faked_session, } # Prepare mocks for AnsibleModule object diff --git a/tests/end2end/test_zhmc_user.py b/tests/end2end/test_zhmc_user.py index 06503171b..ea9d52578 100644 --- a/tests/end2end/test_zhmc_user.py +++ b/tests/end2end/test_zhmc_user.py @@ -83,7 +83,7 @@ # 'default_group_name': no default group (artificial property) 'description': "zhmc test user", 'disabled': False, - 'user_role_names': ['Standard'], # (artificial property) + 'user_role_names': ['hmc-all-system-managed-objects'], # (artificial prop) 'authentication_type': 'local', 'password_rule_name': 'Basic', # (artificial property) 'password': 'Bumeran9', @@ -260,6 +260,8 @@ def test_user_facts( client = zhmcclient.Client(hmc_session) console = client.consoles.console + faked_session = hmc_session if hd.mock_file else None + # Determine a random existing user of the desired type to test. users = console.users.list() typed_users = [u for u in users @@ -281,7 +283,7 @@ def test_user_facts( 'properties': {}, 'expand': expand, 'log_file': LOG_FILE, - '_faked_session': None, + '_faked_session': faked_session, } # Prepare mocks for AnsibleModule object @@ -397,6 +399,8 @@ def test_user_absent_present( hmc_auth = dict(userid=hd.userid, password=hd.password, ca_certs=hd.ca_certs, verify=hd.verify) + faked_session = hmc_session if hd.mock_file else None + expand = False # Expansion is tested elsewhere client = zhmcclient.Client(hmc_session) console = client.consoles.console @@ -446,7 +450,7 @@ def test_user_absent_present( 'state': input_state, 'expand': expand, 'log_file': LOG_FILE, - '_faked_session': None, + '_faked_session': faked_session, } if input_props is not None: params['properties'] = input_props