Aggregate requisites AFTER aggregating states

This commit is contained in:
Tyler Levy Conde 2024-06-04 15:53:36 -06:00 committed by Daniel Wozniak
parent 9ea88c5bef
commit 0b599713e9
2 changed files with 7 additions and 22 deletions

View file

@ -972,8 +972,9 @@ class State:
self.state_con["loader_cache"][agg_fun] = True self.state_con["loader_cache"][agg_fun] = True
try: try:
low["__agg__"] = True low["__agg__"] = True
low = self._aggregate_requisites(low, chunks) # Aggregate the states *before* aggregating requisites otherwise there will never be requisites to aggregate
low = self.states[agg_fun](low, chunks, running) low = self.states[agg_fun](low, chunks, running)
low = self._aggregate_requisites(low, chunks)
except TypeError: except TypeError:
log.error("Failed to execute aggregate for state %s", low["state"]) log.error("Failed to execute aggregate for state %s", low["state"])
else: else:

View file

@ -1118,28 +1118,12 @@ def test_mod_aggregate_order(minion_opts):
state_obj.opts["state_aggregate"] = True # Ensure state aggregation is enabled state_obj.opts["state_aggregate"] = True # Ensure state aggregation is enabled
# Process each chunk with _mod_aggregate to simulate state execution # Process each chunk with _mod_aggregate to simulate state execution
running = state_obj.call_chunks(chunks) state_obj.call_chunks(chunks)
first_key = "pkg_|-first packages_|-first packages_|-installed" first_state_low = chunks[0]
requirement_key = "test_|-requirement_|-requirement_|-nop" last_state_low = chunks[-1]
second_key = "pkg_|-second packages_|-second packages_|-installed" # Verify that the requisites got aggregated as well
assert first_state_low["require"] == last_state_low["require"]
# Check if the "second packages" have been executed after "requirement"
# by checking their run numbers
assert (
running[first_key]["__run_num__"] < running[requirement_key]["__run_num__"]
), "Requirement should execute before second packages"
assert (
running[requirement_key]["__run_num__"] < running[second_key]["__run_num__"]
), "Second packages should execute after requirement"
# Further, we should verify that the "second packages" have "gc" only after "requirement" is complete
assert "gc" in running[second_key].get(
"pkgs", []
), "GC should be in second packages"
assert "drpm" in running[first_key].get(
"pkgs", []
), "DRPM should be in first packages"
def test_verify_onlyif_cmd_opts_exclude(minion_opts): def test_verify_onlyif_cmd_opts_exclude(minion_opts):