Conversation
Member
|
@cidrblock bring it out of draft once is passing all CI checks. |
Made-with: Cursor
…ctations The ../inventory.yml relative path in config.yml only works for flat scenarios. For group_a/scenario_0 it resolves to group_a/inventory.yml (wrong) instead of molecule/inventory.yml. Add inventory copies in each group directory so ansible finds hosts and actually runs the playbooks. Also fix slice count expectations: default scenario is included in slicing, so depth=1 yields 3 slices and depth=2 yields 7. Remove unused 'psql' from dictionary.txt (flagged by cspell hook). Made-with: Cursor
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
Adds a
--sliceflag (and config file support) to control how scenarios are grouped into work units when using--workers. With--slice=1(the default), scenarios are grouped by their top-level directory segment so all CRUD states for a resource run sequentially on one worker. With--slice=2, each leaf scenario is dispatched independently (pre-slice behavior).This is relevant for collections with nested scenario directories (e.g.
appliance_vlans/gathered,appliance_vlans/merged) where related scenarios share state and must execute in order within a worker.Changes by file
src/molecule/click_cfg.py— Newsliceproperty onCliOptions(experimental, default"1").src/molecule/types.py—slice: intadded to bothCommandArgsandConfigDataTypedDicts.src/molecule/command/test.py,check.py,destroy.py—"slice"added to@common_optionsand wired intocommand_argsviaint(ctx.params["slice"]). No other runtime changes.src/molecule/config.py—sliceproperty reads from the config dict (self.config.get("slice", 1)), following the same pattern asshared_state._apply_cli_overridesextended so CLI--slicetakes precedence over the config file value.src/molecule/data/molecule.json— Schema entry forslice(integer, default 1, minimum 1).src/molecule/scenarios.py—sliceproperty onScenariosreads from the first scenario's config, mirroring theshared_stateaggregation pattern.src/molecule/worker.py— Core implementation:_slice_key(name, depth)— splits scenario name on/and joins the firstdepthsegments to derive the grouping key._group_scenarios_by_slice(scenarios, depth)— groupsScenarioobjects by_slice_key, preserving original sort order.run_scenario_slice(entries, ...)— executes a list of(molecule_file, name)pairs sequentially in one worker process, stopping on first failure within the slice. Returnslist[SliceResult].run_scenarios_parallel— refactored to group via_group_scenarios_by_sliceand submit one future per group torun_scenario_sliceinstead of one future per scenario. Fail-fast and continue-on-failure semantics apply at the slice level. Log output reports slice count and depth.validate_worker_args— validates that--slice(non-default) requires--workers > 1.run_one_scenarioremains unchanged and exported for backward compatibility but is no longer called internally —run_scenario_slicehandles all dispatch.pyproject.toml—verbosity_assertionschanged from2(int) to"2"(string). Newer pytest requires this config option to be a string; the int type causedTypeErrorin all integration tests with assertion failures. Pre-existing issue, not introduced by this PR.tests/fixtures/integration/test_workers/— Fixture scenarios restructured from flat (scenario_0..5) to nested (group_a/scenario_0..2,group_b/scenario_3..5) to enable slice testing.config.ymlnow includesslice: 1.tests/unit/test_worker.py— New tests for_slice_key(4 cases),_group_scenarios_by_slice(4 cases),run_scenario_slice(success + failure-stops-early),validate_worker_argsslice validation (2 cases). Existingrun_scenarios_paralleltests updated for the newlist[SliceResult]return format.tests/unit/test_click_cfg.py—test_slice_optionverifying the new CLI option properties.tests/integration/test_workers.py— Scenario references updated for nested names. Two new tests:test_workers_slice_groups_by_resource(verifies 2 slices at depth=1) andtest_workers_slice_depth_2(verifies 6 slices at depth=2).docs/guides/parallel.md— Documents--slicewith a behavior table, CLI examples, config file example, and precedence notes.Runtime behavior
Existing
--workersbehavior is preserved. The default--slice=1groups scenarios by their first path segment, which is a change from pre-slice behavior (individual dispatch) but produces the same results since scenarios within a group still execute sequentially. Users can opt into the previous individual-dispatch behavior with--slice=2.Sequential mode (
--workers 1or no--workers) is completely unaffected —slicein the config is silently ignored.Test plan
_slice_key,_group_scenarios_by_slice,run_scenario_slice, validation, parallel dispatch)tox -e lintclean (ruff, cspell, pydoclint, pylint, mypy, codespell)