Skip to content

Commit

Permalink
pw_bluetooth_sapphire: Fuchsia test outputs in CQ
Browse files Browse the repository at this point in the history
Expose fuchsia test orchestration outputs in CQ by specifying
`TEST_UNDECLARED_OUTPUTS_DIR`[1] via
`TEST_UNDECLARED_OUTPUTS_DIR_OVERRIDE`[2], allowing those outputs to be
captured by the glob pattern in the `save_logs` recipe module.

Test outputs include ffx host logs, ffx target logs, ffx daemon logs,
ssh logs, and subrunner (test stdout + stderr) logs.

This will help us better understand test execution/failures in CQ.

[1]: https://cs.opensource.google/fuchsia/fuchsia/+/main:tools/orchestrate/orchestrator.go;l=32;drc=cdbc75125ae61cf5937631c7151c35f5a32a5731
[2]: https://fxrev.dev/1110434

Bug: 362990622
Change-Id: I26468e988ede800a8749ff6ffd39424a184985c9
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/232331
Reviewed-by: Ted Pudlik <[email protected]>
Commit-Queue: Darren Chan <[email protected]>
Lint: Lint 🤖 <[email protected]>
  • Loading branch information
chandarrengoog authored and CQ Bot Account committed Aug 30, 2024
1 parent 3e28899 commit 6829156
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
25 changes: 22 additions & 3 deletions pw_bluetooth_sapphire/docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,33 @@ Example:
Run Fuchsia presubmit tests
===========================
Presubmits for bt-host are captured in a dedicated separate builder, rather than
existing ones such as ``pigweed-linux-bazel-noenv``.
These presubmits can be replicated with the following command:
Presubmits for bt-host are captured in a dedicated separate builder,
``pigweed-linux-bazel-bthost``, rather than existing ones such as
``pigweed-linux-bazel-noenv``.

On the builder invocation console, there are a number of useful artifacts for
examining the environment during test failures. Here are some notable examples:

* ``bt_host_package`` stdout: Combined stdout/stderr of the entire test orchestration and execution.
* ``subrunner.log``: Combined test stdout/stderr of test execution only.
* ``target.log``: The ffx target device's logs.
* ``ffx_config.txt``: The ffx configuration used for provisioning and testing.
* ``ffx.log``: The ffx host logs.
* ``ffx_daemon.log``: The ffx daemon's logs.
* ``env.dump.txt``: The environment variables when test execution started.
* ``ssh.log``: The ssh logs when communicating with the target device.

These presubmits can be also be replicated locally with the following command:

.. code-block::
bazel run --config=fuchsia //pw_bluetooth_sapphire/fuchsia:infra.test_all
.. note::
Existing package servers must be stopped before running this command. To
check for any existing package servers run ``lsof -i :8083`` and make sure
each of those processes are killed.

.. note::
You do not need to start an emulator beforehand to to run all tests this way.
This test target will automatically provision one before running all tests.
Expand Down
15 changes: 11 additions & 4 deletions pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,21 @@ def bthost_package(ctx: PresubmitContext) -> None:
"""Builds, tests, and prepares bt_host for upload."""
target = '//pw_bluetooth_sapphire/fuchsia:infra'
build_bazel(ctx, 'build', '--config=fuchsia', target)
# Override the default test_tag_filters to ensure test targets tagged
# "integration" are still run.

# Explicitly specify TEST_UNDECLARED_OUTPUTS_DIR_OVERRIDE as that will allow
# `orchestrate`'s output (eg: ffx host + target logs, test stdout/stderr) to
# be picked up by the `save_logs` recipe module.
# We cannot rely on Bazel's native TEST_UNDECLARED_OUTPUTS_DIR functionality
# since `zip` is not available in builders. See https://pwbug.dev/362990622.
build_bazel(
ctx,
'test',
'run',
'--config=fuchsia',
'--test_tag_filters=',
f'{target}.test_all',
env=dict(
os.environ,
TEST_UNDECLARED_OUTPUTS_DIR_OVERRIDE=ctx.output_dir,
),
)

stdout_path = ctx.output_dir / 'bazel.manifest.stdout'
Expand Down

0 comments on commit 6829156

Please sign in to comment.