diff --git a/e2e/Dockerfile b/e2e/Dockerfile index 316ccaa56..d35a62618 100644 --- a/e2e/Dockerfile +++ b/e2e/Dockerfile @@ -21,4 +21,5 @@ RUN apt-get update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -ENTRYPOINT ["python3", "-m", "unittest", "discover", "--failfast", "--start-directory", "/tests", "-v"] +ENTRYPOINT ["python3", "-m", "unittest", "--failfast", "-v"] +CMD ["discover","--start-directory","/tests"] \ No newline at end of file diff --git a/e2e/README.md b/e2e/README.md index 3c9a066f5..98adbe53a 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -40,6 +40,25 @@ To run the end 2 end test and keep the kind state execute: NOCLEANUP=True ./run.sh ``` +## Run indidual test + +After having executed a normal E2E run with `NOCLEANUP=True` Kind still continues to run, allowing you subsequent test runs. + +To run an individual test, run the following command in the `e2e` directory + +```bash +NOCLEANUP=True ./run.sh main tests.test_e2e.EndToEndTestCase.test_lazy_spilo_upgrade +``` + +## Inspecting Kind + +If you want to inspect Kind/Kubernetes cluster, use the following script to exec into the K8s setup and then use `kubectl` + +```bash +./run_test_image.sh +kubectl get pods +``` + ## Covered use cases The current tests are all bundled in [`test_e2e.py`](tests/test_e2e.py): diff --git a/e2e/run.sh b/e2e/run.sh index 19c96cc84..abdefcd1d 100755 --- a/e2e/run.sh +++ b/e2e/run.sh @@ -48,8 +48,8 @@ function set_kind_api_server_ip(){ } function run_tests(){ - echo "Running tests..." - + echo "Running tests... image: ${e2e_test_runner_image}" + echo $@ # tests modify files in ./manifests, so we mount a copy of this directory done by the e2e Makefile docker run --rm --network=host -e "TERM=xterm-256color" \ @@ -57,7 +57,7 @@ function run_tests(){ --mount type=bind,source="$(readlink -f manifests)",target=/manifests \ --mount type=bind,source="$(readlink -f tests)",target=/tests \ --mount type=bind,source="$(readlink -f exec.sh)",target=/exec.sh \ - -e OPERATOR_IMAGE="${operator_image}" "${e2e_test_runner_image}" + -e OPERATOR_IMAGE="${operator_image}" "${e2e_test_runner_image}" $@ } function clean_up(){ @@ -68,13 +68,14 @@ function clean_up(){ } function main(){ - + echo "Entering main function..." [[ -z ${NOCLEANUP-} ]] && trap "clean_up" QUIT TERM EXIT pull_images [[ ! -f ${kubeconfig_path} ]] && start_kind set_kind_api_server_ip - run_tests + shift + run_tests $@ exit 0 } -"$@" +"$1" $@ diff --git a/e2e/tests/test_e2e.py b/e2e/tests/test_e2e.py index e24ebeb39..1c5aad81f 100644 --- a/e2e/tests/test_e2e.py +++ b/e2e/tests/test_e2e.py @@ -1069,7 +1069,10 @@ class K8s: stderr=subprocess.PIPE) def get_patroni_state(self, pod): - return json.loads(self.exec_with_kubectl(pod, "patronictl list -f json").stdout) + r = self.exec_with_kubectl(pod, "patronictl list -f json") + if not r.returncode == 0 or not r.stdout.decode()[0:1]=="[": + return [] + return json.loads(r.stdout.decode()) def get_patroni_running_members(self, pod): result = self.get_patroni_state(pod)