From 197ba0092cf45d51fb3816103ac9b88bfc2b79a2 Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 2 Aug 2024 16:48:54 +0000 Subject: [PATCH] tests: fix compatibility with revised patching Directly set the release for each test charm target rather than using the return value of CompareOpenStackReleases which is no longer patched by charms.openstack. Drop supported Ubuntu targets from charmcraft configuration. Change-Id: If6b65341ec69a2e1fd9b481fea75912bea2c86c4 --- charmcraft.yaml | 64 ------------------- unit_tests/test_lib_charm_openstack_ironic.py | 13 ++-- 2 files changed, 6 insertions(+), 71 deletions(-) diff --git a/charmcraft.yaml b/charmcraft.yaml index 2783462..bf03322 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -54,67 +54,3 @@ bases: - name: ubuntu channel: "22.04" architectures: [arm64] - - build-on: - - name: ubuntu - channel: "23.04" - architectures: [amd64] - run-on: - - name: ubuntu - channel: "23.04" - architectures: [amd64] - - build-on: - - name: ubuntu - channel: "23.04" - architectures: [s390x] - run-on: - - name: ubuntu - channel: "23.04" - architectures: [s390x] - - build-on: - - name: ubuntu - channel: "23.04" - architectures: [ppc64el] - run-on: - - name: ubuntu - channel: "23.04" - architectures: [ppc64el] - - build-on: - - name: ubuntu - channel: "23.04" - architectures: [arm64] - run-on: - - name: ubuntu - channel: "23.04" - architectures: [arm64] - - build-on: - - name: ubuntu - channel: "23.10" - architectures: [amd64] - run-on: - - name: ubuntu - channel: "23.10" - architectures: [amd64] - - build-on: - - name: ubuntu - channel: "23.10" - architectures: [s390x] - run-on: - - name: ubuntu - channel: "23.10" - architectures: [s390x] - - build-on: - - name: ubuntu - channel: "23.10" - architectures: [ppc64el] - run-on: - - name: ubuntu - channel: "23.10" - architectures: [ppc64el] - - build-on: - - name: ubuntu - channel: "23.10" - architectures: [arm64] - run-on: - - name: ubuntu - channel: "23.10" - architectures: [arm64] diff --git a/unit_tests/test_lib_charm_openstack_ironic.py b/unit_tests/test_lib_charm_openstack_ironic.py index 50d7fae..07219f4 100644 --- a/unit_tests/test_lib_charm_openstack_ironic.py +++ b/unit_tests/test_lib_charm_openstack_ironic.py @@ -22,7 +22,6 @@ import charmhelpers.core.hookenv as hookenv import charms.reactive as reactive from charmhelpers.contrib.openstack.utils import ( - CompareOpenStackReleases, os_release, ) @@ -374,7 +373,7 @@ class TestIronicCharm(test_utils.PatchHelper): def test_validate_deploy_interfaces(self): target = ironic.IronicConductorCharm() - CompareOpenStackReleases.return_value = 'wallaby' + target.release = 'wallaby' with self.assertRaises(ValueError) as err: target._validate_deploy_interfaces(["bogus"]) @@ -389,7 +388,7 @@ class TestIronicCharm(test_utils.PatchHelper): def test_validate_deploy_interfaces_xena(self): reactive.is_flag_set.side_effect = [False, False, False] target = ironic.IronicConductorXenaCharm() - CompareOpenStackReleases.return_value = 'xena' + target.release = 'xena' with self.assertRaises(ValueError) as err: target._validate_deploy_interfaces(["bogus"]) @@ -406,8 +405,8 @@ class TestIronicCharm(test_utils.PatchHelper): # boot method is enabled. Validate will fail, until # set-temp-url-secret action is run reactive.is_flag_set.side_effect = [False, True] - CompareOpenStackReleases.return_value = 'wallaby' target = ironic.IronicConductorCharm() + target.release = 'wallaby' with self.assertRaises(ValueError) as err: target._validate_deploy_interfaces(["direct"]) expected_msg = ( @@ -461,8 +460,8 @@ class TestIronicCharm(test_utils.PatchHelper): "enabled-deploy-interfaces": "direct, iscsi", "default-network-interface": "flat", "enabled-network-interfaces": "neutron, flat, noop"} - CompareOpenStackReleases.return_value = 'wallaby' target = ironic.IronicConductorCharm() + target.release = 'wallaby' self.assertEqual(target.custom_assess_status_check(), (None, None)) def test_custom_assess_status_check_invalid_enabled_net_ifaces(self): @@ -485,8 +484,8 @@ class TestIronicCharm(test_utils.PatchHelper): "enabled-deploy-interfaces": "bogus, iscsi", "default-network-interface": "flat", "enabled-network-interfaces": "neutron, flat, noop"} - CompareOpenStackReleases.return_value = 'wallaby' target = ironic.IronicConductorCharm() + target.release = 'wallaby' expected_status = ( 'blocked', 'invalid enabled-deploy-interfaces config, Deploy interface ' @@ -515,8 +514,8 @@ class TestIronicCharm(test_utils.PatchHelper): "enabled-deploy-interfaces": "direct, iscsi", "default-network-interface": "flat", "enabled-network-interfaces": "neutron, flat, noop"} - CompareOpenStackReleases.return_value = 'wallaby' target = ironic.IronicConductorCharm() + target.release = 'wallaby' expected_status = ( 'blocked', 'invalid default-deploy-interface config, default-deploy-interface'