aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>2021-03-24 08:44:29 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2021-04-02 10:07:51 +0200
commit140884ef9183cb53c3d4419f4712a646c3ded7c4 (patch)
tree72484e59fcf7f96652c40b67e1bf3dd16736ab71
parent7b6c7186d3af9f0a87cecf9d3d7a992ac8169375 (diff)
Provide support for air gapped env for e2e
Sometimes, tested Kubernetes doesn't have direct access to Internet but access through repository mirrors. This patch handles this case for e2e test case. Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com> Change-Id: Iaa2960ad03aae1fff859d41bcd6ddf3176658f8e (cherry picked from commit 27dbb7c14bac45a9af8d18e1913a2be6815cea43)
-rw-r--r--README.md8
-rw-r--r--functest_kubernetes/k8stest.py35
2 files changed, 42 insertions, 1 deletions
diff --git a/README.md b/README.md
index d6d131ff..3bed0147 100644
--- a/README.md
+++ b/README.md
@@ -123,7 +123,7 @@ sudo docker run --env-file env \
To test a Kubernetes without access to Internet, repository mirrors needs to be
provided.
-Currently, only ims, rally and security tests supports this feature.
+Currently, all tests supports this feature except cnf conformance.
There's two ways for providing the repository mirrors:
@@ -137,3 +137,9 @@ There's two ways for providing the repository mirrors:
All needed images are given in
[functest-kubernetes/ci/images.txt](functest-kubernetes/ci/images.txt)
+
+For e2e tests, `docker.io` is hardcoded. it does mean that you'll have to set up
+a mirror on docker. An example on how to set it up on docker daemon is provided
+here:
+[daemon-configuration-file](
+https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file)
diff --git a/functest_kubernetes/k8stest.py b/functest_kubernetes/k8stest.py
index 35649edc..bd1aed8a 100644
--- a/functest_kubernetes/k8stest.py
+++ b/functest_kubernetes/k8stest.py
@@ -19,6 +19,7 @@ import os
import re
import subprocess
import time
+import yaml
from xtesting.core import testcase
@@ -30,6 +31,8 @@ class E2ETesting(testcase.TestCase):
__logger = logging.getLogger(__name__)
config = '/root/.kube/config'
+ gcr_repo = os.getenv("MIRROR_REPO", "gcr.io")
+ k8s_gcr_repo = os.getenv("MIRROR_REPO", "k8s.gcr.io")
def __init__(self, **kwargs):
super(E2ETesting, self).__init__(**kwargs)
@@ -52,9 +55,11 @@ class E2ETesting(testcase.TestCase):
cmd_line.extend(
['-non-blocking-taints', os.environ["NON_BLOCKING_TAINTS"]])
cmd_line.extend(['-disable-log-dump', 'true'])
+ self._generate_repo_list_file()
self.__logger.info("Starting k8s test: '%s'.", cmd_line)
env = os.environ.copy()
env["GINKGO_PARALLEL"] = 'y'
+ env["KUBE_TEST_REPO_LIST"] = "{}/repositories.yml".format(self.res_dir)
process = subprocess.Popen(cmd_line, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, env=env)
boutput = process.stdout.read()
@@ -84,6 +89,8 @@ class E2ETesting(testcase.TestCase):
self.__logger.error(grp2.group(1))
def run(self, **kwargs):
+ if not os.path.exists(self.res_dir):
+ os.makedirs(self.res_dir)
if not os.path.isfile(self.config):
self.__logger.error(
"Cannot run k8s testcases. Config file not found")
@@ -97,3 +104,31 @@ class E2ETesting(testcase.TestCase):
res = self.EX_RUN_ERROR
self.stop_time = time.time()
return res
+
+ def _generate_repo_list_file(self):
+ """Generate the repositories list for the test."""
+ # The list is taken from
+ # https://github.com/kubernetes/kubernetes/blob/master/test/utils/image/manifest.go
+ # It may needs update regularly
+ gcr_repo = os.getenv("GCR_REPO", self.gcr_repo)
+ k8s_gcr_repo = os.getenv("K8S_GCR_REPO", self.k8s_gcr_repo)
+ repo_list = {
+ "GcAuthenticatedRegistry": "{}/authenticated-image-pulling".format(
+ gcr_repo),
+ "E2eRegistry": "{}/kubernetes-e2e-test-images".format(
+ gcr_repo),
+ "PromoterE2eRegistry": "{}/e2e-test-images".format(
+ k8s_gcr_repo),
+ "BuildImageRegistry": "{}/build-image".format(k8s_gcr_repo),
+ "InvalidRegistry": "invalid.com/invalid",
+ "GcEtcdRegistry": "{}".format(k8s_gcr_repo),
+ "GcRegistry": "{}".format(k8s_gcr_repo),
+ "SigStorageRegistry": "{}/sig-storage".format(k8s_gcr_repo),
+ "PrivateRegistry": "{}/k8s-authenticated-test".format(
+ gcr_repo),
+ "SampleRegistry": "{}/google-samples".format(gcr_repo),
+ "GcrReleaseRegistry": "{}/gke-release".format(gcr_repo),
+ "MicrosoftRegistry": "mcr.microsoft.com",
+ }
+ with open("{}/repositories.yml".format(self.res_dir), 'w') as file:
+ yaml.dump(repo_list, file)