Remove unsupported calls
Because kubernetes 11.0.0 deleted the function of 'kubernetes.client.api_client.ApiClient.__del__', which caused an ut error and deleted the relevant mock call. Change-Id: I1ecade75227b3dc37c8fcdf775b7823583faea43
This commit is contained in:
parent
401c9bca56
commit
7fc2b10557
|
@ -16,8 +16,6 @@ from karbor.context import RequestContext
|
||||||
from karbor.services.protection.clients import k8s
|
from karbor.services.protection.clients import k8s
|
||||||
from karbor.tests import base
|
from karbor.tests import base
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
|
|
||||||
class KubernetesClientTest(base.TestCase):
|
class KubernetesClientTest(base.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -43,8 +41,7 @@ class KubernetesClientTest(base.TestCase):
|
||||||
'/etc/provider.d/client-admin.key',
|
'/etc/provider.d/client-admin.key',
|
||||||
'k8s_client')
|
'k8s_client')
|
||||||
|
|
||||||
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
|
def test_create_client(self):
|
||||||
def test_create_client(self, mock_k8s_delete):
|
|
||||||
|
|
||||||
client = k8s.create(self._context, self.conf)
|
client = k8s.create(self._context, self.conf)
|
||||||
self.assertEqual(client.api_client.configuration.host, self.host_url)
|
self.assertEqual(client.api_client.configuration.host, self.host_url)
|
||||||
|
|
|
@ -46,10 +46,9 @@ class PodProtectablePluginTest(base.TestCase):
|
||||||
self.assertEqual(("OS::Keystone::Project"),
|
self.assertEqual(("OS::Keystone::Project"),
|
||||||
plugin.get_parent_resource_types())
|
plugin.get_parent_resource_types())
|
||||||
|
|
||||||
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
|
|
||||||
@mock.patch('kubernetes.client.apis.core_v1_api.'
|
@mock.patch('kubernetes.client.apis.core_v1_api.'
|
||||||
'CoreV1Api.list_namespaced_pod')
|
'CoreV1Api.list_namespaced_pod')
|
||||||
def test_list_resources(self, mock_pod_list, mock_pod_delete):
|
def test_list_resources(self, mock_pod_list):
|
||||||
plugin = K8sPodProtectablePlugin(self._context, cfg.CONF)
|
plugin = K8sPodProtectablePlugin(self._context, cfg.CONF)
|
||||||
|
|
||||||
pod = V1Pod(api_version="v1", kind="Pod",
|
pod = V1Pod(api_version="v1", kind="Pod",
|
||||||
|
@ -66,10 +65,9 @@ class PodProtectablePluginTest(base.TestCase):
|
||||||
'default:busybox-test')],
|
'default:busybox-test')],
|
||||||
plugin.list_resources(self._context))
|
plugin.list_resources(self._context))
|
||||||
|
|
||||||
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
|
|
||||||
@mock.patch('kubernetes.client.apis.core_v1_api.'
|
@mock.patch('kubernetes.client.apis.core_v1_api.'
|
||||||
'CoreV1Api.read_namespaced_pod')
|
'CoreV1Api.read_namespaced_pod')
|
||||||
def test_show_resource(self, mock_pod_get, mock_pod_delete):
|
def test_show_resource(self, mock_pod_get):
|
||||||
plugin = K8sPodProtectablePlugin(self._context, cfg.CONF)
|
plugin = K8sPodProtectablePlugin(self._context, cfg.CONF)
|
||||||
|
|
||||||
pod = V1Pod(api_version="v1", kind="Pod",
|
pod = V1Pod(api_version="v1", kind="Pod",
|
||||||
|
|
|
@ -151,7 +151,6 @@ class VolumeProtectablePluginTest(base.TestCase):
|
||||||
{'availability_zone': 'az1'})],
|
{'availability_zone': 'az1'})],
|
||||||
plugin.get_dependent_resources(self._context, project))
|
plugin.get_dependent_resources(self._context, project))
|
||||||
|
|
||||||
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
|
|
||||||
@mock.patch.object(volumes.VolumeManager, 'list')
|
@mock.patch.object(volumes.VolumeManager, 'list')
|
||||||
@mock.patch('kubernetes.client.apis.core_v1_api.'
|
@mock.patch('kubernetes.client.apis.core_v1_api.'
|
||||||
'CoreV1Api.read_persistent_volume')
|
'CoreV1Api.read_persistent_volume')
|
||||||
|
@ -162,8 +161,7 @@ class VolumeProtectablePluginTest(base.TestCase):
|
||||||
def test_get_pod_dependent_resources(self, mock_pod_read,
|
def test_get_pod_dependent_resources(self, mock_pod_read,
|
||||||
mock_pvc_read,
|
mock_pvc_read,
|
||||||
mock_pv_read,
|
mock_pv_read,
|
||||||
mock_volume_list,
|
mock_volume_list):
|
||||||
mock_delete):
|
|
||||||
plugin = VolumeProtectablePlugin(self._context)
|
plugin = VolumeProtectablePlugin(self._context)
|
||||||
|
|
||||||
pod = V1Pod(api_version="v1", kind="Pod",
|
pod = V1Pod(api_version="v1", kind="Pod",
|
||||||
|
|
|
@ -131,9 +131,8 @@ class PodProtectionPluginTest(base.TestCase):
|
||||||
self.assertEqual(options_schema,
|
self.assertEqual(options_schema,
|
||||||
pod_plugin_schemas.SAVED_INFO_SCHEMA)
|
pod_plugin_schemas.SAVED_INFO_SCHEMA)
|
||||||
|
|
||||||
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
|
|
||||||
@mock.patch('karbor.services.protection.clients.k8s.create')
|
@mock.patch('karbor.services.protection.clients.k8s.create')
|
||||||
def test_create_backup(self, mock_k8s_create, mock_k8s_delete):
|
def test_create_backup(self, mock_k8s_create):
|
||||||
self.k8s_client = client_factory.ClientFactory.create_client(
|
self.k8s_client = client_factory.ClientFactory.create_client(
|
||||||
"k8s", self.cntxt)
|
"k8s", self.cntxt)
|
||||||
resource = Resource(id="c88b92a8-e8b4-504c-bad4-343d92061871",
|
resource = Resource(id="c88b92a8-e8b4-504c-bad4-343d92061871",
|
||||||
|
|
Loading…
Reference in New Issue