aboutsummaryrefslogtreecommitdiffstats
path: root/functest_kubernetes/ims/ims.py
diff options
context:
space:
mode:
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>2021-03-24 08:23:03 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2021-03-25 09:59:34 +0100
commit9c95b5f46e57365c1f6e7e5c9073f7fe2ad48a66 (patch)
treebbf1191c54b571e95086ebe0d793bc72544b99ff /functest_kubernetes/ims/ims.py
parentaf623f6b45c9357b0e33210f54db64b270d162bf (diff)
Provide support for air gapped env for ims
Sometimes, tested Kubernetes doesn't have direct access to Internet but access through repository mirrors. This patch handles this case for ims test cases. Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com> Change-Id: I3b5e78fcf43ca7af6bcfd2d87fa4bb0705373697
Diffstat (limited to 'functest_kubernetes/ims/ims.py')
-rw-r--r--functest_kubernetes/ims/ims.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/functest_kubernetes/ims/ims.py b/functest_kubernetes/ims/ims.py
index adb46023..49a66370 100644
--- a/functest_kubernetes/ims/ims.py
+++ b/functest_kubernetes/ims/ims.py
@@ -13,11 +13,13 @@ from __future__ import division
import abc
import logging
+import os
import time
import subprocess
import re
import yaml
+from jinja2 import Template
from kubernetes import client
from kubernetes import config
from kubernetes import watch
@@ -39,6 +41,8 @@ class Vims(testcase.TestCase): # pylint: disable=too-many-instance-attributes
test_image_name = "ollivier/clearwater-live-test:hunter"
test_container_name = "live-test"
ns_generate_name = "ims-"
+ dockerhub_repo = os.getenv("MIRROR_REPO", "docker.io")
+ quay_repo = os.getenv("MIRROR_REPO", "quay.io")
__logger = logging.getLogger(__name__)
@@ -218,7 +222,12 @@ class K8sVims(Vims):
with open(pkg_resources.resource_filename(
'functest_kubernetes',
'ims/{}-depl.yaml'.format(deployment))) as yfile:
- body = yaml.safe_load(yfile)
+ template = Template(yfile.read())
+ body = yaml.safe_load(template.render(
+ dockerhub_repo=os.getenv(
+ "DOCKERHUB_REPO", self.dockerhub_repo),
+ quay_repo=os.getenv(
+ "QUAY_REPO", self.quay_repo)))
resp = self.appsv1.create_namespaced_deployment(
body=body, namespace=self.namespace)
self.__logger.info("Deployment %s created", resp.metadata.name)
@@ -270,8 +279,11 @@ class HelmVims(Vims):
See https://github.com/Metaswitch/clearwater-docker for more details
"""
+ dockerhub_repo = os.getenv("DOCKERHUB_REPO", self.dockerhub_repo)
+ quay_repo = os.getenv("QUAY_REPO", self.quay_repo)
cmd = [
- "helm", "install", "clearwater",
+ "helm", "install", "clearwater", "--set",
+ "repo.dockerHub={},repo.quay={}".format(dockerhub_repo, quay_repo),
pkg_resources.resource_filename("functest_kubernetes", "ims/helm"),
"-n", self.namespace]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)