From 0474be923f5afdb4aad9804c8eaa2f61b9393279 Mon Sep 17 00:00:00 2001 From: Sergey Dudoladov Date: Fri, 26 Apr 2019 17:11:48 +0200 Subject: [PATCH] deploy operator before running test --- e2e/tests/test_example.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/e2e/tests/test_example.py b/e2e/tests/test_example.py index 859c87cd9..70b96e27c 100755 --- a/e2e/tests/test_example.py +++ b/e2e/tests/test_example.py @@ -1,12 +1,35 @@ -import unittest -from kubernetes import client, config +import unittest, yaml +from kubernetes import client, config, utils from pprint import pprint +import subprocess class SampleTestCase(unittest.TestCase): nodes = set(["kind-test-postgres-operator-worker", "kind-test-postgres-operator-worker2", "kind-test-postgres-operator-worker3"]) + @classmethod + def setUpClass(cls): + + # deploy operator + + _ = config.load_kube_config() + k8s_client = client.ApiClient() + + # HACK create_from_yaml fails with multiple object defined within a single file + # which is exactly the case with RBAC definition + subprocess.run(["kubectl", "create", "-f", "manifests/operator-service-account-rbac.yaml"]) + + for filename in ["configmap.yaml", "postgres-operator.yaml"]: + path = "manifests/" + filename + utils.create_from_yaml(k8s_client, path) + + #TODO wait until operator pod starts up label ; name=postgres-operator + + @classmethod + def tearDownClass(cls): + pass + def setUp(self): self.config = config.load_kube_config() self.v1 = client.CoreV1Api()