various (#16)
* add full integration test of cli / pytest_abra with all tests * save path of runner_*.py in runner subclass to improve test discovery -> allows for same test name in two different runners * reorganize output dir names * use URL fixture everywhere * rework coordinator interface * add --session_id to cli args * add log results table * plenty of refactoring * add assert messages * add plenty of tests * add /docs dir with plenty of documentation * fix authentik setup * add authentik cleanup, remove test user * add random test user credential generation and integrate into test routine. random creds are saved to STATES Reviewed-on: local-it-infrastructure/e2e_tests#16 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
parent
016b88a68d
commit
2dd765a974
36 changed files with 1145 additions and 432 deletions
|
|
@ -4,9 +4,10 @@ from typing import TYPE_CHECKING, NamedTuple
|
|||
|
||||
from dotenv import dotenv_values
|
||||
|
||||
from pytest_abra.utils import files_are_same
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pytest_abra.dir_manager import DirManager
|
||||
from pytest_abra.runner import Runner
|
||||
from pytest_abra import DirManager, Runner
|
||||
|
||||
|
||||
class EnvFile(NamedTuple):
|
||||
|
|
@ -45,6 +46,7 @@ class EnvManager:
|
|||
def _get_dependency_rules(env_files: list[EnvFile], RUNNER_DICT: dict[str, type["Runner"]]) -> list[DependencyRule]:
|
||||
dependency_rules: list[DependencyRule] = []
|
||||
for env_file in env_files:
|
||||
assert env_file.env_type in RUNNER_DICT, f"no runner for env_type={env_file.env_type} found in RUNNER_DICT"
|
||||
child_runner_class = RUNNER_DICT[env_file.env_type]
|
||||
for dependency in child_runner_class.dependencies:
|
||||
dependency_rule = DependencyRule(child=child_runner_class.env_type, dependency=dependency)
|
||||
|
|
@ -93,11 +95,25 @@ class EnvManager:
|
|||
"Could not resolve test order. This is possibly due to a circular dependency (a on b, b on c, c on a)"
|
||||
)
|
||||
|
||||
def copy_env_files(self, DIR: "DirManager") -> None:
|
||||
"""Copies all env files to STATES/env_files. Files will be renamed to
|
||||
<index>-<env_type>-<original_name>
|
||||
00-authentik-login.test.dev.local-it.cloud.env"""
|
||||
@staticmethod
|
||||
def copy_env_files(env_files: list[EnvFile], DIR: "DirManager") -> None:
|
||||
"""Copies all env files to STATES/env_files.
|
||||
|
||||
for index, env_file in enumerate(self.env_files):
|
||||
Files will be renamed to <index>-<env_type>-<original_name>. Example:
|
||||
00-authentik-login.test.dev.local-it.cloud.env
|
||||
|
||||
Does nothing when called twice with same env_files. Throws an AssertionError if either
|
||||
contents or filenames of env_files have changed (probably test rerun with different input)"""
|
||||
|
||||
dir_was_not_empty = len(list(DIR.ENV_FILES.iterdir())) > 0
|
||||
|
||||
for index, env_file in enumerate(env_files):
|
||||
file_name = "-".join([str(index).zfill(2), env_file.env_type, env_file.env_path.name])
|
||||
if dir_was_not_empty:
|
||||
# check that the copied env files have not changed
|
||||
present_files = [f.name for f in DIR.ENV_FILES.iterdir()]
|
||||
assert (
|
||||
file_name in present_files and files_are_same(env_file.env_path, DIR.ENV_FILES / file_name)
|
||||
), "It appears that you are resuming a test while the input env files have changed. Start a new test instead"
|
||||
|
||||
shutil.copy(env_file.env_path, DIR.ENV_FILES / file_name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue