deploy operator before running test

This commit is contained in:
Sergey Dudoladov 2019-04-26 17:11:48 +02:00
parent 646de3d77e
commit 0474be923f
1 changed files with 25 additions and 2 deletions

View File

@ -1,12 +1,35 @@
import unittest import unittest, yaml
from kubernetes import client, config from kubernetes import client, config, utils
from pprint import pprint from pprint import pprint
import subprocess
class SampleTestCase(unittest.TestCase): class SampleTestCase(unittest.TestCase):
nodes = set(["kind-test-postgres-operator-worker", "kind-test-postgres-operator-worker2", "kind-test-postgres-operator-worker3"]) 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): def setUp(self):
self.config = config.load_kube_config() self.config = config.load_kube_config()
self.v1 = client.CoreV1Api() self.v1 = client.CoreV1Api()