Add Calico tests (copied from mcp-qa)
Change-Id: I10219fc78c8759919c631baa9e9f95baf631c1dc
Reviewed-on: https://review.gerrithub.io/365463
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/managers/k8s/deployments.py b/tcp_tests/managers/k8s/deployments.py
index 1dbd1d2..5d47d70 100644
--- a/tcp_tests/managers/k8s/deployments.py
+++ b/tcp_tests/managers/k8s/deployments.py
@@ -26,6 +26,10 @@
def name(self):
return self.metadata.name
+ @property
+ def namespace(self):
+ return self.metadata.namespace
+
class K8sDeploymentManager(K8sBaseManager):
"""docstring for ClassName"""
diff --git a/tcp_tests/managers/k8smanager.py b/tcp_tests/managers/k8smanager.py
index 45cb078..04222d9 100644
--- a/tcp_tests/managers/k8smanager.py
+++ b/tcp_tests/managers/k8smanager.py
@@ -229,6 +229,44 @@
lambda: self.check_ds_ready(dsname, namespace=namespace),
timeout=timeout, interval=interval)
+ def check_deploy_create(self, body, namespace=None):
+ """Check creating k8s Deployment
+
+ :param body: dict, Deployment spec
+ :param namespace: str
+ :rtype: K8sDeployment object
+ """
+ LOG.info("Creating Deployment in k8s cluster")
+ LOG.debug(
+ "Deployment spec to create:\n{}".format(
+ yaml.dump(body, default_flow_style=False))
+ )
+ deploy = self.api.deployments.create(body=body, namespace=namespace)
+ LOG.info("Deployment '{0}' is created in '{1}' namespace".format(
+ deploy.name, deploy.namespace))
+ return self.api.deployments.get(name=deploy.name,
+ namespace=deploy.namespace)
+
+ def check_deploy_ready(self, deploy_name, namespace=None):
+ """Check if k8s Deployment is ready
+
+ :param deploy_name: str, deploy name
+ :return: bool
+ """
+ deploy = self.api.deployments.get(name=deploy_name, namespace=namespace)
+ return deploy.status.available_replicas == deploy.status.replicas
+
+ def wait_deploy_ready(self, deploy_name, namespace=None, timeout=60, interval=5):
+ """Wait until all pods are scheduled on nodes
+
+ :param deploy_name: str, deploy name
+ :param timeout: int
+ :param interval: int
+ """
+ helpers.wait(
+ lambda: self.check_deploy_ready(deploy_name, namespace=namespace),
+ timeout=timeout, interval=interval)
+
def check_namespace_create(self, name):
"""Check creating k8s Namespace
@@ -290,3 +328,9 @@
self.__config.k8s.k8s_conformance_image),
timeout=timeout)['stdout']
return result
+
+ def get_k8s_masters(self):
+ k8s_masters_fqdn = self._salt.get_pillar(tgt='I@kubernetes:master',
+ pillar='linux:network:fqdn')
+ return [self._K8SManager__underlay.host_by_node_name(node_name=v)
+ for pillar in k8s_masters_fqdn for k, v in pillar.items()]