Skip to content

Commit 1fdfb32

Browse files
authored
Ensure that E2E tests do not run for packages that won't contain any E2E (DataDog#20967)
* Ensrue that E2E tests do not run for packages that won't contain any E2E * Add changelog * Fix typos and remove debug print * Modify existing test to ensure it is not skipped
1 parent 1ecb16e commit 1fdfb32

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

ddev/changelog.d/20967.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Skip E2E test execution for packages that do not define them.

ddev/src/ddev/cli/env/test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,18 @@ def test_command(
7878
from ddev.config.constants import AppEnvVars
7979
from ddev.e2e.config import EnvDataStorage
8080
from ddev.e2e.constants import E2EMetadata
81+
from ddev.repo.constants import NOT_E2E_TESTABLE
8182
from ddev.utils.ci import running_in_ci
8283
from ddev.utils.structures import EnvVars
8384

8485
app: Application = ctx.obj
85-
storage = EnvDataStorage(app.data_dir)
8686
integration = app.repo.integrations.get(intg_name)
87+
88+
if integration.name in NOT_E2E_TESTABLE:
89+
app.display_info(f"Selected target {integration.name!r} does not have E2E tests to run. Skipping.")
90+
return
91+
92+
storage = EnvDataStorage(app.data_dir)
8793
active_envs = storage.get_environments(integration.name)
8894

8995
if environment is None:
@@ -109,6 +115,7 @@ def test_command(
109115
and (not data.get('platforms') or app.platform.name in data['platforms'])
110116
and (python_filter is None or data.get('python') == python_filter)
111117
]
118+
112119
elif environment == 'active':
113120
env_names = active_envs
114121
else:

ddev/src/ddev/repo/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Licensed under a 3-clause BSD style license (see LICENSE)
44
CONFIG_DIRECTORY = '.ddev'
55
NOT_SHIPPABLE = frozenset(['datadog_checks_dev', 'datadog_checks_tests_helper', 'ddev'])
6+
NOT_E2E_TESTABLE = frozenset(['datadog_checks_dev', 'datadog_checks_base', 'datadog_checks_tests_helper', 'ddev'])
67
FULL_NAMES = {
78
'core': 'integrations-core',
89
'extras': 'integrations-extras',

ddev/tests/cli/env/test_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# (C) Datadog, Inc. 2024-present
22
# All rights reserved
33
# Licensed under a 3-clause BSD style license (see LICENSE)
4+
from contextlib import nullcontext
5+
46
import mock
7+
import pytest
58

69
from tests.helpers.mocks import MockPopen
710

@@ -23,3 +26,24 @@ def test_env_vars_repo(ddev, helpers, data_dir, write_result_file, mocker):
2326
with mock.patch('ddev.utils.structures.EnvVars', side_effect=MockEnvVars):
2427
result = ddev('env', 'test', 'postgres', 'py3.12')
2528
assert result.exit_code == 0, result.output
29+
# Ensure test was not skipped
30+
assert "does not have E2E tests to run" not in result.output
31+
32+
33+
@pytest.mark.parametrize(
34+
'target, expectation',
35+
[
36+
('datadog_checks_dev', nullcontext()),
37+
('datadog_checks_base', nullcontext()),
38+
# This will raise an OSError because the package is not a valid integration
39+
('datadog_checks_tests_helper', pytest.raises(OSError)),
40+
('ddev', nullcontext()),
41+
],
42+
ids=['datadog_checks_dev', 'datadog_checks_base', 'datadog_checks_tests_helper', 'ddev'],
43+
)
44+
@pytest.mark.parametrize('env', ['py3.12', 'all', ''], ids=['py3.12', 'all', 'no-env'])
45+
def test_env_test_not_e2e_testable(ddev, target: str, env: str, expectation):
46+
with expectation:
47+
result = ddev('env', 'test', target, env)
48+
assert result.exit_code == 0, result.output
49+
assert "does not have E2E tests to run" in result.output

0 commit comments

Comments
 (0)