mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
tests - use same domains for each tests
This commit is contained in:
parent
1ef7653bdc
commit
7768940fe6
6 changed files with 43 additions and 44 deletions
|
|
@ -10,7 +10,7 @@ from yaml import safe_load, dump
|
|||
|
||||
|
||||
class AutoconfTest(Test):
|
||||
def __init__(self, name, timeout, tests, no_copy_container=False, delay=0):
|
||||
def __init__(self, name, timeout, tests, no_copy_container=False, delay=0, domains={}):
|
||||
super().__init__(
|
||||
name,
|
||||
"autoconf",
|
||||
|
|
@ -19,13 +19,7 @@ class AutoconfTest(Test):
|
|||
no_copy_container=no_copy_container,
|
||||
delay=delay,
|
||||
)
|
||||
self._domains = {
|
||||
r"www\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1')}",
|
||||
r"auth\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1')}",
|
||||
r"app1\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1_1')}",
|
||||
r"app2\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1_2')}",
|
||||
r"app3\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1_3')}",
|
||||
}
|
||||
self._domains = domains
|
||||
self._check_domains()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from logger import log
|
|||
|
||||
|
||||
class DockerTest(Test):
|
||||
def __init__(self, name, timeout, tests, no_copy_container=False, delay=0):
|
||||
def __init__(self, name, timeout, tests, no_copy_container=False, delay=0, domains={}):
|
||||
super().__init__(
|
||||
name,
|
||||
"docker",
|
||||
|
|
@ -16,13 +16,7 @@ class DockerTest(Test):
|
|||
no_copy_container=no_copy_container,
|
||||
delay=delay,
|
||||
)
|
||||
self._domains = {
|
||||
r"www\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1"),
|
||||
r"auth\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1"),
|
||||
r"app1\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1_1"),
|
||||
r"app2\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1_2"),
|
||||
r"app3\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1_3"),
|
||||
}
|
||||
self._domains = domains
|
||||
self._check_domains()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -10,15 +10,9 @@ from yaml import safe_load_all, dump_all
|
|||
|
||||
|
||||
class KubernetesTest(Test):
|
||||
def __init__(self, name, timeout, tests, delay=0):
|
||||
def __init__(self, name, timeout, tests, delay=0, domains={}):
|
||||
super().__init__(name, "kubernetes", timeout, tests, delay=delay)
|
||||
self._domains = {
|
||||
r"www\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1_2')}",
|
||||
r"auth\.example\.com": f"{Test.random_string(1)}.{getenv('TEST_DOMAIN1_2')}",
|
||||
r"app1\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1')}",
|
||||
r"app2\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN2')}",
|
||||
r"app3\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN3')}",
|
||||
}
|
||||
self._domains = domains
|
||||
|
||||
@staticmethod
|
||||
def init():
|
||||
|
|
|
|||
|
|
@ -8,15 +8,9 @@ from logger import log
|
|||
|
||||
|
||||
class LinuxTest(Test):
|
||||
def __init__(self, name, timeout, tests, distro):
|
||||
def __init__(self, name, timeout, tests, distro, domains={}):
|
||||
super().__init__(name, "linux", timeout, tests, delay=20)
|
||||
self._domains = {
|
||||
r"www\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1')}",
|
||||
r"auth\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1')}",
|
||||
r"app1\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1_1')}",
|
||||
r"app2\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1_2')}",
|
||||
r"app3\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1_3')}",
|
||||
}
|
||||
self._domains = domains
|
||||
if distro not in ("ubuntu", "debian", "fedora", "centos", "rhel"):
|
||||
raise Exception(f"unknown distro {distro}")
|
||||
self.__distro = distro
|
||||
|
|
|
|||
|
|
@ -10,15 +10,9 @@ from yaml import safe_load, dump
|
|||
|
||||
|
||||
class SwarmTest(Test):
|
||||
def __init__(self, name, timeout, tests, delay=0):
|
||||
def __init__(self, name, timeout, tests, delay=0, domains={}):
|
||||
super().__init__(name, "swarm", timeout, tests, delay=delay)
|
||||
self._domains = {
|
||||
r"www\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1_1')}",
|
||||
r"auth\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1_2')}",
|
||||
r"app1\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN1')}",
|
||||
r"app2\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN2')}",
|
||||
r"app3\.example\.com": f"{Test.random_string(6)}.{getenv('TEST_DOMAIN3')}",
|
||||
}
|
||||
self._domains = domains
|
||||
|
||||
@staticmethod
|
||||
def init():
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
from pathlib import Path
|
||||
from sys import path, argv, exit
|
||||
from glob import glob
|
||||
from os import _exit
|
||||
from os import _exit, getenv
|
||||
from os.path import isfile
|
||||
from traceback import format_exc
|
||||
from json import loads, dumps
|
||||
|
|
@ -16,6 +16,7 @@ from AutoconfTest import AutoconfTest
|
|||
from SwarmTest import SwarmTest
|
||||
from KubernetesTest import KubernetesTest
|
||||
from LinuxTest import LinuxTest
|
||||
from Test import Test
|
||||
from logger import log
|
||||
|
||||
if len(argv) <= 1:
|
||||
|
|
@ -52,6 +53,32 @@ if not ret:
|
|||
log("TESTS", "❌", "Test.init() failed")
|
||||
exit(1)
|
||||
|
||||
domains = {}
|
||||
if test_type in ["docker", "autoconf", "linux"]:
|
||||
domains = {
|
||||
r"www\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1"),
|
||||
r"auth\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1"),
|
||||
r"app1\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1_1"),
|
||||
r"app2\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1_2"),
|
||||
r"app3\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1_3"),
|
||||
}
|
||||
elif test_type == "kubernetes":
|
||||
domains = {
|
||||
r"www\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1_2"),
|
||||
r"auth\.example\.com": Test.random_string(1) + "." + getenv("TEST_DOMAIN1_2"),
|
||||
r"app1\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1"),
|
||||
r"app2\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN2"),
|
||||
r"app3\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN3"),
|
||||
}
|
||||
elif test_type == "swarm":
|
||||
domains = {
|
||||
r"www\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1_1"),
|
||||
r"auth\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1_2"),
|
||||
r"app1\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN1"),
|
||||
r"app2\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN2"),
|
||||
r"app3\.example\.com": Test.random_string(6) + "." + getenv("TEST_DOMAIN3"),
|
||||
}
|
||||
|
||||
for example in glob("./examples/*"):
|
||||
if isfile(f"{example}/tests.json"):
|
||||
try:
|
||||
|
|
@ -79,6 +106,7 @@ for example in glob("./examples/*"):
|
|||
tests["tests"],
|
||||
no_copy_container=no_copy_container,
|
||||
delay=delay,
|
||||
domains=domains,
|
||||
)
|
||||
elif test_type == "autoconf":
|
||||
test_obj = AutoconfTest(
|
||||
|
|
@ -87,13 +115,14 @@ for example in glob("./examples/*"):
|
|||
tests["tests"],
|
||||
no_copy_container=no_copy_container,
|
||||
delay=delay,
|
||||
domains=domains,
|
||||
)
|
||||
elif test_type == "swarm":
|
||||
test_obj = SwarmTest(tests["name"], tests["timeout"], tests["tests"], delay=delay)
|
||||
test_obj = SwarmTest(tests["name"], tests["timeout"], tests["tests"], delay=delay, domains=domains)
|
||||
elif test_type == "kubernetes":
|
||||
test_obj = KubernetesTest(tests["name"], tests["timeout"], tests["tests"], delay=delay)
|
||||
test_obj = KubernetesTest(tests["name"], tests["timeout"], tests["tests"], delay=delay, domains=domains)
|
||||
elif test_type == "linux":
|
||||
test_obj = LinuxTest(tests["name"], tests["timeout"], tests["tests"], distro)
|
||||
test_obj = LinuxTest(tests["name"], tests["timeout"], tests["tests"], distro, domains=domains)
|
||||
if not test_obj.run_tests():
|
||||
log("TESTS", "❌", "Tests failed for " + tests["name"])
|
||||
if test_type == "linux":
|
||||
|
|
|
|||
Loading…
Reference in a new issue