diff options
26 files changed, 123 insertions, 66 deletions
@@ -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 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: @@ -133,6 +133,13 @@ There's two ways for providing the repository mirrors: - `DOCKERHUB_REPO` for DockerHub repository (`docker.io`) - `GCR_REPO` for Google Cloud repository (`gcr.io`) - `K8S_GCR_REPO` for Kubernetes repository (`k8s.gcr.io`) + - `QUAY_REPO` for Quay repository (`quay.io`) 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/ims/astaire-depl.yaml b/functest_kubernetes/ims/astaire-depl.yaml index 2ceebfde..d00b790b 100644 --- a/functest_kubernetes/ims/astaire-depl.yaml +++ b/functest_kubernetes/ims/astaire-depl.yaml @@ -15,10 +15,10 @@ spec: terminationGracePeriodSeconds: 120 initContainers: - name: wait-on-cassandra - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-astaire:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-astaire:hunter" name: astaire ports: - containerPort: 22 @@ -47,7 +47,7 @@ spec: preStop: exec: command: ["/bin/bash", "-c", "/usr/bin/pre-stop"] - - image: busybox:1.28 + - image: {{ dockerhub_repo }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/astaire/astaire_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/bono-depl.yaml b/functest_kubernetes/ims/bono-depl.yaml index d8507165..3537927e 100644 --- a/functest_kubernetes/ims/bono-depl.yaml +++ b/functest_kubernetes/ims/bono-depl.yaml @@ -15,10 +15,10 @@ spec: spec: initContainers: - name: wait-on-sprout - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup sprout; do echo waiting for sprout to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-bono:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-bono:hunter" name: bono ports: - containerPort: 22 @@ -54,7 +54,7 @@ spec: volumeMounts: - name: bonologs mountPath: /var/log/bono - - image: busybox:1.28 + - image: {{ dockerhub_repo }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/bono/bono_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/cassandra-depl.yaml b/functest_kubernetes/ims/cassandra-depl.yaml index 50f8c87c..8f33abc5 100644 --- a/functest_kubernetes/ims/cassandra-depl.yaml +++ b/functest_kubernetes/ims/cassandra-depl.yaml @@ -14,10 +14,10 @@ spec: spec: initContainers: - name: wait-on-etcd - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup etcd; do echo waiting for etcd to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-cassandra:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-cassandra:hunter" name: cassandra ports: - containerPort: 22 diff --git a/functest_kubernetes/ims/chronos-depl.yaml b/functest_kubernetes/ims/chronos-depl.yaml index 5f753f1f..cd9c8bcc 100644 --- a/functest_kubernetes/ims/chronos-depl.yaml +++ b/functest_kubernetes/ims/chronos-depl.yaml @@ -16,11 +16,11 @@ spec: spec: terminationGracePeriodSeconds: 120 initContainers: - - name: wait-on-cassandra - image: busybox:1.28 + - name: {{ dockerhub_repo }}/wait-on-cassandra + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-chronos:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-chronos:hunter" name: chronos ports: - containerPort: 22 @@ -48,7 +48,7 @@ spec: preStop: exec: command: ["/bin/bash", "-c", "/usr/bin/pre-stop"] - - image: busybox:1.28 + - image: {{ dockerhub_repo }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/chronos/chronos_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/ellis-depl.yaml b/functest_kubernetes/ims/ellis-depl.yaml index 9403dbbe..6d69d62b 100644 --- a/functest_kubernetes/ims/ellis-depl.yaml +++ b/functest_kubernetes/ims/ellis-depl.yaml @@ -14,13 +14,13 @@ spec: spec: initContainers: - name: wait-on-homestead-prov - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup homestead-prov; do echo waiting for homestead-prov to start ...; sleep 2; done'] - name: wait-on-sprout - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup sprout; do echo waiting for sprout to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-ellis:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-ellis:hunter" name: ellis ports: - containerPort: 22 diff --git a/functest_kubernetes/ims/etcd-depl.yaml b/functest_kubernetes/ims/etcd-depl.yaml index c9e628ff..0fc50cb6 100644 --- a/functest_kubernetes/ims/etcd-depl.yaml +++ b/functest_kubernetes/ims/etcd-depl.yaml @@ -45,7 +45,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.name - image: quay.io/coreos/etcd:v2.2.5 + image: {{ quay_repo }}/coreos/etcd:v2.2.5 name: etcd ports: - containerPort: 2379 diff --git a/functest_kubernetes/ims/helm/templates/astaire-depl.yaml b/functest_kubernetes/ims/helm/templates/astaire-depl.yaml index 11fcb1d6..13bf0001 100644 --- a/functest_kubernetes/ims/helm/templates/astaire-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/astaire-depl.yaml @@ -15,10 +15,10 @@ spec: terminationGracePeriodSeconds: 120 initContainers: - name: wait-on-cassandra - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-astaire:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-astaire:{{ .Values.image.tag }}" name: astaire ports: - containerPort: 22 @@ -47,7 +47,7 @@ spec: preStop: exec: command: ["/bin/bash", "-c", "/usr/bin/pre-stop"] - - image: busybox:1.28 + - image: {{ .Values.repo.dockerHub }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/astaire/astaire_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/helm/templates/bono-depl.yaml b/functest_kubernetes/ims/helm/templates/bono-depl.yaml index d3fb1b82..2ab749b4 100644 --- a/functest_kubernetes/ims/helm/templates/bono-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/bono-depl.yaml @@ -15,10 +15,10 @@ spec: spec: initContainers: - name: wait-on-sprout - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup sprout; do echo waiting for sprout to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-bono:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-bono:{{ .Values.image.tag }}" name: bono ports: - containerPort: 22 @@ -54,7 +54,7 @@ spec: volumeMounts: - name: bonologs mountPath: /var/log/bono - - image: busybox:1.28 + - image: {{ .Values.repo.dockerHub }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/bono/bono_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/helm/templates/cassandra-depl.yaml b/functest_kubernetes/ims/helm/templates/cassandra-depl.yaml index fb04a78f..d1850f52 100644 --- a/functest_kubernetes/ims/helm/templates/cassandra-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/cassandra-depl.yaml @@ -14,10 +14,10 @@ spec: spec: initContainers: - name: wait-on-etcd - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup etcd; do echo waiting for etcd to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-cassandra:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-cassandra:{{ .Values.image.tag }}" name: cassandra ports: - containerPort: 22 diff --git a/functest_kubernetes/ims/helm/templates/chronos-depl.yaml b/functest_kubernetes/ims/helm/templates/chronos-depl.yaml index 641ba479..6188754e 100644 --- a/functest_kubernetes/ims/helm/templates/chronos-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/chronos-depl.yaml @@ -17,10 +17,10 @@ spec: terminationGracePeriodSeconds: 120 initContainers: - name: wait-on-cassandra - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-chronos:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-chronos:{{ .Values.image.tag }}" name: chronos ports: - containerPort: 22 @@ -48,7 +48,7 @@ spec: preStop: exec: command: ["/bin/bash", "-c", "/usr/bin/pre-stop"] - - image: busybox:1.28 + - image: {{ .Values.repo.dockerHub }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/chronos/chronos_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/helm/templates/ellis-depl.yaml b/functest_kubernetes/ims/helm/templates/ellis-depl.yaml index 0a290139..c8dd9232 100644 --- a/functest_kubernetes/ims/helm/templates/ellis-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/ellis-depl.yaml @@ -14,13 +14,13 @@ spec: spec: initContainers: - name: wait-on-homestead-prov - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup homestead-prov; do echo waiting for homestead-prov to start ...; sleep 2; done'] - name: wait-on-sprout - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup sprout; do echo waiting for sprout to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-ellis:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-ellis:{{ .Values.image.tag }}" name: ellis ports: - containerPort: 22 diff --git a/functest_kubernetes/ims/helm/templates/etcd-depl.yaml b/functest_kubernetes/ims/helm/templates/etcd-depl.yaml index c9e628ff..33fc2e81 100644 --- a/functest_kubernetes/ims/helm/templates/etcd-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/etcd-depl.yaml @@ -45,7 +45,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.name - image: quay.io/coreos/etcd:v2.2.5 + image: {{ .Values.repo.quay }}//coreos/etcd:v2.2.5 name: etcd ports: - containerPort: 2379 diff --git a/functest_kubernetes/ims/helm/templates/homer-depl.yaml b/functest_kubernetes/ims/helm/templates/homer-depl.yaml index 01bf9cdc..073124f1 100644 --- a/functest_kubernetes/ims/helm/templates/homer-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/homer-depl.yaml @@ -14,10 +14,10 @@ spec: spec: initContainers: - name: wait-on-cassandra - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-homer:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-homer:{{ .Values.image.tag }}" name: homer ports: - containerPort: 22 diff --git a/functest_kubernetes/ims/helm/templates/homestead-depl.yaml b/functest_kubernetes/ims/helm/templates/homestead-depl.yaml index 782ff16d..4e7f86a6 100644 --- a/functest_kubernetes/ims/helm/templates/homestead-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/homestead-depl.yaml @@ -15,13 +15,13 @@ spec: spec: initContainers: - name: wait-on-cassandra - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] - name: wait-on-astaire - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup astaire; do echo waiting for astaire to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-homestead:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-homestead:{{ .Values.image.tag }}" name: homestead ports: - containerPort: 22 @@ -44,7 +44,7 @@ spec: volumeMounts: - name: homesteadlogs mountPath: /var/log/homestead - - image: busybox:1.28 + - image: {{ .Values.repo.dockerHub }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/homestead/homestead_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/helm/templates/homestead-prov-depl.yaml b/functest_kubernetes/ims/helm/templates/homestead-prov-depl.yaml index 59ec4e26..49e3e4b3 100644 --- a/functest_kubernetes/ims/helm/templates/homestead-prov-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/homestead-prov-depl.yaml @@ -15,10 +15,10 @@ spec: spec: initContainers: - name: wait-on-homestead - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup homestead; do echo waiting for homestead to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-homestead-prov:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-homestead-prov:{{ .Values.image.tag }}" name: homestead-prov ports: - containerPort: 22 diff --git a/functest_kubernetes/ims/helm/templates/ralf-depl.yaml b/functest_kubernetes/ims/helm/templates/ralf-depl.yaml index b052eea6..e115ee25 100644 --- a/functest_kubernetes/ims/helm/templates/ralf-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/ralf-depl.yaml @@ -15,10 +15,10 @@ spec: spec: initContainers: - name: wait-on-cassandra - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-ralf:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-ralf:{{ .Values.image.tag }}" name: ralf ports: - containerPort: 22 @@ -41,7 +41,7 @@ spec: volumeMounts: - name: ralflogs mountPath: /var/log/ralf - - image: busybox:1.28 + - image: {{ .Values.repo.dockerHub }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/ralf/ralf_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/helm/templates/sprout-depl.yaml b/functest_kubernetes/ims/helm/templates/sprout-depl.yaml index 1ee4701f..dd7ef49e 100644 --- a/functest_kubernetes/ims/helm/templates/sprout-depl.yaml +++ b/functest_kubernetes/ims/helm/templates/sprout-depl.yaml @@ -15,16 +15,16 @@ spec: spec: initContainers: - name: wait-on-ralf - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup ralf; do echo waiting for ralf to start ...; sleep 2; done'] - name: wait-on-chronos - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup chronos; do echo waiting for chronos to start ...; sleep 2; done'] - name: wait-on-homestead - image: busybox:1.28 + image: {{ .Values.repo.dockerHub }}/busybox:1.28 command: ['sh', '-c', 'until nslookup homestead; do echo waiting for homestead to start ...; sleep 2; done'] containers: - - image: "{{ .Values.image.path }}-sprout:{{ .Values.image.tag }}" + - image: "{{ .Values.repo.dockerHub }}/{{ .Values.image.path }}-sprout:{{ .Values.image.tag }}" name: sprout ports: - containerPort: 22 @@ -47,7 +47,7 @@ spec: volumeMounts: - name: sproutlogs mountPath: /var/log/sprout - - image: busybox:1.28 + - image: {{ .Values.repo.dockerHub }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/sprout/sprout_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/helm/values.yaml b/functest_kubernetes/ims/helm/values.yaml index b2cb3272..03866e33 100644 --- a/functest_kubernetes/ims/helm/values.yaml +++ b/functest_kubernetes/ims/helm/values.yaml @@ -4,3 +4,6 @@ image: path: ollivier/clearwater tag: hunter +repo: + dockerHub: docker.io + quay: quay.io diff --git a/functest_kubernetes/ims/homer-depl.yaml b/functest_kubernetes/ims/homer-depl.yaml index 564b2374..665d618e 100644 --- a/functest_kubernetes/ims/homer-depl.yaml +++ b/functest_kubernetes/ims/homer-depl.yaml @@ -14,10 +14,10 @@ spec: spec: initContainers: - name: wait-on-cassandra - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-homer:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-homer:hunter" name: homer ports: - containerPort: 22 diff --git a/functest_kubernetes/ims/homestead-depl.yaml b/functest_kubernetes/ims/homestead-depl.yaml index 82ea0cef..d8b8a65f 100644 --- a/functest_kubernetes/ims/homestead-depl.yaml +++ b/functest_kubernetes/ims/homestead-depl.yaml @@ -15,13 +15,13 @@ spec: spec: initContainers: - name: wait-on-cassandra - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] - name: wait-on-astaire - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup astaire; do echo waiting for astaire to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-homestead:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-homestead:hunter" name: homestead ports: - containerPort: 22 @@ -44,7 +44,7 @@ spec: volumeMounts: - name: homesteadlogs mountPath: /var/log/homestead - - image: busybox:1.28 + - image: {{ dockerhub_repo }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/homestead/homestead_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/homestead-prov-depl.yaml b/functest_kubernetes/ims/homestead-prov-depl.yaml index c194cea9..efcbd048 100644 --- a/functest_kubernetes/ims/homestead-prov-depl.yaml +++ b/functest_kubernetes/ims/homestead-prov-depl.yaml @@ -15,10 +15,10 @@ spec: spec: initContainers: - name: wait-on-homestead - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup homestead; do echo waiting for homestead to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-homestead-prov:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-homestead-prov:hunter" name: homestead-prov ports: - containerPort: 22 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) diff --git a/functest_kubernetes/ims/ralf-depl.yaml b/functest_kubernetes/ims/ralf-depl.yaml index de2b93ec..c1ce59ca 100644 --- a/functest_kubernetes/ims/ralf-depl.yaml +++ b/functest_kubernetes/ims/ralf-depl.yaml @@ -15,10 +15,10 @@ spec: spec: initContainers: - name: wait-on-cassandra - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup cassandra; do echo waiting for cassandra to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-ralf:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-ralf:hunter" name: ralf ports: - containerPort: 22 @@ -41,7 +41,7 @@ spec: volumeMounts: - name: ralflogs mountPath: /var/log/ralf - - image: busybox:1.28 + - image: {{ dockerhub_repo }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/ralf/ralf_current.txt" ] volumeMounts: diff --git a/functest_kubernetes/ims/sprout-depl.yaml b/functest_kubernetes/ims/sprout-depl.yaml index 5e182483..b3840a8e 100644 --- a/functest_kubernetes/ims/sprout-depl.yaml +++ b/functest_kubernetes/ims/sprout-depl.yaml @@ -15,16 +15,16 @@ spec: spec: initContainers: - name: wait-on-ralf - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup ralf; do echo waiting for ralf to start ...; sleep 2; done'] - name: wait-on-chronos - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup chronos; do echo waiting for chronos to start ...; sleep 2; done'] - name: wait-on-homestead - image: busybox:1.28 + image: {{ dockerhub_repo }}/busybox:1.28 command: ['sh', '-c', 'until nslookup homestead; do echo waiting for homestead to start ...; sleep 2; done'] containers: - - image: "ollivier/clearwater-sprout:hunter" + - image: "{{ dockerhub_repo }}/ollivier/clearwater-sprout:hunter" name: sprout ports: - containerPort: 22 @@ -47,7 +47,7 @@ spec: volumeMounts: - name: sproutlogs mountPath: /var/log/sprout - - image: busybox:1.28 + - image: {{ dockerhub_repo }}/busybox:1.28 name: tailer command: [ "tail", "-F", "/var/log/sprout/sprout_current.txt" ] volumeMounts: 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) |