Add Tier-1 integration tests; fix bugs; inline result collector#1
Merged
Conversation
Adds a Tier-1 test suite (30 tests) that exercises the full execution path (build_task -> TaskQueueManager -> result parsing -> failure handling) via Ansible's local connection plugin, with no SSH or external host required. Fixes three bugs uncovered by the new tests: 1. The 'json_results' stdout callback referenced by _run() was not bundled in the standalone package. Replaced with an inline _JsonResultsCallback constructed directly (no plugin loader). 2. tqm._stdout_callback was removed in ansible-core 2.19+. The callback instance is now appended to tqm._callback_plugins directly, and the default 'minimal' stdout callback is evicted after load_callbacks() so it does not print to the terminal. 3. json.dumps in _check_failed_results crashed on non-serializable Task instances in _task_fields on ansible-core 2.19+. Added default=str. Test coverage groups: - Basic execution and dynamic dispatch via __getattr__ - load_module / run_loaded_modules and with-block batch mode - no_log censoring (with negative control) - forks fan-out across a 4-host local-connection inventory - AnsibleHosts container protocol (len, getitem int/str/bad, iter) - Pattern matching (subset, empty -> NoAnsibleHostError) - _make_single_host fast-path regression - Per-host failure aggregation (failures do not drop hosts from results) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Xin Wang <wangxin.wang@gmail.com>
The previous negative control asserted SECRET appears in result['invocation'], which depends on Ansible's interpreter-discovery state and was empty on Python 3.12/3.13 in CI. Assert SECRET appears anywhere in the serialized result instead (stdout from echo always has it). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Xin Wang <wangxin.wang@gmail.com>
- Lead with AnsibleLocalhost: zero setup (no inventory, no SSH) so the first snippet a reader copies actually runs. - Add inline inventory.ini example for the AnsibleHost path. - Document the result-shape matrix (single/multi host x single/batch). - Document AnsibleModuleFailed + ignore_errors failure semantics. - Expand task_directives coverage (ignore_errors, no_log, when, failed_when, changed_when, become). - Show AnsibleHosts container protocol (len, getitem, iter). - Link to tests/test_local_integration.py as runnable examples. - Fix stale ansible-core version cap: <2.20 -> <2.22. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Xin Wang <wangxin.wang@gmail.com>
Adds a short note pointing out that `with host:` is lexically scoped, and that `load_module` + `run_loaded_modules` is the explicit form for assembling a batch across multiple functions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Xin Wang <wangxin.wang@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make the library testable end-to-end without SSH or Docker, fix three bugs the new tests uncovered, and rewrite the README Quickstart to be copy-paste runnable.
Bug fixes
json_resultsplugin that only existed insonic-mgmt).tqm._stdout_callbackwas removed in ansible-core 2.19+; append the collector totqm._callback_pluginsdirectly instead.json.dumpsin_check_failed_resultscrashed on non-serializableTaskinstances on ansible-core 2.19+; addeddefault=str.Tests
30 Tier-1 integration tests using Ansible's
localconnection — hermetic, no SSH, no Docker. Covers basic execution, dynamic dispatch, batch modes,no_log,forks, multi-host fan-out, theAnsibleHostscontainer protocol, and per-host failure aggregation.README
Rewrote the Quickstart so the first snippet actually runs (uses
AnsibleLocalhost), added a result-shape matrix, documented failure semantics, and fixed a staleansible-core<2.20cap.Validation
All 17 CI jobs green (lint + Python 3.10–3.13 × ansible-core 2.16–2.21 matrix).