Skip to content

Commit

Permalink
Prepare E2E tooling for better message passing (#15843)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored Sep 15, 2023
1 parent 6237ac3 commit d69dc07
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
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

0 comments on commit d69dc07

Please sign in to comment.