Skip to content

Automation tests — run lifecycle (trigger, cancel, history) #2799

Description

@stelbailey

What

Integration tests for triggering automation runs, cancelling them, and querying run history. These tests involve async execution — TriggerAutomationReactor returns a run ID immediately and execution happens in the background.

Depends on

#2797 (AutomationTestUtils, including waitForRunCompletion)

Files to create

test/prerna/testing/automation/
  TriggerAutomationReactorTests.java
  CancelAutomationRunReactorTests.java
  AutomationRunHistoryTests.java

Test cases

TriggerAutomationReactorTests

  • testTriggerReturnsRunIdImmediately — trigger → response has runId + RUNNING or QUEUED status
  • testTriggerCreatesRunRecord — trigger, wait for completion → getAutomationRun returns full record with timestamps
  • testTriggerMinimalAutomation — automation with only a trigger node (no action nodes) → completes with COMPLETED status
  • testTriggerUnknownAutomationIdThrows — random UUID → error

CancelAutomationRunReactorTests

  • testCancelRunWhileRunning — trigger a slow automation (wait node with short delay), immediately cancel → run ends with CANCELLED status
  • testCancelAlreadyCompletedRunThrows — complete a run first, then try to cancel → error
  • testCancelUnknownRunIdThrows — random UUID → error

AutomationRunHistoryTests

  • testListRunsEmptyBeforeAnyTrigger — fresh automation → empty run list
  • testListRunsReturnsAllRuns — trigger 3 times, wait for each → list returns 3 records
  • testGetRunReturnsCorrectStatus — trigger, wait for completion → status is COMPLETED, has start/end timestamps
  • testGetRunReturnsNodeOutputs — trigger automation with a DB engine node, wait → getAutomationNodeOutputs returns output for that node
  • testGetRunUnknownIdThrows — random UUID → error

Async handling note

TriggerAutomationReactor submits work to the execution backend and returns immediately. Tests that need to assert on a completed run must use AutomationTestUtils.waitForRunCompletion(automationId, runId, 30) to poll until the run reaches a terminal state.

Important: the polling approach here is independent of the execution backend decision (Temporal vs Quartz). waitForRunCompletion only reads the AUTOMATION_RUNS DB table — whichever backend updates that table on completion, the polling works the same way. No changes to these tests should be needed after #2790 is resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions