diff --git a/rally_openstack/scenarios/magnum/utils.py b/rally_openstack/scenarios/magnum/utils.py index db0dc0ee..a4731bb9 100644 --- a/rally_openstack/scenarios/magnum/utils.py +++ b/rally_openstack/scenarios/magnum/utils.py @@ -172,7 +172,12 @@ class MagnumScenario(scenario.OpenStackScenario): config.ssl_ca_cert = ca_certs config.cert_file = cert_file config.key_file = key_file - client = api_client.ApiClient(config=config) + if hasattr(k8s_config, "ConfigurationObject"): + # k8sclient < 4.0.0 + client = api_client.ApiClient(config=config) + else: + client = api_client.ApiClient(config) + return core_v1_api.CoreV1Api(client) @atomic.action_timer("magnum.k8s_list_v1pods") diff --git a/tests/unit/scenarios/magnum/test_utils.py b/tests/unit/scenarios/magnum/test_utils.py index 18d38b53..bf3975f7 100644 --- a/tests/unit/scenarios/magnum/test_utils.py +++ b/tests/unit/scenarios/magnum/test_utils.py @@ -174,7 +174,12 @@ class MagnumScenarioTestCase(test.ScenarioTestCase): _api_client = mock_api_client.return_value self.scenario._get_k8s_api_client() mock_configuration_object.assert_called_once_with() - mock_api_client.assert_called_once_with(config=config) + if hasattr(kubernetes_client, "ConfigurationObject"): + # k8s-python < 4.0.0 + mock_api_client.assert_called_once_with(config=config) + else: + mock_api_client.assert_called_once_with(config) + mock_core_v1_api.assert_called_once_with(_api_client) @mock.patch("kubernetes.client.api_client.ApiClient") @@ -211,7 +216,11 @@ class MagnumScenarioTestCase(test.ScenarioTestCase): _api_client = mock_api_client.return_value self.scenario._get_k8s_api_client() mock_configuration_object.assert_called_once_with() - mock_api_client.assert_called_once_with(config=config) + if hasattr(kubernetes_client, "ConfigurationObject"): + # k8s-python < 4.0.0 + mock_api_client.assert_called_once_with(config=config) + else: + mock_api_client.assert_called_once_with(config) mock_core_v1_api.assert_called_once_with(_api_client) @mock.patch(MAGNUM_UTILS + ".MagnumScenario._get_k8s_api_client")