From fa1edfadc47c5357e49b5a3d98962bc216d0b9be Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Thu, 20 Jun 2024 13:28:25 +0200 Subject: [PATCH] Mock: Consolidated the different assumptions in the zhmcclient mock support Signed-off-by: Andreas Maier --- changes/noissue.4.fix.rst | 5 +++++ tests/end2end/test_activation_profile.py | 4 +--- tests/end2end/test_adapter.py | 4 +--- tests/end2end/test_capacity_group.py | 4 +--- tests/end2end/test_console.py | 2 +- tests/end2end/test_cpc.py | 4 +--- tests/end2end/test_hba.py | 3 +-- tests/end2end/test_ldap_server_definition.py | 2 +- tests/end2end/test_lpar.py | 3 +-- tests/end2end/test_nic.py | 3 +-- tests/end2end/test_partition.py | 4 +--- tests/end2end/test_password_rule.py | 2 +- tests/end2end/test_port.py | 3 +-- tests/end2end/test_storage_group.py | 4 +--- tests/end2end/test_storage_group_template.py | 4 +--- tests/end2end/test_storage_volume.py | 3 +-- tests/end2end/test_storage_volume_template.py | 4 +--- tests/end2end/test_task.py | 2 +- tests/end2end/test_user.py | 2 +- tests/end2end/test_user_pattern.py | 2 +- tests/end2end/test_user_role.py | 2 +- tests/end2end/test_virtual_function.py | 3 +-- tests/end2end/test_virtual_switch.py | 3 +-- tests/end2end/utils.py | 21 ++++++------------- 24 files changed, 33 insertions(+), 60 deletions(-) create mode 100644 changes/noissue.4.fix.rst diff --git a/changes/noissue.4.fix.rst b/changes/noissue.4.fix.rst new file mode 100644 index 00000000..41c39254 --- /dev/null +++ b/changes/noissue.4.fix.rst @@ -0,0 +1,5 @@ +Mock: Consolidated the different assumptions in the zhmcclient mock support and +the end2end testcases regarding whether the implemented behavior depends on the +mocked HMC or CPC generation (e.g. support or not support the 'properties' +query parameter on some List operations). Now, the zhmcclient mock support +always implements only the behavior of the latest HMC / CPC generation. diff --git a/tests/end2end/test_activation_profile.py b/tests/end2end/test_activation_profile.py index fc87f97e..992b0747 100644 --- a/tests/end2end/test_activation_profile.py +++ b/tests/end2end/test_activation_profile.py @@ -222,7 +222,6 @@ def test_actprof_property(classic_mode_cpcs, profile_type): # noqa: F811 for cpc in classic_mode_cpcs: assert not cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition actprof_mgr = getattr(cpc, profile_type + '_activation_profiles') @@ -242,5 +241,4 @@ def test_actprof_property(classic_mode_cpcs, profile_type): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties( - client, actprof.manager, non_list_prop, (2, 15)) + runtest_get_properties(actprof.manager, non_list_prop) diff --git a/tests/end2end/test_adapter.py b/tests/end2end/test_adapter.py index 1e3cbc8c..beffe59b 100644 --- a/tests/end2end/test_adapter.py +++ b/tests/end2end/test_adapter.py @@ -92,7 +92,6 @@ def test_adapter_property(dpm_mode_cpcs): # noqa: F811 for cpc in dpm_mode_cpcs: assert cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -110,8 +109,7 @@ def test_adapter_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties( - client, adapter.manager, non_list_prop, None) + runtest_get_properties(adapter.manager, non_list_prop) def test_adapter_hs_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_capacity_group.py b/tests/end2end/test_capacity_group.py index 656d8175..e740b019 100644 --- a/tests/end2end/test_capacity_group.py +++ b/tests/end2end/test_capacity_group.py @@ -86,7 +86,6 @@ def test_capgrp_property(dpm_mode_cpcs): # noqa: F811 for cpc in dpm_mode_cpcs: assert cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -104,8 +103,7 @@ def test_capgrp_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties( - client, capgrp.manager, non_list_prop, None) + runtest_get_properties(capgrp.manager, non_list_prop) def test_capgrp_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_console.py b/tests/end2end/test_console.py index 32448340..da3ec019 100644 --- a/tests/end2end/test_console.py +++ b/tests/end2end/test_console.py @@ -67,7 +67,7 @@ def test_console_property(hmc_session): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, client.consoles, non_list_prop, (2, 15)) + runtest_get_properties(client.consoles, non_list_prop) def test_console_list_features(hmc_session): # noqa: F811 diff --git a/tests/end2end/test_cpc.py b/tests/end2end/test_cpc.py index 3c688a71..e3ded0ee 100644 --- a/tests/end2end/test_cpc.py +++ b/tests/end2end/test_cpc.py @@ -120,12 +120,10 @@ def test_cpc_property(all_cpcs): # noqa: F811 for cpc in all_cpcs: print(f"Testing with CPC {cpc.name}") - client = cpc.manager.client - # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, cpc.manager, non_list_prop, (2, 14)) + runtest_get_properties(cpc.manager, non_list_prop) def test_cpc_features(all_cpcs): # noqa: F811 diff --git a/tests/end2end/test_hba.py b/tests/end2end/test_hba.py index febc62b2..6267c54b 100644 --- a/tests/end2end/test_hba.py +++ b/tests/end2end/test_hba.py @@ -92,7 +92,6 @@ def test_hba_property(dpm_mode_cpcs): # noqa: F811 for cpc in dpm_mode_cpcs: assert cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -115,7 +114,7 @@ def test_hba_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, hba.manager, non_list_prop, None) + runtest_get_properties(hba.manager, non_list_prop) def test_hba_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_ldap_server_definition.py b/tests/end2end/test_ldap_server_definition.py index e2f1f9bc..904b2eed 100644 --- a/tests/end2end/test_ldap_server_definition.py +++ b/tests/end2end/test_ldap_server_definition.py @@ -108,7 +108,7 @@ def test_ldapsrvdef_property(hmc_session): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, ldapsrvdef.manager, non_list_prop, None) + runtest_get_properties(ldapsrvdef.manager, non_list_prop) def test_ldapsrvdef_crud(hmc_session): # noqa: F811 diff --git a/tests/end2end/test_lpar.py b/tests/end2end/test_lpar.py index 3c6c5bf7..f4c5ad28 100644 --- a/tests/end2end/test_lpar.py +++ b/tests/end2end/test_lpar.py @@ -103,7 +103,6 @@ def test_lpar_property(classic_mode_cpcs): # noqa: F811 for cpc in classic_mode_cpcs: assert not cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -121,7 +120,7 @@ def test_lpar_property(classic_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, lpar.manager, non_list_prop, (2, 14)) + runtest_get_properties(lpar.manager, non_list_prop) TESTCASES_CONSOLE_LIST_PERMITTED_LPARS = [ diff --git a/tests/end2end/test_nic.py b/tests/end2end/test_nic.py index f0230e26..d1af66c3 100644 --- a/tests/end2end/test_nic.py +++ b/tests/end2end/test_nic.py @@ -96,7 +96,6 @@ def test_nic_property(dpm_mode_cpcs): # noqa: F811 for cpc in dpm_mode_cpcs: assert cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -119,7 +118,7 @@ def test_nic_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, nic.manager, non_list_prop, None) + runtest_get_properties(nic.manager, non_list_prop) def test_nic_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_partition.py b/tests/end2end/test_partition.py index ec87f4fc..c2c255be 100644 --- a/tests/end2end/test_partition.py +++ b/tests/end2end/test_partition.py @@ -94,7 +94,6 @@ def test_part_property(dpm_mode_cpcs): # noqa: F811 for cpc in dpm_mode_cpcs: assert cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -112,8 +111,7 @@ def test_part_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties( - client, part.manager, non_list_prop, (2, 16)) + runtest_get_properties(part.manager, non_list_prop) def test_part_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_password_rule.py b/tests/end2end/test_password_rule.py index d29e7e05..f487c98b 100644 --- a/tests/end2end/test_password_rule.py +++ b/tests/end2end/test_password_rule.py @@ -102,7 +102,7 @@ def test_pwrule_property(hmc_session): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, pwrule.manager, non_list_prop, None) + runtest_get_properties(pwrule.manager, non_list_prop) def test_pwrule_crud(hmc_session): # noqa: F811 diff --git a/tests/end2end/test_port.py b/tests/end2end/test_port.py index 0ae9ae8a..446058b6 100644 --- a/tests/end2end/test_port.py +++ b/tests/end2end/test_port.py @@ -90,7 +90,6 @@ def test_port_property(dpm_mode_cpcs): # noqa: F811 for cpc in dpm_mode_cpcs: assert cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -113,7 +112,7 @@ def test_port_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, port.manager, non_list_prop, None) + runtest_get_properties(port.manager, non_list_prop) def test_port_update(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_storage_group.py b/tests/end2end/test_storage_group.py index 4a81b1e0..8d49fe00 100644 --- a/tests/end2end/test_storage_group.py +++ b/tests/end2end/test_storage_group.py @@ -90,7 +90,6 @@ def test_stogrp_property(dpm_mode_cpcs): # noqa: F811 assert cpc.dpm_enabled skipif_no_storage_mgmt_feature(cpc) - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -108,8 +107,7 @@ def test_stogrp_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties( - client, stogrp.manager, non_list_prop, None) + runtest_get_properties(stogrp.manager, non_list_prop) def test_stogrp_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_storage_group_template.py b/tests/end2end/test_storage_group_template.py index f9b813d0..b0399feb 100644 --- a/tests/end2end/test_storage_group_template.py +++ b/tests/end2end/test_storage_group_template.py @@ -93,7 +93,6 @@ def test_stogrptpl_property(dpm_mode_cpcs): # noqa: F811 skipif_no_storage_mgmt_feature(cpc) console = cpc.manager.client.consoles.console - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -112,8 +111,7 @@ def test_stogrptpl_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties( - client, stogrptpl.manager, non_list_prop, None) + runtest_get_properties(stogrptpl.manager, non_list_prop) def test_stogrptpl_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_storage_volume.py b/tests/end2end/test_storage_volume.py index 15ec6db5..4b100b49 100644 --- a/tests/end2end/test_storage_volume.py +++ b/tests/end2end/test_storage_volume.py @@ -140,8 +140,7 @@ def test_stovol_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties( - client, stovol.manager, non_list_prop, None) + runtest_get_properties(stovol.manager, non_list_prop) def test_stovol_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_storage_volume_template.py b/tests/end2end/test_storage_volume_template.py index 5ecc7cc0..4586ce2c 100644 --- a/tests/end2end/test_storage_volume_template.py +++ b/tests/end2end/test_storage_volume_template.py @@ -98,7 +98,6 @@ def test_stovoltpl_property(dpm_mode_cpcs): # noqa: F811 skipif_no_storage_mgmt_feature(cpc) console = cpc.manager.client.consoles.console - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -124,8 +123,7 @@ def test_stovoltpl_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties( - client, stovoltpl.manager, non_list_prop, None) + runtest_get_properties(stovoltpl.manager, non_list_prop) def test_stovoltpl_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_task.py b/tests/end2end/test_task.py index af4e7967..a0828a4a 100644 --- a/tests/end2end/test_task.py +++ b/tests/end2end/test_task.py @@ -96,4 +96,4 @@ def test_task_property(hmc_session): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, task.manager, non_list_prop, None) + runtest_get_properties(task.manager, non_list_prop) diff --git a/tests/end2end/test_user.py b/tests/end2end/test_user.py index 091eaaf6..a2f994e2 100644 --- a/tests/end2end/test_user.py +++ b/tests/end2end/test_user.py @@ -102,7 +102,7 @@ def test_user_property(hmc_session): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, user.manager, non_list_prop, None) + runtest_get_properties(user.manager, non_list_prop) def test_user_crud(hmc_session): # noqa: F811 diff --git a/tests/end2end/test_user_pattern.py b/tests/end2end/test_user_pattern.py index ff8a72c3..09365f9d 100644 --- a/tests/end2end/test_user_pattern.py +++ b/tests/end2end/test_user_pattern.py @@ -102,7 +102,7 @@ def test_upatt_property(hmc_session): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, upatt.manager, non_list_prop, None) + runtest_get_properties(upatt.manager, non_list_prop) def test_upatt_crud(hmc_session): # noqa: F811 diff --git a/tests/end2end/test_user_role.py b/tests/end2end/test_user_role.py index 61767eea..ae0d9eee 100644 --- a/tests/end2end/test_user_role.py +++ b/tests/end2end/test_user_role.py @@ -102,7 +102,7 @@ def test_urole_property(hmc_session): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, urole.manager, non_list_prop, None) + runtest_get_properties(urole.manager, non_list_prop) def test_urole_crud(hmc_session): # noqa: F811 diff --git a/tests/end2end/test_virtual_function.py b/tests/end2end/test_virtual_function.py index 96a3f924..3b189a6e 100644 --- a/tests/end2end/test_virtual_function.py +++ b/tests/end2end/test_virtual_function.py @@ -93,7 +93,6 @@ def test_vfunc_property(dpm_mode_cpcs): # noqa: F811 for cpc in dpm_mode_cpcs: assert cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -117,7 +116,7 @@ def test_vfunc_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, vfunc.manager, non_list_prop, None) + runtest_get_properties(vfunc.manager, non_list_prop) def test_vfunc_crud(dpm_mode_cpcs): # noqa: F811 diff --git a/tests/end2end/test_virtual_switch.py b/tests/end2end/test_virtual_switch.py index 972de236..7c25cd0f 100644 --- a/tests/end2end/test_virtual_switch.py +++ b/tests/end2end/test_virtual_switch.py @@ -87,7 +87,6 @@ def test_vswitch_property(dpm_mode_cpcs): # noqa: F811 for cpc in dpm_mode_cpcs: assert cpc.dpm_enabled - client = cpc.manager.client session = cpc.manager.session hd = session.hmc_definition @@ -106,4 +105,4 @@ def test_vswitch_property(dpm_mode_cpcs): # noqa: F811 # Select a property that is not returned by list() non_list_prop = 'description' - runtest_get_properties(client, vswitch.manager, non_list_prop, None) + runtest_get_properties(vswitch.manager, non_list_prop) diff --git a/tests/end2end/utils.py b/tests/end2end/utils.py index 5f7d428d..ac7cc0a5 100644 --- a/tests/end2end/utils.py +++ b/tests/end2end/utils.py @@ -398,8 +398,7 @@ def runtest_find_list(session, manager, name, server_prop, client_prop, prop_names=list_props + add_props) -def runtest_get_properties( - client, manager, non_list_prop, properties_hmc_version): # noqa: F811 +def runtest_get_properties(manager, non_list_prop): # noqa: F811 # pylint: disable=redefined-outer-name """ Run tests for pull_full_properties/pull_properties/get_property/prop @@ -407,28 +406,20 @@ def runtest_get_properties( Parameters: - client (zhmcclient.Client): Client of the manager. - manager (zhmcclient.BaseManager): Manager for listing the resources. non_list_prop (string): Name of a resource property that is not returned with the List HMC operation. - - properties_hmc_version (tuple(int,int)): HMC version that - introduced the 'properties' query parameter for this resource type. """ assert isinstance(manager, zhmcclient.BaseManager) - # Get HMC version as a tuple (major, minor) - av = client.query_api_version() - hmc_version = tuple(int(v) for v in av['hmc-version'].split('.')) - # Indicates whether pull_properties() is expected to pull just the - # specified properties. - supports_properties = properties_hmc_version is not None \ - and hmc_version >= properties_hmc_version \ - and manager.supports_properties + # specified properties. We make this dependent only on whether the + # mock support for the resource implements it, and not on the HMC + # version, because the zhmcclient mock support only implements the + # latest CPC and HMC generation, for simplicity. + supports_properties = manager.supports_properties # Part 1: First chunk of methods to be tested