diff --git a/rally_openstack/scenarios/magnum/utils.py b/rally_openstack/scenarios/magnum/utils.py index 5c259c05..c71a73cf 100644 --- a/rally_openstack/scenarios/magnum/utils.py +++ b/rally_openstack/scenarios/magnum/utils.py @@ -18,8 +18,8 @@ import string import time from kubernetes import client as k8s_config +from kubernetes.client.api import core_v1_api from kubernetes.client import api_client -from kubernetes.client.apis import core_v1_api from kubernetes.client.rest import ApiException from rally.common import cfg diff --git a/requirements.txt b/requirements.txt index 4031f7b7..afb0c286 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ rally>=0.11.0 # Apache License, Version boto>=2.32.1 # MIT gnocchiclient>=3.3.1 # Apache Software License keystoneauth1>=3.3.0 # Apache Software License -kubernetes>1.0.0 # Apache License Version 2.0 +kubernetes>=11.0.0 # Apache License Version 2.0 os-faults>=0.2.0 # Apache Software License osprofiler>=1.4.0 # Apache Software License python-barbicanclient>=4.5.2 # Apache Software License diff --git a/tests/unit/scenarios/magnum/test_utils.py b/tests/unit/scenarios/magnum/test_utils.py index a37a7ca3..a5f00b74 100644 --- a/tests/unit/scenarios/magnum/test_utils.py +++ b/tests/unit/scenarios/magnum/test_utils.py @@ -17,7 +17,6 @@ import os import mock from kubernetes import client as kubernetes_client -from kubernetes.client import api_client from kubernetes.client.rest import ApiException from rally import exceptions from rally_openstack.scenarios.magnum import utils @@ -136,7 +135,7 @@ class MagnumScenarioTestCase(test.ScenarioTestCase): self.scenario.atomic_actions(), "magnum.create_ca_certificate") @mock.patch("kubernetes.client.api_client.ApiClient") - @mock.patch("kubernetes.client.apis.core_v1_api.CoreV1Api") + @mock.patch("kubernetes.client.api.core_v1_api.CoreV1Api") def test_get_k8s_api_client_using_tls(self, mock_core_v1_api, mock_api_client): @@ -184,7 +183,7 @@ class MagnumScenarioTestCase(test.ScenarioTestCase): mock_core_v1_api.assert_called_once_with(_api_client) @mock.patch("kubernetes.client.api_client.ApiClient") - @mock.patch("kubernetes.client.apis.core_v1_api.CoreV1Api") + @mock.patch("kubernetes.client.api.core_v1_api.CoreV1Api") def test_get_k8s_api_client(self, mock_core_v1_api, mock_api_client): if hasattr(kubernetes_client, "ConfigurationObject"): @@ -246,23 +245,23 @@ class MagnumScenarioTestCase(test.ScenarioTestCase): podname = podname + mock_random_choice.return_value k8s_api.create_namespaced_pod = mock.MagicMock( side_effect=[ApiException(status=403), self.pod]) - not_ready_pod = api_client.models.V1Pod() - not_ready_status = api_client.models.V1PodStatus() + not_ready_pod = kubernetes_client.models.V1Pod() + not_ready_status = kubernetes_client.models.V1PodStatus() not_ready_status.phase = "not_ready" not_ready_pod.status = not_ready_status - almost_ready_pod = api_client.models.V1Pod() - almost_ready_status = api_client.models.V1PodStatus() + almost_ready_pod = kubernetes_client.models.V1Pod() + almost_ready_status = kubernetes_client.models.V1PodStatus() almost_ready_status.phase = "almost_ready" almost_ready_pod.status = almost_ready_status - ready_pod = api_client.models.V1Pod() - ready_condition = api_client.models.V1PodCondition(status="True", - type="Ready") - ready_status = api_client.models.V1PodStatus() + ready_pod = kubernetes_client.models.V1Pod() + ready_condition = kubernetes_client.models.V1PodCondition( + status="True", type="Ready") + ready_status = kubernetes_client.models.V1PodStatus() ready_status.phase = "Running" ready_status.conditions = [ready_condition] - ready_pod_metadata = api_client.models.V1ObjectMeta() + ready_pod_metadata = kubernetes_client.models.V1ObjectMeta() ready_pod_metadata.uid = "123456789" - ready_pod_spec = api_client.models.V1PodSpec( + ready_pod_spec = kubernetes_client.models.V1PodSpec( node_name="host_abc", containers=[] ) @@ -290,10 +289,10 @@ class MagnumScenarioTestCase(test.ScenarioTestCase): "metadata": {"name": "nginx"}}) k8s_api.create_namespaced_pod.return_value = self.pod mock_time.side_effect = [1, 2, 3, 4, 5, 1800, 1801] - not_ready_pod = api_client.models.V1Pod() - not_ready_status = api_client.models.V1PodStatus() + not_ready_pod = kubernetes_client.models.V1Pod() + not_ready_status = kubernetes_client.models.V1PodStatus() not_ready_status.phase = "not_ready" - not_ready_pod_metadata = api_client.models.V1ObjectMeta() + not_ready_pod_metadata = kubernetes_client.models.V1ObjectMeta() not_ready_pod_metadata.uid = "123456789" not_ready_pod.status = not_ready_status not_ready_pod.metadata = not_ready_pod_metadata @@ -332,19 +331,20 @@ class MagnumScenarioTestCase(test.ScenarioTestCase): for i in range(5): suffix = suffix + mock_random_choice.return_value rcname = manifest["metadata"]["name"] + suffix - rc = api_client.models.V1ReplicationController() - rc.spec = api_client.models.V1ReplicationControllerSpec() + rc = kubernetes_client.models.V1ReplicationController() + rc.spec = kubernetes_client.models.V1ReplicationControllerSpec() rc.spec.replicas = manifest["spec"]["replicas"] k8s_api.create_namespaced_replication_controller.return_value = rc - not_ready_rc = api_client.models.V1ReplicationController() + not_ready_rc = kubernetes_client.models.V1ReplicationController() not_ready_rc_status = ( - api_client.models.V1ReplicationControllerStatus(replicas=0)) + kubernetes_client.models.V1ReplicationControllerStatus(replicas=0)) not_ready_rc.status = not_ready_rc_status - ready_rc = api_client.models.V1ReplicationController() - ready_rc_status = api_client.models.V1ReplicationControllerStatus( - replicas=manifest["spec"]["replicas"] + ready_rc = kubernetes_client.models.V1ReplicationController() + ready_rc_status = ( + kubernetes_client.models.V1ReplicationControllerStatus( + replicas=manifest["spec"]["replicas"]) ) - ready_rc_metadata = api_client.models.V1ObjectMeta() + ready_rc_metadata = kubernetes_client.models.V1ObjectMeta() ready_rc_metadata.uid = "123456789" ready_rc_metadata.name = rcname ready_rc.status = ready_rc_status @@ -374,15 +374,15 @@ class MagnumScenarioTestCase(test.ScenarioTestCase): "template": {"metadata": {"labels": {"name": "nginx"}}}}}) - rc = api_client.models.V1ReplicationController() - rc.spec = api_client.models.V1ReplicationControllerSpec() + rc = kubernetes_client.models.V1ReplicationController() + rc.spec = kubernetes_client.models.V1ReplicationControllerSpec() rc.spec.replicas = manifest["spec"]["replicas"] mock_time.side_effect = [1, 2, 3, 4, 5, 1800, 1801] k8s_api.create_namespaced_replication_controller.return_value = rc - not_ready_rc = api_client.models.V1ReplicationController() + not_ready_rc = kubernetes_client.models.V1ReplicationController() not_ready_rc_status = ( - api_client.models.V1ReplicationControllerStatus(replicas=0)) - not_ready_rc_metadata = api_client.models.V1ObjectMeta() + kubernetes_client.models.V1ReplicationControllerStatus(replicas=0)) + not_ready_rc_metadata = kubernetes_client.models.V1ObjectMeta() not_ready_rc_metadata.uid = "123456789" not_ready_rc.status = not_ready_rc_status not_ready_rc.metadata = not_ready_rc_metadata diff --git a/upper-constraints.txt b/upper-constraints.txt index 9a4ae39b..e5da8f9a 100644 --- a/upper-constraints.txt +++ b/upper-constraints.txt @@ -43,7 +43,7 @@ jsonpatch===1.23 jsonpointer===2.0 jsonschema===3.0.2 keystoneauth1===3.11.0 -kubernetes===10.0.1 +kubernetes===11.0.0 linecache2===1.0.0 Mako===1.0.7 MarkupSafe===1.1.1