Browse Source

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
changes/71/713171/3 1.5.0
shenxindi 1 year ago
parent
commit
7fc2b10557
4 changed files with 5 additions and 13 deletions
  1. +1
    -4
      karbor/tests/unit/clients/test_k8s_client.py
  2. +2
    -4
      karbor/tests/unit/plugins/test_pod_protectable_plugin.py
  3. +1
    -3
      karbor/tests/unit/plugins/test_volume_protectable_plugin.py
  4. +1
    -2
      karbor/tests/unit/protection/test_pod_protection_plugin.py

+ 1
- 4
karbor/tests/unit/clients/test_k8s_client.py View File

@ -16,8 +16,6 @@ from karbor.context import RequestContext
from karbor.services.protection.clients import k8s
from karbor.tests import base
import mock
class KubernetesClientTest(base.TestCase):
def setUp(self):
@ -43,8 +41,7 @@ class KubernetesClientTest(base.TestCase):
'/etc/provider.d/client-admin.key',
'k8s_client')
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
def test_create_client(self, mock_k8s_delete):
def test_create_client(self):
client = k8s.create(self._context, self.conf)
self.assertEqual(client.api_client.configuration.host, self.host_url)

+ 2
- 4
karbor/tests/unit/plugins/test_pod_protectable_plugin.py View File

@ -46,10 +46,9 @@ class PodProtectablePluginTest(base.TestCase):
self.assertEqual(("OS::Keystone::Project"),
plugin.get_parent_resource_types())
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
@mock.patch('kubernetes.client.apis.core_v1_api.'
'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)
pod = V1Pod(api_version="v1", kind="Pod",
@ -66,10 +65,9 @@ class PodProtectablePluginTest(base.TestCase):
'default:busybox-test')],
plugin.list_resources(self._context))
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
@mock.patch('kubernetes.client.apis.core_v1_api.'
'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)
pod = V1Pod(api_version="v1", kind="Pod",


+ 1
- 3
karbor/tests/unit/plugins/test_volume_protectable_plugin.py View File

@ -151,7 +151,6 @@ class VolumeProtectablePluginTest(base.TestCase):
{'availability_zone': 'az1'})],
plugin.get_dependent_resources(self._context, project))
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
@mock.patch.object(volumes.VolumeManager, 'list')
@mock.patch('kubernetes.client.apis.core_v1_api.'
'CoreV1Api.read_persistent_volume')
@ -162,8 +161,7 @@ class VolumeProtectablePluginTest(base.TestCase):
def test_get_pod_dependent_resources(self, mock_pod_read,
mock_pvc_read,
mock_pv_read,
mock_volume_list,
mock_delete):
mock_volume_list):
plugin = VolumeProtectablePlugin(self._context)
pod = V1Pod(api_version="v1", kind="Pod",


+ 1
- 2
karbor/tests/unit/protection/test_pod_protection_plugin.py View File

@ -131,9 +131,8 @@ class PodProtectionPluginTest(base.TestCase):
self.assertEqual(options_schema,
pod_plugin_schemas.SAVED_INFO_SCHEMA)
@mock.patch('kubernetes.client.api_client.ApiClient.__del__')
@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(
"k8s", self.cntxt)
resource = Resource(id="c88b92a8-e8b4-504c-bad4-343d92061871",


Loading…
Cancel
Save