Skip to content

refactor(integration-tests): Use ExternalAction flows throughout the testing suite; deprecate log_subprocess_output_to_file().#2242

Open
quinntaylormitchell wants to merge 5 commits intoy-scope:mainfrom
quinntaylormitchell:testing-migration-externalaction
Open

refactor(integration-tests): Use ExternalAction flows throughout the testing suite; deprecate log_subprocess_output_to_file().#2242
quinntaylormitchell wants to merge 5 commits intoy-scope:mainfrom
quinntaylormitchell:testing-migration-externalaction

Conversation

@quinntaylormitchell
Copy link
Copy Markdown
Collaborator

@quinntaylormitchell quinntaylormitchell commented May 4, 2026

Description

This PR migrates the testing suite with respect to the new designs implemented in #2182 (ExternalAction, CmdMsg). The previous flow that used log_subprocess_output_to_file() has been removed, and all related flows have been modified accordingly.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Ran uv run pytest -m 'package' and uv run pytest -m 'core'; all tests pass.

Summary by CodeRabbit

  • Tests

    • Standardized external command handling in integration tests with explicit return-code checks and clearer fail-fast messages for more reliable, diagnosable test runs.
    • Updated tests to extract and validate log/event outputs more robustly.
  • Chores

    • Reorganized and consolidated test utilities, removing a legacy subprocess helper.
    • Added filesystem and JSON structural comparison utilities to strengthen test verification.

@quinntaylormitchell quinntaylormitchell requested a review from a team as a code owner May 4, 2026 20:12
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 75e1c59c-3b5b-4220-8c28-1691726404e5

📥 Commits

Reviewing files that changed from the base of the PR and between c64c205 and 55fff1a.

📒 Files selected for processing (2)
  • integration-tests/tests/utils/docker_utils.py
  • integration-tests/tests/utils/fs_validation.py

Walkthrough

This PR replaces ad-hoc subprocess invocation helpers with an ExternalAction abstraction across integration tests and fixtures, introduces fs_validation helpers for filesystem/JSON comparison, removes the old subprocess logging utility, and updates call sites to check ExternalAction.completed_proc.returncode and call pytest.fail(format_action_failure_msg(...)) on failures. (39 words)

Changes

Integration-test External Command and FS Validation Refactor

Layer / File(s) Summary
Data Shape & Small API
integration-tests/tests/utils/classes.py
ExternalAction now has optional `args: CmdArgs
New FS Validation Module
integration-tests/tests/utils/fs_validation.py
Adds is_dir_tree_content_equal(path1, path2), is_json_file_structurally_equal(json_fp1, json_fp2), and _sort_json_keys_and_rows(json_fp). These invoke diff/jq via ExternalAction/get_binary_path, interpret exit codes (0/1 → boolean) and raise RuntimeError on unexpected failures.
Logging/Helpers Cleanup
integration-tests/tests/utils/logging_utils.py
Removes log_subprocess_output_to_file and related log-file writing; keeps format_action_failure_msg and reduces imports to logging and ExternalAction.
Core Utilities Integration
integration-tests/tests/utils/docker_utils.py, integration-tests/tests/utils/package_utils.py, integration-tests/tests/utils/asserting_utils.py
Docker, package lifecycle, and package-assertion helpers now run external commands via ExternalAction.from_cmd(...), check completed_proc.returncode, and raise/call pytest.fail(format_action_failure_msg(...)) or RuntimeError on non-zero exits. Docstrings updated to reference pytest.fail/RuntimeError. asserting_utils now imports FS validators from fs_validation.
Tests & Fixtures Wiring
integration-tests/tests/fixtures/integration_test_logs.py, integration-tests/tests/test_identity_transformation.py, integration-tests/tests/test_log_converter.py
Tests and fixtures replace run_and_log_subprocess/direct subprocess usage with ExternalAction.from_cmd(...) for commands (curl, tar, chmod, clp, clp-s, log-converter, etc.), add explicit return-code checks, call pytest.fail(format_action_failure_msg(...)) on failures, and read command output from completed_proc.stdout where consumed.
Removal / Simplification
integration-tests/tests/utils/subprocess_utils.py, integration-tests/tests/utils/utils.py
Removes subprocess_utils.py (including run_and_log_subprocess and DEFAULT_CMD_TIMEOUT_SECONDS), extracts directory/JSON comparison helpers into fs_validation.py, and simplifies imports in utils.py.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring effort: migrating the testing suite to use ExternalAction flows and deprecating log_subprocess_output_to_file().
Docstring Coverage ✅ Passed Docstring coverage is 91.30% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Ruff (0.15.12)
integration-tests/tests/utils/docker_utils.py

�[1;31mruff failed�[0m
�[1mCause:�[0m Failed to load extended configuration /tools/yscope-dev-utils/exports/lint-configs/python/ruff.toml (/integration-tests/pyproject.toml extends /tools/yscope-dev-utils/exports/lint-configs/python/ruff.toml)
�[1mCause:�[0m Failed to read /tools/yscope-dev-utils/exports/lint-configs/python/ruff.toml
�[1mCause:�[0m No such file or directory (os error 2)

integration-tests/tests/utils/fs_validation.py

�[1;31mruff failed�[0m
�[1mCause:�[0m Failed to load extended configuration /tools/yscope-dev-utils/exports/lint-configs/python/ruff.toml (/integration-tests/pyproject.toml extends /tools/yscope-dev-utils/exports/lint-configs/python/ruff.toml)
�[1mCause:�[0m Failed to read /tools/yscope-dev-utils/exports/lint-configs/python/ruff.toml
�[1mCause:�[0m No such file or directory (os error 2)


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@integration-tests/tests/test_log_converter.py`:
- Around line 98-99: The conditional `if stdout else []` is redundant—use the
captured stdout directly: replace the `stdout =
search_action.completed_proc.stdout` / `lines = stdout.splitlines() if stdout
else []` pattern by calling `splitlines()` on
`search_action.completed_proc.stdout` (i.e., `lines =
search_action.completed_proc.stdout.splitlines()`) so `lines` is produced
correctly from the `stdout` string; refer to the `stdout` variable and
`search_action.completed_proc.stdout`/`lines` in the change.

