Skip to content

Commit 4d85c66

Browse files
committed
Fix test_13 and test_14 merge verification
- test_13 now asserts that PC state is 'merged' or 'closed' after merge - Previously only logged warning but didn't fail if merge didn't complete - test_14 wait time increased from 5 to 10 seconds for data propagation - Improved logging to diagnose merge issues
1 parent 006c856 commit 4d85c66

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

tests/integration/test_workflow.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -487,17 +487,25 @@ def test_13_merge_proposed_change(
487487
for log_entry in task.logs[:10]: # Show first 10 log entries
488488
logging.info(" %s", log_entry)
489489

490-
# The merge task can fail due to check failures even if the merge completes.
491-
# test_14 will verify that the data actually made it to main.
492-
if task.state != TaskState.COMPLETED:
493-
logging.warning(
494-
"Merge task %s finished with state %s, "
495-
"but will verify merge succeeded in next test",
496-
task.id,
497-
task.state,
498-
)
499-
else:
500-
logging.info("Proposed change merged successfully")
490+
# Verify the merge completed successfully
491+
# Check the PC state rather than just the task state, as the PC state
492+
# is the authoritative source for whether the merge succeeded
493+
pc_after_merge = client_main.get(
494+
"CoreProposedChange",
495+
name__value=f"Add Arista DC - Test {default_branch}",
496+
)
497+
498+
pc_state = pc_after_merge.state.value if hasattr(pc_after_merge.state, 'value') else pc_after_merge.state
499+
logging.info("Proposed change state after merge: %s", pc_state)
500+
501+
# The PC should be in 'merged' or 'closed' state if merge succeeded
502+
assert pc_state in ['merged', 'closed'], (
503+
f"Merge did not complete successfully. "
504+
f"Task state: {task.state}, PC state: {pc_state}. "
505+
f"Check task logs above for details."
506+
)
507+
508+
logging.info("Proposed change merged successfully")
501509

502510
async def test_14_verify_merge_to_main(
503511
self, async_client_main: InfrahubClient
@@ -508,9 +516,10 @@ async def test_14_verify_merge_to_main(
508516
client = async_client_main
509517
client.default_branch = "main"
510518

511-
# Add a small delay to allow for data propagation after merge
512-
logging.info("Waiting 5 seconds for data propagation...")
513-
time.sleep(5)
519+
# Add a delay to allow for data propagation after merge
520+
# Infrahub needs time to propagate merged data across the system
521+
logging.info("Waiting 10 seconds for merge data propagation...")
522+
time.sleep(10)
514523

515524
# Try to get dc-arista from main branch
516525
try:

0 commit comments

Comments
 (0)