Update magnum/utils.py to match Kubernetes changes
Tempest verification as proposed by Rally fails vs Kubernetes 11.0.0 [1]. It should be noted that Kubernetes was updated to 11.0.0 in Openstack master upper-constraints [2]. It sets kubernetes>=11.0.0 as abstract dependency [3][4]. It replace api_client.models by kubernetes_client.models in magnum test_utils.py (kubernetes_client could rather have been selected). [1] https://build.opnfv.org/ci/job/functest-opnfv-functest-healthcheck-latest-tempest_smoke-run/749/console [2]76a83f23a6
[3] https://github.com/openstack/requirements/blob/master/global-requirements.txt#L115 [4]5cddbde0bf
Change-Id: I76c2d089b5a9d947a910a0410c4784c5a0cdddb3 Signed-off-by: Cédric Ollivier <ollivier.cedric@gmail.com>
This commit is contained in:
parent
6847b85085
commit
5776e015f1
|
@ -18,8 +18,8 @@ import string
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from kubernetes import client as k8s_config
|
from kubernetes import client as k8s_config
|
||||||
|
from kubernetes.client.api import core_v1_api
|
||||||
from kubernetes.client import api_client
|
from kubernetes.client import api_client
|
||||||
from kubernetes.client.apis import core_v1_api
|
|
||||||
from kubernetes.client.rest import ApiException
|
from kubernetes.client.rest import ApiException
|
||||||
|
|
||||||
from rally.common import cfg
|
from rally.common import cfg
|
||||||
|
|
|
@ -10,7 +10,7 @@ rally>=0.11.0 # Apache License, Version
|
||||||
boto>=2.32.1 # MIT
|
boto>=2.32.1 # MIT
|
||||||
gnocchiclient>=3.3.1 # Apache Software License
|
gnocchiclient>=3.3.1 # Apache Software License
|
||||||
keystoneauth1>=3.3.0 # 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
|
os-faults>=0.2.0 # Apache Software License
|
||||||
osprofiler>=1.4.0 # Apache Software License
|
osprofiler>=1.4.0 # Apache Software License
|
||||||
python-barbicanclient>=4.5.2 # Apache Software License
|
python-barbicanclient>=4.5.2 # Apache Software License
|
||||||
|
|
|
@ -17,7 +17,6 @@ import os
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from kubernetes import client as kubernetes_client
|
from kubernetes import client as kubernetes_client
|
||||||
from kubernetes.client import api_client
|
|
||||||
from kubernetes.client.rest import ApiException
|
from kubernetes.client.rest import ApiException
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally_openstack.scenarios.magnum import utils
|
from rally_openstack.scenarios.magnum import utils
|
||||||
|
@ -136,7 +135,7 @@ class MagnumScenarioTestCase(test.ScenarioTestCase):
|
||||||
self.scenario.atomic_actions(), "magnum.create_ca_certificate")
|
self.scenario.atomic_actions(), "magnum.create_ca_certificate")
|
||||||
|
|
||||||
@mock.patch("kubernetes.client.api_client.ApiClient")
|
@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,
|
def test_get_k8s_api_client_using_tls(self, mock_core_v1_api,
|
||||||
mock_api_client):
|
mock_api_client):
|
||||||
|
|
||||||
|
@ -184,7 +183,7 @@ class MagnumScenarioTestCase(test.ScenarioTestCase):
|
||||||
mock_core_v1_api.assert_called_once_with(_api_client)
|
mock_core_v1_api.assert_called_once_with(_api_client)
|
||||||
|
|
||||||
@mock.patch("kubernetes.client.api_client.ApiClient")
|
@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):
|
def test_get_k8s_api_client(self, mock_core_v1_api, mock_api_client):
|
||||||
|
|
||||||
if hasattr(kubernetes_client, "ConfigurationObject"):
|
if hasattr(kubernetes_client, "ConfigurationObject"):
|
||||||
|
@ -246,23 +245,23 @@ class MagnumScenarioTestCase(test.ScenarioTestCase):
|
||||||
podname = podname + mock_random_choice.return_value
|
podname = podname + mock_random_choice.return_value
|
||||||
k8s_api.create_namespaced_pod = mock.MagicMock(
|
k8s_api.create_namespaced_pod = mock.MagicMock(
|
||||||
side_effect=[ApiException(status=403), self.pod])
|
side_effect=[ApiException(status=403), self.pod])
|
||||||
not_ready_pod = api_client.models.V1Pod()
|
not_ready_pod = kubernetes_client.models.V1Pod()
|
||||||
not_ready_status = api_client.models.V1PodStatus()
|
not_ready_status = kubernetes_client.models.V1PodStatus()
|
||||||
not_ready_status.phase = "not_ready"
|
not_ready_status.phase = "not_ready"
|
||||||
not_ready_pod.status = not_ready_status
|
not_ready_pod.status = not_ready_status
|
||||||
almost_ready_pod = api_client.models.V1Pod()
|
almost_ready_pod = kubernetes_client.models.V1Pod()
|
||||||
almost_ready_status = api_client.models.V1PodStatus()
|
almost_ready_status = kubernetes_client.models.V1PodStatus()
|
||||||
almost_ready_status.phase = "almost_ready"
|
almost_ready_status.phase = "almost_ready"
|
||||||
almost_ready_pod.status = almost_ready_status
|
almost_ready_pod.status = almost_ready_status
|
||||||
ready_pod = api_client.models.V1Pod()
|
ready_pod = kubernetes_client.models.V1Pod()
|
||||||
ready_condition = api_client.models.V1PodCondition(status="True",
|
ready_condition = kubernetes_client.models.V1PodCondition(
|
||||||
type="Ready")
|
status="True", type="Ready")
|
||||||
ready_status = api_client.models.V1PodStatus()
|
ready_status = kubernetes_client.models.V1PodStatus()
|
||||||
ready_status.phase = "Running"
|
ready_status.phase = "Running"
|
||||||
ready_status.conditions = [ready_condition]
|
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_metadata.uid = "123456789"
|
||||||
ready_pod_spec = api_client.models.V1PodSpec(
|
ready_pod_spec = kubernetes_client.models.V1PodSpec(
|
||||||
node_name="host_abc",
|
node_name="host_abc",
|
||||||
containers=[]
|
containers=[]
|
||||||
)
|
)
|
||||||
|
@ -290,10 +289,10 @@ class MagnumScenarioTestCase(test.ScenarioTestCase):
|
||||||
"metadata": {"name": "nginx"}})
|
"metadata": {"name": "nginx"}})
|
||||||
k8s_api.create_namespaced_pod.return_value = self.pod
|
k8s_api.create_namespaced_pod.return_value = self.pod
|
||||||
mock_time.side_effect = [1, 2, 3, 4, 5, 1800, 1801]
|
mock_time.side_effect = [1, 2, 3, 4, 5, 1800, 1801]
|
||||||
not_ready_pod = api_client.models.V1Pod()
|
not_ready_pod = kubernetes_client.models.V1Pod()
|
||||||
not_ready_status = api_client.models.V1PodStatus()
|
not_ready_status = kubernetes_client.models.V1PodStatus()
|
||||||
not_ready_status.phase = "not_ready"
|
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_metadata.uid = "123456789"
|
||||||
not_ready_pod.status = not_ready_status
|
not_ready_pod.status = not_ready_status
|
||||||
not_ready_pod.metadata = not_ready_pod_metadata
|
not_ready_pod.metadata = not_ready_pod_metadata
|
||||||
|
@ -332,19 +331,20 @@ class MagnumScenarioTestCase(test.ScenarioTestCase):
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
suffix = suffix + mock_random_choice.return_value
|
suffix = suffix + mock_random_choice.return_value
|
||||||
rcname = manifest["metadata"]["name"] + suffix
|
rcname = manifest["metadata"]["name"] + suffix
|
||||||
rc = api_client.models.V1ReplicationController()
|
rc = kubernetes_client.models.V1ReplicationController()
|
||||||
rc.spec = api_client.models.V1ReplicationControllerSpec()
|
rc.spec = kubernetes_client.models.V1ReplicationControllerSpec()
|
||||||
rc.spec.replicas = manifest["spec"]["replicas"]
|
rc.spec.replicas = manifest["spec"]["replicas"]
|
||||||
k8s_api.create_namespaced_replication_controller.return_value = rc
|
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 = (
|
not_ready_rc_status = (
|
||||||
api_client.models.V1ReplicationControllerStatus(replicas=0))
|
kubernetes_client.models.V1ReplicationControllerStatus(replicas=0))
|
||||||
not_ready_rc.status = not_ready_rc_status
|
not_ready_rc.status = not_ready_rc_status
|
||||||
ready_rc = api_client.models.V1ReplicationController()
|
ready_rc = kubernetes_client.models.V1ReplicationController()
|
||||||
ready_rc_status = api_client.models.V1ReplicationControllerStatus(
|
ready_rc_status = (
|
||||||
replicas=manifest["spec"]["replicas"]
|
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.uid = "123456789"
|
||||||
ready_rc_metadata.name = rcname
|
ready_rc_metadata.name = rcname
|
||||||
ready_rc.status = ready_rc_status
|
ready_rc.status = ready_rc_status
|
||||||
|
@ -374,15 +374,15 @@ class MagnumScenarioTestCase(test.ScenarioTestCase):
|
||||||
"template": {"metadata":
|
"template": {"metadata":
|
||||||
{"labels":
|
{"labels":
|
||||||
{"name": "nginx"}}}}})
|
{"name": "nginx"}}}}})
|
||||||
rc = api_client.models.V1ReplicationController()
|
rc = kubernetes_client.models.V1ReplicationController()
|
||||||
rc.spec = api_client.models.V1ReplicationControllerSpec()
|
rc.spec = kubernetes_client.models.V1ReplicationControllerSpec()
|
||||||
rc.spec.replicas = manifest["spec"]["replicas"]
|
rc.spec.replicas = manifest["spec"]["replicas"]
|
||||||
mock_time.side_effect = [1, 2, 3, 4, 5, 1800, 1801]
|
mock_time.side_effect = [1, 2, 3, 4, 5, 1800, 1801]
|
||||||
k8s_api.create_namespaced_replication_controller.return_value = rc
|
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 = (
|
not_ready_rc_status = (
|
||||||
api_client.models.V1ReplicationControllerStatus(replicas=0))
|
kubernetes_client.models.V1ReplicationControllerStatus(replicas=0))
|
||||||
not_ready_rc_metadata = api_client.models.V1ObjectMeta()
|
not_ready_rc_metadata = kubernetes_client.models.V1ObjectMeta()
|
||||||
not_ready_rc_metadata.uid = "123456789"
|
not_ready_rc_metadata.uid = "123456789"
|
||||||
not_ready_rc.status = not_ready_rc_status
|
not_ready_rc.status = not_ready_rc_status
|
||||||
not_ready_rc.metadata = not_ready_rc_metadata
|
not_ready_rc.metadata = not_ready_rc_metadata
|
||||||
|
|
|
@ -43,7 +43,7 @@ jsonpatch===1.23
|
||||||
jsonpointer===2.0
|
jsonpointer===2.0
|
||||||
jsonschema===3.0.2
|
jsonschema===3.0.2
|
||||||
keystoneauth1===3.11.0
|
keystoneauth1===3.11.0
|
||||||
kubernetes===10.0.1
|
kubernetes===11.0.0
|
||||||
linecache2===1.0.0
|
linecache2===1.0.0
|
||||||
Mako===1.0.7
|
Mako===1.0.7
|
||||||
MarkupSafe===1.1.1
|
MarkupSafe===1.1.1
|
||||||
|
|
Loading…
Reference in New Issue