In `@integration-tests/tests/utils/fs_validation.py`:
- Around line 18-19: Replace the literal "diff" command with a resolved binary
path using get_binary_path("diff") so missing-binary errors raise RuntimeError
immediately and match the docstring; update the cmd construction in the block
that creates ExternalAction (the variable diff_action and cmd assignment) to
call get_binary_path("diff") and use that returned path, leaving ExternalAction
and ExternalAction._run_subprocess() unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 221bb561-877c-439c-9998-a608a4d4700b

📥 Commits

Reviewing files that changed from the base of the PR and between 645fe06 and 7e4ab2f.

📒 Files selected for processing (11)
  • integration-tests/tests/fixtures/integration_test_logs.py
  • integration-tests/tests/test_identity_transformation.py
  • integration-tests/tests/test_log_converter.py
  • integration-tests/tests/utils/asserting_utils.py
  • integration-tests/tests/utils/classes.py
  • integration-tests/tests/utils/docker_utils.py
  • integration-tests/tests/utils/fs_validation.py
  • integration-tests/tests/utils/logging_utils.py
  • integration-tests/tests/utils/package_utils.py
  • integration-tests/tests/utils/subprocess_utils.py
  • integration-tests/tests/utils/utils.py
💤 Files with no reviewable changes (2)
  • integration-tests/tests/utils/logging_utils.py
  • integration-tests/tests/utils/subprocess_utils.py

Comment thread integration-tests/tests/test_log_converter.py Outdated
Comment thread integration-tests/tests/utils/fs_validation.py Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@integration-tests/tests/utils/fs_validation.py`:
- Around line 58-63: The NamedTemporaryFile call explicitly passes delete=True
which is redundant because delete=True is the default; update the call that
creates sorted_fp (the NamedTemporaryFile instantiation in fs_validation.py
where sorted_fp is assigned) to omit the delete=True argument so it reads simply
NamedTemporaryFile(mode="w+"), leaving the rest of the usage (write/flush/seek)
unchanged.
- Line 55: The error message for a failing jq run (built from jq_rc and json_fp)
should include jq_action.completed_proc.stderr when available; update the
construction of err_msg in the fs_validation.py logic (where err_msg = f"jq
failed with exit code {jq_rc} for {json_fp}") to append the captured stderr
output (e.g., include a suffix like "stderr:
{jq_action.completed_proc.stderr!r}" only when stderr is present) so diagnostics
are preserved while retaining the existing exit code and filepath information.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0c3d895c-9aa4-4f8a-b7cd-a9b87a3e0ea0

📥 Commits

Reviewing files that changed from the base of the PR and between 7e4ab2f and bb6d688.

📒 Files selected for processing (2)
  • integration-tests/tests/test_log_converter.py
  • integration-tests/tests/utils/fs_validation.py

Comment thread integration-tests/tests/utils/fs_validation.py Outdated
Comment thread integration-tests/tests/utils/fs_validation.py Outdated
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.

1 participant