CLOUD-929 - Initial pytest test migration#2058
Conversation
e2e-tests/lib/tools.py
Outdated
|
|
||
| # TODO: consider using Python for filtering instead of yq | ||
| yq_filter = f""" | ||
| del(.metadata.ownerReferences[].apiVersion) | |
There was a problem hiding this comment.
This would be nice in a separated file perhaps
e2e-tests/conftest.py
Outdated
|
|
||
|
|
||
| @pytest.fixture(scope="class") | ||
| def deploy_chaos_mesh(namespace): |
There was a problem hiding this comment.
I think we could have separate file for helm installed dependencies and use a generic function with parameters to install a helm chart since subprocess is going to be used fot it
e2e-tests/tools.py
Outdated
| def kubectl_bin(*args, check: bool = True, input_data: str = "") -> str: | ||
| """Execute kubectl command""" | ||
| cmd = ["kubectl"] + list(args) | ||
| logger.debug(" ".join(map(str, cmd))) | ||
| result = subprocess.run(cmd, check=check, capture_output=True, text=True, input=input_data) | ||
|
|
||
| if result.stderr: | ||
| logger.warning(f"kubectl error: {result.stderr}") | ||
| return result.stderr | ||
|
|
||
| return result.stdout |
There was a problem hiding this comment.
I think it would be nice to add a -n <current-namespace> option and stop changing the kubectl context. This would match the approach used in kuttl tests and would let us run multiple tests in parallel on the same cluster. I don’t think it would cause any problems.
e2e-tests/conftest.py
Outdated
| os.environ.setdefault("DELETE_CRD_ON_START", "1") | ||
| os.environ.setdefault("SKIP_DELETE", "0") | ||
| os.environ.setdefault("SKIP_BACKUPS_TO_AWS_GCP_AZURE", "1") | ||
| os.environ.setdefault("UPDATE_COMPARE_FILES", "0") |
There was a problem hiding this comment.
UPDATE_COMPARE_FILES isn't implemented in this PR
e2e-tests/lib/tools.py
Outdated
|
|
||
| if result.stderr: | ||
| logger.warning(f"kubectl error: {result.stderr}") | ||
| return result.stderr |
There was a problem hiding this comment.
| return result.stderr |
If we have stderr and result.returncode is 0, I think we should still return stdout
| create_infra() { | ||
| local ns="$1" | ||
|
|
||
| echo "$ns" > /tmp/pytest_current_namespace |
There was a problem hiding this comment.
[shfmt] reported by reviewdog 🐶
| echo "$ns" > /tmp/pytest_current_namespace | |
| echo "$ns" >/tmp/pytest_current_namespace |
Commit: 9a7560b |
Due to the high volume of requests, we're unable to provide free service for this account. To continue using the service, please upgarde to a paid plan.
CHANGE DESCRIPTION
This PR sets up the initial groundwork for transitioning to pytest as our testing framework. It includes:
Create virtual environment and install dependencies:
uv sync --lockedRun all tests:
uv run pytestRun a specific test
uv run pytest e2e-tests/init-deployEnabling debug logging:
LOG_LEVEL=DEBUG uv run pytestCHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability