diff --git a/Makefile b/Makefile index b2f162b70..3ec27256c 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,6 @@ test: hack/verify-codegen.sh @go test ./... -e2e: +e2e: docker e2e/run.sh - # TODO run before tests once they are implemented completely flake8 --exit-zero diff --git a/e2e/kind-config-smoke-tests.yaml b/e2e/kind-config-smoke-tests.yaml index d95d68b2e..a59746fd3 100644 --- a/e2e/kind-config-smoke-tests.yaml +++ b/e2e/kind-config-smoke-tests.yaml @@ -4,4 +4,3 @@ nodes: - role: control-plane - role: worker - role: worker -- role: worker diff --git a/e2e/run.sh b/e2e/run.sh index d6673610e..c2ccf4d2a 100755 --- a/e2e/run.sh +++ b/e2e/run.sh @@ -18,5 +18,8 @@ kind create cluster --name ${cluster_name} --config ./e2e/kind-config-smoke-test export KUBECONFIG="$(kind get kubeconfig-path --name=${cluster_name})" kubectl cluster-info +version=$(git describe --tags --always --dirty) +kind load docker-image "registry.opensource.zalan.do/acid/postgres-operator:${version}" --name ${cluster_name} + python3 -m unittest discover --start-directory e2e/tests/ && kind delete cluster --name ${cluster_name} \ No newline at end of file diff --git a/e2e/tests/test_smoke.py b/e2e/tests/test_smoke.py index 23fcc22bc..15044e398 100755 --- a/e2e/tests/test_smoke.py +++ b/e2e/tests/test_smoke.py @@ -4,7 +4,7 @@ from kubernetes import client, config, utils from pprint import pprint import timeout_decorator import subprocess - +import git class K8sApi: @@ -13,6 +13,8 @@ class K8sApi: self.k8s_client = client.ApiClient() self.core_v1 = client.CoreV1Api() self.crd_api = client.CustomObjectsApi() + self.apps_v1 = client.AppsV1Api() + class SmokeTestCase(unittest.TestCase): @@ -41,6 +43,26 @@ class SmokeTestCase(unittest.TestCase): for filename in ["configmap.yaml", "postgres-operator.yaml"]: path = "manifests/" + filename utils.create_from_yaml(k8s_api.k8s_client, path) + + # submit most recent operator image built locally; see VERSION in Makefile + repo = git.Repo(".") + version = repo.git.describe("--tags", "--always", "--dirty") + + body = { + "spec": { + "template": { + "spec": { + "containers": [ + { + "name" : "postgres-operator", + "image": "registry.opensource.zalan.do/acid/postgres-operator:" + version + } + ] + } + } + } + } + k8s_api.apps_v1.patch_namespaced_deployment("postgres-operator", "default", body) pod_phase = None while pod_phase != 'Running': diff --git a/requirements.txt b/requirements.txt index 6fff5e0ff..d47e7d619 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ kubernetes flake8 +git +timeout_decorator