Merge "Fix k8s APIClient when k8s-client >= 4.0.0"
This commit is contained in:
commit
e627a4f727
@ -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")
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user