Skip to content

Commit b8e5301

Browse files
committed
Fix deprecations introduced in v1.16
1 parent a05c331 commit b8e5301

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

kubernetes/e2e_test/test_extensions.py renamed to kubernetes/e2e_test/test_apps.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@
1717
import yaml
1818

1919
from kubernetes.client import api_client
20-
from kubernetes.client.apis import extensions_v1beta1_api
21-
from kubernetes.client.models import v1_delete_options
20+
from kubernetes.client.apis import apps_v1_api
2221
from kubernetes.e2e_test import base
2322

2423

25-
class TestClientExtensions(unittest.TestCase):
24+
class TestClientApps(unittest.TestCase):
2625

2726
@classmethod
2827
def setUpClass(cls):
2928
cls.config = base.get_e2e_configuration()
3029

3130
def test_create_deployment(self):
3231
client = api_client.ApiClient(configuration=self.config)
33-
api = extensions_v1beta1_api.ExtensionsV1beta1Api(client)
32+
api = apps_v1_api.AppsV1Api(client)
3433
name = 'nginx-deployment-' + str(uuid.uuid4())
35-
deployment = '''apiVersion: extensions/v1beta1
34+
deployment = '''apiVersion: apps/v1
3635
kind: Deployment
3736
metadata:
3837
name: %s
@@ -45,7 +44,7 @@ def test_create_deployment(self):
4544
spec:
4645
containers:
4746
- name: nginx
48-
image: nginx:1.7.9
47+
image: nginx:1.15.4
4948
ports:
5049
- containerPort: 80
5150
'''
@@ -56,14 +55,14 @@ def test_create_deployment(self):
5655
self.assertIsNotNone(resp)
5756

5857
options = v1_delete_options.V1DeleteOptions()
59-
resp = api.delete_namespaced_deployment(name, 'default', body=options)
58+
resp = api.delete_namespaced_deployment(name, 'default', body={})
6059

6160
def test_create_daemonset(self):
6261
client = api_client.ApiClient(configuration=self.config)
63-
api = extensions_v1beta1_api.ExtensionsV1beta1Api(client)
62+
api = apps_v1_api.AppsV1Api(client)
6463
name = 'nginx-app-' + str(uuid.uuid4())
6564
daemonset = {
66-
'apiVersion': 'extensions/v1beta1',
65+
'apiVersion': 'apps/v1',
6766
'kind': 'DaemonSet',
6867
'metadata': {
6968
'labels': {'app': 'nginx'},
@@ -77,7 +76,7 @@ def test_create_daemonset(self):
7776
'spec': {
7877
'containers': [
7978
{'name': 'nginx-app',
80-
'image': 'nginx:1.10'},
79+
'image': 'nginx:1.15.4'},
8180
],
8281
},
8382
},
@@ -90,5 +89,4 @@ def test_create_daemonset(self):
9089
resp = api.read_namespaced_daemon_set(name, 'default')
9190
self.assertIsNotNone(resp)
9291

93-
options = v1_delete_options.V1DeleteOptions()
94-
resp = api.delete_namespaced_daemon_set(name, 'default', body=options)
92+
resp = api.delete_namespaced_daemon_set(name, 'default', body={})

kubernetes/e2e_test/test_utils.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ def tearDownClass(cls):
4141

4242
def test_create_apps_deployment_from_yaml(self):
4343
"""
44-
Should be able to create an apps/v1beta1 deployment.
44+
Should be able to create an apps/v1 deployment.
4545
"""
4646
k8s_client = client.api_client.ApiClient(configuration=self.config)
4747
utils.create_from_yaml(
4848
k8s_client, self.path_prefix + "apps-deployment.yaml")
49-
app_api = client.AppsV1beta1Api(k8s_client)
49+
app_api = client.AppsV1Api(k8s_client)
5050
dep = app_api.read_namespaced_deployment(name="nginx-app",
5151
namespace="default")
5252
self.assertIsNotNone(dep)
@@ -68,7 +68,7 @@ def test_create_apps_deployment_from_yaml_obj(self):
6868

6969
utils.create_from_dict(k8s_client, yml_obj)
7070

71-
app_api = client.AppsV1beta1Api(k8s_client)
71+
app_api = client.AppsV1Api(k8s_client)
7272
dep = app_api.read_namespaced_deployment(name="nginx-app-3",
7373
namespace="default")
7474
self.assertIsNotNone(dep)
@@ -289,7 +289,7 @@ def test_create_from_list_in_multi_resource_yaml(self):
289289
utils.create_from_yaml(
290290
k8s_client, self.path_prefix + "multi-resource-with-list.yaml")
291291
core_api = client.CoreV1Api(k8s_client)
292-
app_api = client.AppsV1beta1Api(k8s_client)
292+
app_api = client.AppsV1Api(k8s_client)
293293
pod_0 = core_api.read_namespaced_pod(
294294
name="mock-pod-0", namespace="default")
295295
self.assertIsNotNone(pod_0)
@@ -365,15 +365,16 @@ def test_create_from_multi_resource_yaml_with_multi_conflicts(self):
365365
name="triple-nginx", namespace="default",
366366
body={})
367367

368-
def test_create_namespaces_apps_deployment_from_yaml(self):
368+
def test_create_namespaced_apps_deployment_from_yaml(self):
369369
"""
370-
Should be able to create an apps/v1beta1 deployment.
370+
Should be able to create an apps/v1beta1 deployment
371+
in a test namespace.
371372
"""
372373
k8s_client = client.api_client.ApiClient(configuration=self.config)
373374
utils.create_from_yaml(
374375
k8s_client, self.path_prefix + "apps-deployment.yaml",
375376
namespace=self.test_namespace)
376-
app_api = client.AppsV1beta1Api(k8s_client)
377+
app_api = client.AppsV1Api(k8s_client)
377378
dep = app_api.read_namespaced_deployment(name="nginx-app",
378379
namespace=self.test_namespace)
379380
self.assertIsNotNone(dep)
@@ -391,7 +392,7 @@ def test_create_from_list_in_multi_resource_yaml_namespaced(self):
391392
k8s_client, self.path_prefix + "multi-resource-with-list.yaml",
392393
namespace=self.test_namespace)
393394
core_api = client.CoreV1Api(k8s_client)
394-
app_api = client.AppsV1beta1Api(k8s_client)
395+
app_api = client.AppsV1Api(k8s_client)
395396
pod_0 = core_api.read_namespaced_pod(
396397
name="mock-pod-0", namespace=self.test_namespace)
397398
self.assertIsNotNone(pod_0)

kubernetes/e2e_test/test_yaml/apps-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: apps/v1beta1
1+
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: nginx-app

kubernetes/e2e_test/test_yaml/multi-resource-with-list.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ items:
2424
image: busybox
2525
command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']
2626
---
27-
apiVersion: apps/v1beta1
27+
apiVersion: apps/v1
2828
kind: Deployment
2929
metadata:
3030
name: mock

0 commit comments

Comments
 (0)