Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare E2E tooling for better message passing #15843

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datadog_checks_dev/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* Added overview examples to the readme file ([#15817](https://github.com/DataDog/integrations-core/pull/15817))
* Added required classifier tag examples to template ([#15828](https://github.com/DataDog/integrations-core/pull/15828))
* Prepare E2E tooling for better message passing ([#15843](https://github.com/DataDog/integrations-core/pull/15843))

## 25.0.0 / 2023-09-13

Expand Down
1 change: 1 addition & 0 deletions datadog_checks_dev/datadog_checks/dev/_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
E2E_SET_UP = '{}_UP'.format(E2E_PREFIX)
E2E_TEAR_DOWN = '{}_DOWN'.format(E2E_PREFIX)
E2E_PARENT_PYTHON = '{}_PYTHON_PATH'.format(E2E_PREFIX)
E2E_RESULT_FILE = '{}_RESULT_FILE'.format(E2E_PREFIX)

E2E_FIXTURE_NAME = 'dd_environment'
TESTING_PLUGIN = 'DDEV_TESTING_PLUGIN'
Expand Down
18 changes: 13 additions & 5 deletions datadog_checks_dev/datadog_checks/dev/plugin/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .._env import (
E2E_FIXTURE_NAME,
E2E_PARENT_PYTHON,
E2E_RESULT_FILE,
SKIP_ENVIRONMENT,
TESTING_PLUGIN,
e2e_active,
Expand Down Expand Up @@ -128,15 +129,22 @@ def dd_environment_runner(request):

data = {'config': config, 'metadata': metadata}

message = serialize_data(data)

message = 'DDEV_E2E_START_MESSAGE {} DDEV_E2E_END_MESSAGE'.format(message)
message_template = 'DDEV_E2E_START_MESSAGE {} DDEV_E2E_END_MESSAGE'

if testing_plugin:
return message
return message_template.format(serialize_data(data))
else: # no cov
# Exit testing and pass data back up to command
pytest.exit(message)
if E2E_RESULT_FILE in os.environ:
# Standard `pytest.exit` requires a reason but we want an empty string for minimal output
from _pytest.outcomes import Exit

with open(os.environ[E2E_RESULT_FILE], 'w', encoding='utf-8') as f:
f.write(json.dumps(data))

Exit('', 0)
else:
pytest.exit(message_template.format(serialize_data(data)))


@pytest.fixture
Expand Down