Skip to content

Commit

Permalink
Updated the e2e test
Browse files Browse the repository at this point in the history
* Create a Parent Activity, which will be used to spawn children 2 levels deep. This allows for the error message to have a more detail stacktrace
* Look for the stacktrace and effected activity within the error message.
  • Loading branch information
goetzrrGit committed Jul 25, 2024
1 parent b271a19 commit 521edac
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,9 @@ void directiveIdIncluded() throws IOException {

// The error includes the directive id that was executing
assertTrue(exception.containsKey("executingDirectiveId"));
assertTrue(exception.containsKey("executingActivityType"));
assertEquals(dirId, exception.getInt("executingDirectiveId"));
assertEquals("DaemonCheckerActivity", exception.getString("executingActivityType"));

// The error message is correct
assertEquals("Minutes elapsed is incorrect. TimeTrackerDaemon may have stopped.\n\tExpected: 1 Actual: 59",
Expand All @@ -496,7 +498,7 @@ void directiveIdOnDescendant() throws IOException {
// Setup: Insert a directive that will throw
int dirId = hasura.insertActivity(
fooPlan,
"DaemonCheckerSpawner",
"DaemonTaskActivity",
"01:00:00",
Json.createObjectBuilder().add("minutesElapsed", 1).add("spawnDelay", 1).build());

Expand All @@ -514,6 +516,13 @@ void directiveIdOnDescendant() throws IOException {
// The error includes the directive id that was executing
assertTrue(exception.containsKey("executingDirectiveId"));
assertEquals(dirId, exception.getInt("executingDirectiveId"));
assertTrue(exception.containsKey("executingActivityType"));
assertEquals(dirId, exception.getInt("executingDirectiveId"));
assertEquals("DaemonTaskActivity", exception.getString("executingActivityType"));
assertTrue(exception.containsKey("activityStackTrace"));
assertEquals("DaemonTaskActivity\n"
+ "|-DaemonCheckerSpawner\n"
+ "|--DaemonCheckerActivity", exception.getString("activityStackTrace"));

// The error message is correct
assertEquals("Minutes elapsed is incorrect. TimeTrackerDaemon may have stopped.\n\tExpected: 1 Actual: 60",
Expand Down Expand Up @@ -551,8 +560,11 @@ void noDirectiveIdOnDaemon() throws IOException {

final var exception = reason.data();

// The error does not include any directive ids
// The error does not include any directive ids,
// executingActivityType, and activityStackTrace
assertFalse(exception.containsKey("executingDirectiveId"));
assertFalse(exception.containsKey("executingActivityType"));
assertFalse(exception.containsKey("activityStackTrace"));

// The error message is correct
assertEquals("Daemon task exception raised.", reason.message());
Expand Down Expand Up @@ -596,6 +608,8 @@ void noDirectiveIdDaemonMidDirective() throws IOException {

// The error does not include any directive ids
assertFalse(exception.containsKey("executingDirectiveId"));
assertFalse(exception.containsKey("executingActivityType"));
assertFalse(exception.containsKey("activityStackTrace"));

// The error message is correct
assertEquals("Daemon task exception raised.", reason.message());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package gov.nasa.jpl.aerie.foomissionmodel.activities;

import gov.nasa.jpl.aerie.foomissionmodel.Mission;
import gov.nasa.jpl.aerie.merlin.framework.annotations.ActivityType;
import gov.nasa.jpl.aerie.merlin.protocol.types.Duration;

import static gov.nasa.jpl.aerie.foomissionmodel.generated.ActivityActions.call;
import static gov.nasa.jpl.aerie.merlin.framework.ModelActions.delay;

/**
* An activity that spawns a DaemonCheckerSpawner which spawns a DaemonCheckerActivity after delaying.
* Useful for testing the behavior of exceptions thrown by child activities and the stack trace back
* to this activity.
*
* @param minutesElapsed The expected number of minutes elapsed when the DaemonCheckerActivity begins
* @param spawnDelay The number of minutes to delay between the start of this activity and spawning the DaemonCheckerActivity
*/
@ActivityType("DaemonTaskActivity")
public record DaemonTaskActivity(int minutesElapsed, int spawnDelay) {
@ActivityType.EffectModel
public void run(final Mission mission) {
delay(Duration.of(spawnDelay, Duration.MINUTE));
call(mission, new DaemonCheckerSpawner(minutesElapsed,spawnDelay));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@WithActivityType(ZeroDurationUncontrollableActivity.class)
@WithActivityType(DaemonCheckerActivity.class)
@WithActivityType(DaemonCheckerSpawner.class)
@WithActivityType(DaemonTaskActivity.class)

@WithActivityType(DecompositionTestActivities.ParentActivity.class)
@WithActivityType(DecompositionTestActivities.ChildActivity.class)
Expand All @@ -30,6 +31,7 @@
import gov.nasa.jpl.aerie.foomissionmodel.activities.ControllableDurationActivity;
import gov.nasa.jpl.aerie.foomissionmodel.activities.DaemonCheckerActivity;
import gov.nasa.jpl.aerie.foomissionmodel.activities.DaemonCheckerSpawner;
import gov.nasa.jpl.aerie.foomissionmodel.activities.DaemonTaskActivity;
import gov.nasa.jpl.aerie.foomissionmodel.activities.DecompositionTestActivities;
import gov.nasa.jpl.aerie.foomissionmodel.activities.FooActivity;
import gov.nasa.jpl.aerie.foomissionmodel.activities.LateRiserActivity;
Expand Down

0 comments on commit 521edac

Please sign in to comment.