Skip to content
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
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CLI tool for using the CSA Test Harness
Commands:
abort-testing Abort the current test execution
available-tests Get a list of available tests
doctor Diagnose problems reaching the backend
project Manage the application projects
rescan-tests Rescan available test collections
run-tests Create a new test run from selected tests
Expand All @@ -68,6 +69,30 @@ Options:

Run `th-cli test-runner-status` to get the current state of the Matter test runner. For JSON respond, add `--json`.

### doctor

Run `th-cli doctor` when the CLI cannot talk to the backend. It checks, and reports as pass / warn / fail / skip:

- **config**: which `config.json` is used (or that the example file or defaults were used) and the backend host. A
broken `config.json` is reported here instead of aborting the command.
- **backend reachable**: `GET /api/v1/version` with a 5 s timeout, reported as connection refused, DNS failure,
timeout or the HTTP status.
- **versions**: the CLI version and SHA next to the backend version, SHA, SDK tag and database revision.
- **test runner** and **database**: the runner state and a database-backed call (`/projects/`). A failure here is a
warning.
- **Docker containers** (backend, frontend, db, proxy): skipped when `docker` is not installed.

The command exits with a non-zero status if a check fails.

Options:
- `--json`: Print the results as JSON.
- `--no-docker`: Skip the Docker container checks.
- `--log-lines <N>`: Include the last N lines of the backend container log.
- `--no-redact`: Do not mask IP and MAC addresses.

The output is meant to be pasted into issues. Values of keys such as passwords, network keys, datasets, tokens and
setup codes, and credentials in URLs, are always masked. IP and MAC addresses are masked unless `--no-redact` is given.

### abort-testing

Run `th-cli abort-testing` to abort the test run execution that is currently running.
Expand Down
19 changes: 19 additions & 0 deletions tests/test_available_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,25 @@ def test_available_tests_generic_exception(
assert "Please check if the API server is running and accessible" in result.output
mock_api_client.close.assert_called_once()

def test_available_tests_transport_error_suggests_doctor(
self, cli_runner: CliRunner, mock_sync_apis: Mock, mock_api_client: Mock
) -> None:
"""An empty-text transport error names its type and points at `th-cli doctor`."""
from httpx import ConnectError

from th_cli.api_lib_autogen.exceptions import ResponseHandlingException
from th_cli.exceptions import BACKEND_HINT

api = mock_sync_apis.test_collections_api.read_test_collections_api_v1_test_collections__get
api.side_effect = ResponseHandlingException(ConnectError(""))
with patch("th_cli.commands.available_tests.get_client", return_value=mock_api_client):
with patch("th_cli.commands.available_tests.SyncApis", return_value=mock_sync_apis):
result = cli_runner.invoke(available_tests)

assert result.exit_code == 1
assert "ConnectError" in result.output
assert BACKEND_HINT in result.output

def test_available_tests_client_cleanup_on_exception(self, cli_runner: CliRunner, mock_api_client: Mock) -> None:
"""Test that client is properly cleaned up even when an exception occurs."""
# Arrange
Expand Down
Loading
Loading