From 0ec37397320c761bcd0eb5feccd96c7f3cf82b86 Mon Sep 17 00:00:00 2001 From: Sergey Dudoladov Date: Thu, 23 May 2019 12:19:21 +0200 Subject: [PATCH] avoid dropping DELETE event for cron job --- docs/developer.md | 2 ++ e2e/tests/test_smoke.py | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/developer.md b/docs/developer.md index cbbf63dc1..a7c7a2f33 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -323,6 +323,8 @@ The tests utilize examples from `/manifests` (ConfigMap is used for the operator End-to-end tests are executed automatically during builds; to invoke them locally use `make e2e-run` from the project's top directory. Run `make e2e-tools e2e-build` to install `kind` and build the tests' image locally before the first run. +End-to-end tests are written in Python and use `flake8` for code quality. Please run flake8 [before submitting a PR](http://flake8.pycqa.org/en/latest/user/using-hooks.html). + ## Introduce additional configuration parameters In the case you want to add functionality to the operator that shall be diff --git a/e2e/tests/test_smoke.py b/e2e/tests/test_smoke.py index 8d26bbaa8..60844ad2b 100755 --- a/e2e/tests/test_smoke.py +++ b/e2e/tests/test_smoke.py @@ -65,7 +65,7 @@ class SmokeTestCase(unittest.TestCase): Utils.wait_for_pod_start(k8s_api, 'spilo-role=master', cls.RETRY_TIMEOUT_SEC) @timeout_decorator.timeout(TEST_TIMEOUT_SEC) - def master_is_unique(self): + def test_master_is_unique(self): """ Check that there is a single pod in the k8s cluster with the label "spilo-role=master". """ @@ -76,7 +76,7 @@ class SmokeTestCase(unittest.TestCase): self.assertEqual(num_of_master_pods, 1, "Expected 1 master pod, found {}".format(num_of_master_pods)) @timeout_decorator.timeout(TEST_TIMEOUT_SEC) - def scaling(self): + def test_scaling(self): """ Scale up from 2 to 3 pods and back to 2 by updating the Postgres manifest at runtime. """ @@ -91,7 +91,7 @@ class SmokeTestCase(unittest.TestCase): self.assertEqual(2, Utils.count_pods_with_label(k8s, labels)) @timeout_decorator.timeout(TEST_TIMEOUT_SEC) - def taint_based_eviction(self): + def test_taint_based_eviction(self): """ Add taint "postgres=:NoExecute" to node with master. """ @@ -175,8 +175,8 @@ class SmokeTestCase(unittest.TestCase): operator_pod = k8s.core_v1.list_namespaced_pod('default', label_selector="name=postgres-operator").items[0].metadata.name k8s.core_v1.delete_namespaced_pod(operator_pod, "default") # restart reloads the conf Utils.wait_for_pod_start(k8s, 'name=postgres-operator', self.RETRY_TIMEOUT_SEC) - #TODO replace this timeout with a meaningful condition to avodi dropping a delete event - time.sleep(30) + #HACK avoid dropping a delete event when the operator pod has the label but is still starting + time.sleep(10) # delete the logical backup cron job pg_patch_disable_backup = {