Skip to content

Cherry-pick #418: Fail fast on test parameters the SDK test runner does not accept - #422

Merged
rquidute merged 6 commits into
project-chip:v2.17-developfrom
rquidute:fix/1215-validate-test-parameters-preflight-v2.17
Nov 23, 2026
Merged

rquidute merged 6 commits into
project-chip:v2.17-developfrom
rquidute:fix/1215-validate-test-parameters-preflight-v2.17

Conversation

@rquidute

@rquidute rquidute commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cherry-pick of #418 onto v2.17-develop. The original PR is not merged yet; this branch will need updating if review changes it.

Closes #1215 together with the CLI cherry-pick (certification-tool-cli#145).

A mistyped test parameter (e.g. --prompt_timeout instead of --prompt-timeout) only failed when the SDK runner was first invoked, in the middle of the run. Now:

  • The options the runner accepts are read from its --help when the Python test files are generated, and cached in sdk_tests/runner_options.json (git-ignored).
  • POST /test_run_executions/cli and /{id}/start answer 422 with the offending parameter, so no run is created.
  • The suite setup runs the same check as a fallback, before any DUT interaction.
  • Errors list one parameter per line. Suggestions ("did you mean") use a strict similarity cutoff, and the backend knows nothing about any client's options.

Full description and review discussion: #418.

Conflict resolutions (v2.17-develop differs from v2.16-develop)

  • tests/python_tests/test_utils.py: kept v2.17's file (it already has the native-log tests) and appended the validation tests.
  • python_testing/models/utils.py: kept v2.17's re/datetime imports and added only the new functions.
  • python_testing/test_manager.py: kept v2.17's _generate_all_test_files(script_errors) signature and added the _refresh_runner_options call after the container starts.

The six commits are otherwise unchanged. Every file added by the original PR is identical to it.

Tests

Same tests as #418. Not run locally (backend dependencies unavailable where this was prepared); please rely on CI.

Test parameters are forwarded as --<name> <value> to test_harness_client.py.
A mistyped one (e.g. --prompt_timeout) only failed when the runner was first
invoked, in the middle of the run, with the reason visible only in the Python
test log.

At the start of the Python test suite setup, read the runner's options from
its --help (no side effects, never stale) and end the run with a clear
message, before any DUT interaction, if a test parameter is unknown. If the
options cannot be read the check is skipped.

Related to #1215
Cache the options the SDK test runner accepts (read from its --help) whenever
the Python test files are generated, in sdk_tests/runner_options.json. The
test run create (/cli) and start endpoints use it to answer 422 with the
offending parameter, so a mistyped one no longer creates a run, starts a
container and cancels every step.

The suite-setup check stays as a fallback for when the cache is unavailable.
An unreadable or malformed cache means "do not validate", and a failed
refresh drops the old cache so a previous SDK version's list is never used.

Related to #1215
MagicMock(spec=SDKContainer) created in parametrize raised AttributeError
while importing test_utils.py, breaking collection of the whole module.
The backend should not know the options of one client. Drop the
th-cli run-tests hint and instead make the 'did you mean' suggestion
stricter (cutoff 0.8): the default suggested the unrelated --timeout for
--prompt-timeout and --tests for --tests-list. Real typos still get a
suggestion.

Related to #1215
- Do not fail the suite setup when the --help probe raises, and drop the
  redundant warning when the options are unavailable (already logged).
- Reject ambiguous option abbreviations like argparse does: an exact name
  is accepted, otherwise it must abbreviate exactly one option.
- Do not abort test file generation when the options cache cannot be
  written or deleted; empty it instead so a stale list is never used.

Related to #1215
The error is shown in a terminal by th-cli, where a single long line is hard
to read.

Related to #1215
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8f339ca0-ab29-438c-96df-7a61134ab3a9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mergify

mergify Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@rquidute rquidute self-assigned this Nov 23, 2026
@rquidute
rquidute merged commit 21d5235 into project-chip:v2.17-develop Nov 23, 2026
5 of 6 checks passed
@rquidute
rquidute deleted the fix/1215-validate-test-parameters-preflight-v2.17 branch November 23, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants