diff options
author | Sylvain Desbureaux <sylvain.desbureaux@orange.com> | 2021-03-24 08:23:03 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2021-04-02 10:07:39 +0200 |
commit | 1ab07437d4c6c787ec30563fd4a52c162bd689a2 (patch) | |
tree | 57ea472fc09df037464b180f738fdc66f2762c03 /functest_kubernetes/ims/ims.py | |
parent | 521642ab84512aff7e4df952b0725703f1a70779 (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
(cherry picked from commit 9c95b5f46e57365c1f6e7e5c9073f7fe2ad48a66)
Diffstat (limited to 'functest_kubernetes/ims/ims.py')
-rw-r--r-- | functest_kubernetes/ims/ims.py | 16 |
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) |