diff --git a/tests/AutoconfTest.py b/tests/AutoconfTest.py index deaa66540..04b4d9f1b 100644 --- a/tests/AutoconfTest.py +++ b/tests/AutoconfTest.py @@ -1,170 +1,128 @@ from Test import Test -from os.path import isdir, isfile -from os import getenv +from os.path import isdir, join, isfile +from os import chown, walk, getenv, listdir from shutil import copytree, rmtree from traceback import format_exc from subprocess import run from time import sleep -from logger import setup_logger +from logger import log +class AutoconfTest(Test) : -class AutoconfTest(Test): - def __init__(self, name, timeout, tests, no_copy_container=False, delay=0): - super().__init__( - name, - "autoconf", - timeout, - tests, - no_copy_container=no_copy_container, - delay=delay, - ) + def __init__(self, name, timeout, tests, no_copy_container=False, delay=0) : + super().__init__(name, "autoconf", timeout, tests, no_copy_container=no_copy_container, delay=delay) self._domains = { r"www\.example\.com": getenv("TEST_DOMAIN1"), r"auth\.example\.com": getenv("TEST_DOMAIN1"), r"app1\.example\.com": getenv("TEST_DOMAIN1_1"), r"app2\.example\.com": getenv("TEST_DOMAIN1_2"), - r"app3\.example\.com": getenv("TEST_DOMAIN1_3"), + r"app3\.example\.com": getenv("TEST_DOMAIN1_3") } - self.__logger = setup_logger("Autoconf_test", getenv("LOG_LEVEL", "INFO")) + self._check_domains() - @staticmethod - def init(): - try: - if not Test.init(): + def init() : + try : + if not Test.init() : return False proc = run("sudo chown -R root:root /tmp/bw-data", shell=True) - if proc.returncode != 0: - raise (Exception("chown failed (autoconf stack)")) - if isdir("/tmp/autoconf"): + if proc.returncode != 0 : + raise(Exception("chown failed (autoconf stack)")) + if isdir("/tmp/autoconf") : rmtree("/tmp/autoconf") - copytree("./integrations/autoconf", "/tmp/autoconf") - compose = "/tmp/autoconf/docker-compose.yml" - Test.replace_in_file( - compose, r"bunkerity/bunkerweb:.*$", "10.20.1.1:5000/bw-tests:latest" - ) - Test.replace_in_file( - compose, - r"bunkerity/bunkerweb-autoconf:.*$", - "10.20.1.1:5000/bw-autoconf-tests:latest", - ) + copytree("./misc/integrations", "/tmp/integrations") + compose = "/tmp/integrations/autoconf.yml" + Test.replace_in_file(compose, r"bunkerity/bunkerweb:.*$", "local/bunkerweb-tests:latest") + Test.replace_in_file(compose, r"bunkerity/bunkerweb-autoconf:.*$", "local/autoconf-tests:latest") + Test.replace_in_file(compose, r"bunkerity/bunkerweb-scheduler:.*$", "local/scheduler-tests:latest") Test.replace_in_file(compose, r"\./bw\-data:/", "/tmp/bw-data:/") - proc = run( - "docker-compose pull --ignore-pull-failures", - cwd="/tmp/autoconf", - shell=True, - ) - if proc.returncode != 0: - raise (Exception("docker-compose pull failed (autoconf stack)")) + proc = run("docker-compose pull --ignore-pull-failures", cwd="/tmp/autoconf", shell=True) + if proc.returncode != 0 : + raise(Exception("docker-compose pull failed (autoconf stack)")) proc = run("docker-compose up -d", cwd="/tmp/autoconf", shell=True) - if proc.returncode != 0: - raise (Exception("docker-compose up failed (autoconf stack)")) + if proc.returncode != 0 : + raise(Exception("docker-compose up failed (autoconf stack)")) i = 0 healthy = False - while i < 30: - proc = run( - 'docker inspect --format "{{json .State.Health }}" autoconf_mybunker_1', - cwd="/tmp/autoconf", - shell=True, - capture_output=True, - ) - if proc.returncode != 0: - raise (Exception("docker-compose inspect failed (autoconf stack)")) - if "healthy" in proc.stdout.decode(): + while i < 30 : + proc = run('docker inspect --format "{{json .State.Health }}" autoconf-mybunker-1', cwd="/tmp/autoconf", shell=True, capture_output=True) + if proc.returncode != 0 : + raise(Exception("docker inspect failed (autoconf stack)")) + if "healthy" in proc.stdout.decode() : healthy = True break sleep(1) i += 1 - if not healthy: - raise (Exception("autoconf stack is not healthy")) - except: - setup_logger("Autoconf_test", getenv("LOG_LEVEL", "INFO")).error( - f"exception while running AutoconfTest.init()\n{format_exc()}", - ) + if not healthy : + raise(Exception("autoconf stack is not healthy")) + except : + log("AUTOCONF", "❌", "exception while running AutoconfTest.init()\n" + format_exc()) return False return True - @staticmethod - def end(): + def end() : ret = True - try: - if not Test.end(): + try : + if not Test.end() : return False proc = run("docker-compose down -v", cwd="/tmp/autoconf", shell=True) - if proc.returncode != 0: + if proc.returncode != 0 : ret = False rmtree("/tmp/autoconf") - except: - setup_logger("Autoconf_test", getenv("LOG_LEVEL", "INFO")).error( - f"exception while running AutoconfTest.end()\n{format_exc()}", - ) + except : + log("AUTOCONF", "❌", "exception while running AutoconfTest.end()\n" + format_exc()) return False return ret - def _setup_test(self): - try: + def _setup_test(self) : + try : super()._setup_test() - test = f"/tmp/tests/{self._name}" - compose = f"/tmp/tests/{self._name}/autoconf.yml" - example_data = f"/tmp/tests/{self._name}/bw-data" - Test.replace_in_file( - compose, r"bunkerity/bunkerweb:.*$", "10.20.1.1:5000/bw-tests:latest" - ) + test = "/tmp/tests/" + self._name + compose = "/tmp/tests/" + self._name + "/autoconf.yml" + example_data = "/tmp/tests/" + self._name + "/bw-data" + Test.replace_in_file(compose, r"bunkerity/bunkerweb:.*$", "local/bunkerweb-tests:latest") + Test.replace_in_file(compose, r"bunkerity/bunkerweb-scheduler:.*$", "local/scheduler-tests:latest") + Test.replace_in_file(compose, r"bunkerity/bunkerweb-autoconf:.*$", "local/autoconf-tests:latest") Test.replace_in_file(compose, r"\./bw\-data:/", "/tmp/bw-data:/") Test.replace_in_file(compose, r"\- bw_data:/", "- /tmp/bw-data:/") - for ex_domain, test_domain in self._domains.items(): + for ex_domain, test_domain in self._domains.items() : Test.replace_in_files(test, ex_domain, test_domain) Test.rename(test, ex_domain, test_domain) Test.replace_in_files(test, "example.com", getenv("ROOT_DOMAIN")) - setup = f"{test}/setup-autoconf.sh" - if isfile(setup): + setup = test + "/setup-autoconf.sh" + if isfile(setup) : proc = run("sudo ./setup-autoconf.sh", cwd=test, shell=True) - if proc.returncode != 0: - raise (Exception("setup-autoconf failed")) - if isdir(example_data) and not self._no_copy_container: - proc = run( - f"sudo bash -c 'cp -rp {example_data}/* /tmp/bw-data'", - shell=True, - ) - if proc.returncode != 0: - raise (Exception("cp bw-data failed")) - proc = run( - "docker-compose -f autoconf.yml pull --ignore-pull-failures", - shell=True, - cwd=test, - ) - if proc.returncode != 0: - raise (Exception("docker-compose pull failed")) + if proc.returncode != 0 : + raise(Exception("setup-autoconf failed")) + if isdir(example_data) and not self._no_copy_container : + proc = run("sudo bash -c 'cp -rp " + example_data + "/* /tmp/bw-data'", shell=True) + if proc.returncode != 0 : + raise(Exception("cp bw-data failed")) + proc = run("docker-compose -f autoconf.yml pull --ignore-pull-failures", shell=True, cwd=test) + if proc.returncode != 0 : + raise(Exception("docker-compose pull failed")) proc = run("docker-compose -f autoconf.yml up -d", shell=True, cwd=test) - if proc.returncode != 0: - raise (Exception("docker-compose up failed")) - except: - self.__logger.error( - f"exception while running AutoconfTest._setup_test()\n{format_exc()}", - ) + if proc.returncode != 0 : + raise(Exception("docker-compose up failed")) + except : + log("AUTOCONF", "❌", "exception while running AutoconfTest._setup_test()\n" + format_exc()) self._cleanup_test() return False return True - def _cleanup_test(self): - try: - test = f"/tmp/tests/{self._name}" + def _cleanup_test(self) : + try : + test = "/tmp/tests/" + self._name proc = run("docker-compose -f autoconf.yml down -v", shell=True, cwd=test) - if proc.returncode != 0: - raise (Exception("docker-compose down failed")) + if proc.returncode != 0 : + raise(Exception("docker-compose down failed")) super()._cleanup_test() - except: - self.__logger.error( - f"exception while running AutoconfTest._cleanup_test()\n{format_exc()}", - ) + except : + log("AUTOCONF", "❌", "exception while running AutoconfTest._cleanup_test()\n" + format_exc()) return False return True - def _debug_fail(self): + def _debug_fail(self) : autoconf = "/tmp/autoconf" proc = run("docker-compose logs", shell=True, cwd=autoconf) - if proc.returncode != 0: - raise (Exception("docker-compose logs failed")) - test = f"/tmp/tests/{self._name}" + test = "/tmp/tests/" + self._name proc = run("docker-compose -f autoconf.yml logs", shell=True, cwd=test) - if proc.returncode != 0: - raise (Exception("docker-compose -f autoconf.yml logs failed")) diff --git a/tests/DockerTest.py b/tests/DockerTest.py index 1848d3c3a..ac93be52f 100644 --- a/tests/DockerTest.py +++ b/tests/DockerTest.py @@ -1,107 +1,86 @@ from Test import Test -from os.path import isdir, isfile -from os import environ, getenv +from os.path import isdir, join, isfile +from os import chown, walk, getenv, listdir +from shutil import copytree from traceback import format_exc from subprocess import run -from logger import setup_logger +from logger import log +class DockerTest(Test) : -class DockerTest(Test): - def __init__(self, name, timeout, tests, no_copy_container=False, delay=0): - super().__init__( - name, - "docker", - timeout, - tests, - no_copy_container=no_copy_container, - delay=delay, - ) + def __init__(self, name, timeout, tests, no_copy_container=False, delay=0) : + super().__init__(name, "docker", timeout, tests, no_copy_container=no_copy_container, delay=delay) self._domains = { r"www\.example\.com": getenv("TEST_DOMAIN1"), r"auth\.example\.com": getenv("TEST_DOMAIN1"), r"app1\.example\.com": getenv("TEST_DOMAIN1_1"), r"app2\.example\.com": getenv("TEST_DOMAIN1_2"), - r"app3\.example\.com": getenv("TEST_DOMAIN1_3"), + r"app3\.example\.com": getenv("TEST_DOMAIN1_3") } - self.__logger = setup_logger("Docker_test", environ.get("LOGLEVEL", "INFO")) + self._check_domains() - @staticmethod - def init(): - try: - if not Test.init(): + def init() : + try : + if not Test.init() : return False proc = run("sudo chown -R 101:101 /tmp/bw-data", shell=True) - if proc.returncode != 0: - raise (Exception("chown failed (autoconf stack)")) - except: - setup_logger("Docker_test", environ.get("LOG_LEVEL", "INFO")).error( - f"exception while running DockerTest.init()\n{format_exc()}", - ) + if proc.returncode != 0 : + raise(Exception("chown failed (autoconf stack)")) + except : + log("DOCKER", "❌", "exception while running DockerTest.init()\n" + format_exc()) return False return True - def _setup_test(self): - try: + def _setup_test(self) : + try : super()._setup_test() - test = f"/tmp/tests/{self._name}" - compose = f"/tmp/tests/{self._name}/docker-compose.yml" - example_data = f"/tmp/tests/{self._name}/bw-data" - Test.replace_in_file( - compose, r"bunkerity/bunkerweb:.*$", "10.20.1.1:5000/bw-tests:latest" - ) + test = "/tmp/tests/" + self._name + compose = "/tmp/tests/" + self._name + "/docker-compose.yml" + example_data = "/tmp/tests/" + self._name + "/bw-data" + Test.replace_in_file(compose, r"bunkerity/bunkerweb:.*$", "local/bunkerweb-tests:latest") + Test.replace_in_file(compose, r"bunkerity/bunkerweb-scheduler:.*$", "local/scheduler-tests:latest") Test.replace_in_file(compose, r"\./bw\-data:/", "/tmp/bw-data:/") Test.replace_in_file(compose, r"\- bw_data:/", "- /tmp/bw-data:/") - Test.replace_in_file( - compose, - r"AUTO_LETS_ENCRYPT=yes", - "AUTO_LETS_ENCRYPT=yes\n - USE_LETS_ENCRYPT_STAGING=yes", - ) - for ex_domain, test_domain in self._domains.items(): + Test.replace_in_file(compose, r"AUTO_LETS_ENCRYPT=yes", "AUTO_LETS_ENCRYPT=yes\n - USE_LETS_ENCRYPT_STAGING=yes") + Test.replace_in_file(compose, r"DISABLE_DEFAULT_SERVER=yes", "DISABLE_DEFAULT_SERVER=no") + for ex_domain, test_domain in self._domains.items() : Test.replace_in_files(test, ex_domain, test_domain) Test.rename(test, ex_domain, test_domain) Test.replace_in_files(test, "example.com", getenv("ROOT_DOMAIN")) - setup = f"{test}/setup-docker.sh" - if isfile(setup): + setup = test + "/setup-docker.sh" + if isfile(setup) : proc = run("sudo ./setup-docker.sh", cwd=test, shell=True) - if proc.returncode != 0: - raise (Exception("setup-docker failed")) - if isdir(example_data) and not self._no_copy_container: - proc = run( - f"sudo bash -c 'cp -rp {example_data}/* /tmp/bw-data'", - shell=True, - ) - if proc.returncode != 0: - raise (Exception("cp bw-data failed")) - proc = run( - "docker-compose pull --ignore-pull-failures", shell=True, cwd=test - ) - if proc.returncode != 0: - raise (Exception("docker-compose pull failed")) + if proc.returncode != 0 : + raise(Exception("setup-docker failed")) + if isdir(example_data) and not self._no_copy_container : + proc = run("sudo bash -c 'cp -rp " + example_data + "/* /tmp/bw-data'", shell=True) + if proc.returncode != 0 : + raise(Exception("cp bw-data failed")) + proc = run("docker-compose pull --ignore-pull-failures", shell=True, cwd=test) + if proc.returncode != 0 : + raise(Exception("docker-compose pull failed")) proc = run("docker-compose up -d", shell=True, cwd=test) - if proc.returncode != 0: - raise (Exception("docker-compose up failed")) - except: - self.__logger.error( - f"exception while running DockerTest._setup_test()\n{format_exc()}", - ) + if proc.returncode != 0 : + raise(Exception("docker-compose up failed")) + except : + log("DOCKER", "❌", "exception while running DockerTest._setup_test()\n" + format_exc()) self._cleanup_test() return False return True - def _cleanup_test(self): - try: + def _cleanup_test(self) : + try : test = "/tmp/tests/" + self._name proc = run("docker-compose down -v", shell=True, cwd=test) - if proc.returncode != 0: - raise (Exception("docker-compose down failed")) + if proc.returncode != 0 : + raise(Exception("docker-compose down failed")) super()._cleanup_test() - except: - self.__logger.error( - f"exception while running DockerTest._cleanup_test()\n{format_exc()}", - ) + except : + log("DOCKER", "❌", "exception while running DockerTest._cleanup_test()\n" + format_exc()) return False return True - def _debug_fail(self): - test = f"/tmp/tests/{self._name}" - run("docker-compose logs", shell=True, cwd=test) + def _debug_fail(self) : + test = "/tmp/tests/" + self._name + proc = run("docker-compose logs", shell=True, cwd=test) + diff --git a/tests/KubernetesTest.py b/tests/KubernetesTest.py index e4d881dbf..2914e2588 100644 --- a/tests/KubernetesTest.py +++ b/tests/KubernetesTest.py @@ -1,140 +1,133 @@ from Test import Test -from os.path import isdir, isfile -from os import getenv, mkdir +from os.path import isdir, join, isfile +from os import chown, walk, getenv, listdir, mkdir from shutil import copytree, rmtree, copy from traceback import format_exc from subprocess import run from time import sleep -from logger import setup_logger +from logger import log +class KubernetesTest(Test) : -class KubernetesTest(Test): - def __init__(self, name, timeout, tests, delay=0): + def __init__(self, name, timeout, tests, delay=0) : super().__init__(name, "kubernetes", timeout, tests, delay=delay) self._domains = { r"www\.example\.com": getenv("TEST_DOMAIN1_1"), r"auth\.example\.com": getenv("TEST_DOMAIN1_2"), r"app1\.example\.com": getenv("TEST_DOMAIN1"), r"app2\.example\.com": getenv("TEST_DOMAIN2"), - r"app3\.example\.com": getenv("TEST_DOMAIN3"), + r"app3\.example\.com": getenv("TEST_DOMAIN3") } - self.__logger = setup_logger("Kubernetes_test", getenv("LOGLEVEL", "INFO")) - @staticmethod - def init(): - try: - if not Test.init(): + def init() : + try : + if not Test.init() : return False + # proc = run("sudo chown -R root:root /tmp/bw-data", shell=True) + # if proc.returncode != 0 : + # raise(Exception("chown failed (k8s stack)")) + # if isdir("/tmp/kubernetes") : + # rmtree("/tmp/kubernetes") + # copytree("./integrations/kubernetes", "/tmp/kubernetes") + # copy("./tests/utils/k8s.yml", "/tmp/kubernetes") + # deploy = "/tmp/kubernetes/bunkerweb.yml" + # Test.replace_in_file(deploy, r"bunkerity/bunkerweb:.*$", getenv("PRIVATE_REGISTRY") + "/infra/bunkerweb-tests-amd64:latest") + # Test.replace_in_file(deploy, r"bunkerity/bunkerweb-autoconf:.*$", getenv("PRIVATE_REGISTRY") + "/infra/bunkerweb-autoconf-tests-amd64:latest") + # proc = run("kubectl apply -f k8s.yml", cwd="/tmp/kubernetes", shell=True) + # if proc.returncode != 0 : + # raise(Exception("kubectl apply k8s failed (k8s stack)")) + # proc = run("kubectl apply -f rbac.yml", cwd="/tmp/kubernetes", shell=True) + # if proc.returncode != 0 : + # raise(Exception("kubectl apply rbac failed (k8s stack)")) + # proc = run("kubectl apply -f bunkerweb.yml", cwd="/tmp/kubernetes", shell=True) + # if proc.returncode != 0 : + # raise(Exception("kubectl apply bunkerweb failed (k8s stack)")) mkdir("/tmp/kubernetes") - copy("./tests/utils/bunkerweb.yml", "/tmp/kubernetes") + copy("./misc/integrations/k8s.mariadb.yml", "/tmp/kubernetes/bunkerweb.yml") deploy = "/tmp/kubernetes/bunkerweb.yml" - Test.replace_in_file( - deploy, - r"bunkerity/bunkerweb:.*$", - f"{getenv('PRIVATE_REGISTRY')}/infra/bunkerweb-tests-amd64:{getenv('IMAGE_TAG')}", - ) - Test.replace_in_file( - deploy, - r"bunkerity/bunkerweb-autoconf:.*$", - f"{getenv('PRIVATE_REGISTRY')}/infra/bunkerweb-autoconf-tests-amd64:{getenv('IMAGE_TAG')}", - ) - proc = run( - "kubectl apply -f bunkerweb.yml", cwd="/tmp/kubernetes", shell=True - ) - if proc.returncode != 0: - raise (Exception("kubectl apply bunkerweb failed (k8s stack)")) + Test.replace_in_file(deploy, r"bunkerity/bunkerweb:.*$", getenv("PRIVATE_REGISTRY") + "/infra/bunkerweb-tests:" + getenv("IMAGE_TAG")) + Test.replace_in_file(deploy, r"bunkerity/bunkerweb-autoconf:.*$", getenv("PRIVATE_REGISTRY") + "/infra/autoconf-tests:" + getenv("IMAGE_TAG")) + Test.replace_in_file(deploy, r"bunkerity/bunkerweb-scheduler:.*$", getenv("PRIVATE_REGISTRY") + "/infra/scheduler-tests:" + getenv("IMAGE_TAG")) + proc = run("kubectl apply -f bunkerweb.yml", cwd="/tmp/kubernetes", shell=True) + if proc.returncode != 0 : + raise(Exception("kubectl apply bunkerweb failed (k8s stack)")) healthy = False i = 0 - while i < 30: - proc = run( - "kubectl get pods | grep bunkerweb | grep -v Running", - shell=True, - capture_output=True, - ) - if "" == proc.stdout.decode(): + while i < 30 : + proc = run('kubectl get pods | grep bunkerweb | grep -v Running', shell=True, capture_output=True) + if "" == proc.stdout.decode() : healthy = True break sleep(1) i += 1 - if not healthy: - raise (Exception("k8s stack is not healthy")) + if not healthy : + raise(Exception("k8s stack is not healthy")) sleep(60) - except: - setup_logger("Kubernetes_test", getenv("LOG_LEVEL", "INFO")).error( - f"exception while running KubernetesTest.init()\n{format_exc()}", - ) + except : + log("KUBERNETES", "❌", "exception while running KubernetesTest.init()\n" + format_exc()) return False return True - @staticmethod - def end(): + def end() : ret = True - try: - if not Test.end(): + try : + if not Test.end() : return False - proc = run( - "kubectl delete -f bunkerweb.yml", - cwd="/tmp/kubernetes", - shell=True, - ) - if proc.returncode != 0: + proc = run("kubectl delete -f bunkerweb.yml", cwd="/tmp/kubernetes", shell=True) + if proc.returncode != 0 : ret = False rmtree("/tmp/kubernetes") - except: - setup_logger("Kubernetes_test", getenv("LOG_LEVEL", "INFO")).error( - f"exception while running KubernetesTest.end()\n{format_exc()}", - ) + except : + log("KUBERNETES", "❌", "exception while running KubernetesTest.end()\n" + format_exc()) return False return ret - def _setup_test(self): - try: + def _setup_test(self) : + try : super()._setup_test() - test = f"/tmp/tests/{self._name}" - for ex_domain, test_domain in self._domains.items(): + test = "/tmp/tests/" + self._name + deploy = "/tmp/tests/" + self._name + "/kubernetes.yml" + example_data = "./examples/" + self._name + "/bw-data" + for ex_domain, test_domain in self._domains.items() : Test.replace_in_files(test, ex_domain, test_domain) Test.rename(test, ex_domain, test_domain) Test.replace_in_files(test, "example.com", getenv("ROOT_DOMAIN")) - setup = f"{test}/setup-kubernetes.sh" - if isfile(setup): - proc = run("kubectl./setup-kubernetes.sh", cwd=test, shell=True) - if proc.returncode != 0: - raise (Exception("setup-kubernetes failed")) + setup = test + "/setup-kubernetes.sh" + if isfile(setup) : + proc = run("./setup-kubernetes.sh", cwd=test, shell=True) + if proc.returncode != 0 : + raise(Exception("setup-kubernetes failed")) + # if isdir(example_data) : + # for cp_dir in listdir(example_data) : + # if isdir(join(example_data, cp_dir)) : + # copytree(join(example_data, cp_dir), join("/tmp/bw-data", cp_dir)) proc = run("kubectl apply -f kubernetes.yml", shell=True, cwd=test) - if proc.returncode != 0: - raise (Exception("kubectl apply failed")) - except: - self.__logger.error( - f"exception while running KubernetesTest._setup_test()\n{format_exc()}", - ) + if proc.returncode != 0 : + raise(Exception("kubectl apply failed")) + except : + log("KUBERNETES", "❌", "exception while running KubernetesTest._setup_test()\n" + format_exc()) self._cleanup_test() return False return True - def _cleanup_test(self): - try: - test = f"/tmp/tests/{self._name}" - cleanup = f"{test}/cleanup-kubernetes.sh" - if isfile(cleanup): - proc = run("kubectl./cleanup-kubernetes.sh", cwd=test, shell=True) - if proc.returncode != 0: - raise (Exception("cleanup-kubernetes failed")) + def _cleanup_test(self) : + try : + test = "/tmp/tests/" + self._name + cleanup = test + "/cleanup-kubernetes.sh" + if isfile(cleanup) : + proc = run("./cleanup-kubernetes.sh", cwd=test, shell=True) + if proc.returncode != 0 : + raise(Exception("cleanup-kubernetes failed")) proc = run("kubectl delete -f kubernetes.yml", shell=True, cwd=test) - if proc.returncode != 0: - raise (Exception("kubectl delete failed")) + if proc.returncode != 0 : + raise(Exception("kubectl delete failed")) super()._cleanup_test() - except: - self.__logger.error( - f"exception while running KubernetesTest._cleanup_test()\n{format_exc()}", - ) + except : + log("KUBERNETES", "❌", "exception while running KubernetesTest._cleanup_test()\n" + format_exc()) return False return True - def _debug_fail(self): - proc = run( - 'kubectl get pods --no-headers -o custom-columns=":metadata.name"', - shell=True, - capture_output=True, - ) - for pod in proc.stdout.decode().splitlines(): - run(f"kubectl logs {pod}", shell=True) + def _debug_fail(self) : + proc = run('kubectl get pods --no-headers -o custom-columns=":metadata.name"', shell=True, capture_output=True) + for pod in proc.stdout.decode().splitlines() : + run("kubectl logs " + pod, shell=True) diff --git a/tests/SwarmTest.py b/tests/SwarmTest.py index deae302d9..e632ef249 100644 --- a/tests/SwarmTest.py +++ b/tests/SwarmTest.py @@ -30,17 +30,22 @@ class SwarmTest(Test): raise (Exception("chown failed (swarm stack)")) if isdir("/tmp/swarm"): rmtree("/tmp/swarm") - copytree("./integrations/swarm", "/tmp/swarm") - compose = "/tmp/swarm/stack.yml" + copytree("./misc/integrations", "/tmp/integrations") + compose = "/tmp/integrations/swarm.mariadb.yml" Test.replace_in_file( compose, r"bunkerity/bunkerweb:.*$", - "192.168.42.100:5000/bw-tests:latest", + "192.168.42.100:5000/bunkerweb-tests:latest", ) Test.replace_in_file( compose, r"bunkerity/bunkerweb-autoconf:.*$", - "192.168.42.100:5000/bw-autoconf-tests:latest", + "192.168.42.100:5000/autoconf-tests:latest", + ) + Test.replace_in_file( + compose, + r"bunkerity/bunkerweb-scheduler:.*$", + "192.168.42.100:5000/scheduler-tests:latest", ) Test.replace_in_file(compose, r"bw\-data:/", "/tmp/bw-data:/") proc = run(