Skip to content

Commit

Permalink
Increase execution time checking in HookStageExecutorTest (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpanchyk authored Sep 16, 2021
1 parent b7143b4 commit 36d9407
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ public void shouldExecuteEntrypointHooksHappyPath(TestContext context) {
.isEqualTo(HookId.of("module-alpha", "hook-a"));
assertThat(hookOutcome.getStatus()).isEqualTo(ExecutionStatus.success);
assertThat(hookOutcome.getAction()).isEqualTo(ExecutionAction.update);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 10L);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 20L);
});

assertThat(group0Hooks.get(1)).satisfies(hookOutcome -> {
assertThat(hookOutcome.getHookId())
.isEqualTo(HookId.of("module-beta", "hook-a"));
assertThat(hookOutcome.getStatus()).isEqualTo(ExecutionStatus.success);
assertThat(hookOutcome.getAction()).isEqualTo(ExecutionAction.update);
assertThat(hookOutcome.getExecutionTime()).isBetween(80L, 90L);
assertThat(hookOutcome.getExecutionTime()).isBetween(80L, 100L);
});

final List<HookExecutionOutcome> group1Hooks = groups.get(1).getHooks();
Expand All @@ -314,15 +314,15 @@ public void shouldExecuteEntrypointHooksHappyPath(TestContext context) {
.isEqualTo(HookId.of("module-beta", "hook-b"));
assertThat(hookOutcome.getStatus()).isEqualTo(ExecutionStatus.success);
assertThat(hookOutcome.getAction()).isEqualTo(ExecutionAction.update);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 10L);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 20L);
});

assertThat(group1Hooks.get(1)).satisfies(hookOutcome -> {
assertThat(hookOutcome.getHookId())
.isEqualTo(HookId.of("module-alpha", "hook-b"));
assertThat(hookOutcome.getStatus()).isEqualTo(ExecutionStatus.success);
assertThat(hookOutcome.getAction()).isEqualTo(ExecutionAction.update);
assertThat(hookOutcome.getExecutionTime()).isBetween(40L, 50L);
assertThat(hookOutcome.getExecutionTime()).isBetween(40L, 60L);
});
}));

Expand Down Expand Up @@ -467,7 +467,7 @@ public void shouldExecuteEntrypointHooksToleratingMisbehavingHooks(TestContext c
assertThat(hookOutcome.getStatus())
.isEqualTo(ExecutionStatus.invocation_failure);
assertThat(hookOutcome.getMessage()).isEqualTo("Action returned null");
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 10L);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 20L);
});

assertThat(group0Hooks.get(1)).satisfies(hookOutcome -> {
Expand All @@ -477,7 +477,7 @@ public void shouldExecuteEntrypointHooksToleratingMisbehavingHooks(TestContext c
.isEqualTo(ExecutionStatus.invocation_failure);
assertThat(hookOutcome.getMessage()).isEqualTo(
"java.lang.RuntimeException: I'm not allowed to throw exceptions");
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 10L);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 20L);
});

final List<HookExecutionOutcome> group1Hooks = groups.get(1).getHooks();
Expand All @@ -488,7 +488,7 @@ public void shouldExecuteEntrypointHooksToleratingMisbehavingHooks(TestContext c
.isEqualTo(HookId.of("module-beta", "hook-b"));
assertThat(hookOutcome.getStatus()).isEqualTo(ExecutionStatus.success);
assertThat(hookOutcome.getAction()).isEqualTo(ExecutionAction.update);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 10L);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 20L);
});

assertThat(group1Hooks.get(1)).satisfies(hookOutcome -> {
Expand All @@ -497,7 +497,7 @@ public void shouldExecuteEntrypointHooksToleratingMisbehavingHooks(TestContext c
assertThat(hookOutcome.getStatus())
.isEqualTo(ExecutionStatus.invocation_failure);
assertThat(hookOutcome.getMessage()).isEqualTo("Action returned null");
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 10L);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 20L);
});
}));

Expand Down Expand Up @@ -582,7 +582,7 @@ public void shouldExecuteEntrypointHooksToleratingTimeoutAndFailedFuture(TestCon
assertThat(hookOutcome.getStatus())
.isEqualTo(ExecutionStatus.execution_failure);
assertThat(hookOutcome.getMessage()).isEqualTo("Failed after a while");
assertThat(hookOutcome.getExecutionTime()).isBetween(50L, 60L);
assertThat(hookOutcome.getExecutionTime()).isBetween(50L, 70L);
});

assertThat(group0Hooks.get(1)).satisfies(hookOutcome -> {
Expand All @@ -591,7 +591,7 @@ public void shouldExecuteEntrypointHooksToleratingTimeoutAndFailedFuture(TestCon
assertThat(hookOutcome.getStatus()).isEqualTo(ExecutionStatus.timeout);
assertThat(hookOutcome.getMessage()).isEqualTo(
"Timed out while executing action");
assertThat(hookOutcome.getExecutionTime()).isBetween(200L, 210L);
assertThat(hookOutcome.getExecutionTime()).isBetween(200L, 220L);
});

final List<HookExecutionOutcome> group1Hooks = groups.get(1).getHooks();
Expand All @@ -602,7 +602,7 @@ public void shouldExecuteEntrypointHooksToleratingTimeoutAndFailedFuture(TestCon
.isEqualTo(HookId.of("module-beta", "hook-b"));
assertThat(hookOutcome.getStatus()).isEqualTo(ExecutionStatus.success);
assertThat(hookOutcome.getAction()).isEqualTo(ExecutionAction.update);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 10L);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 20L);
});

assertThat(group1Hooks.get(1)).satisfies(hookOutcome -> {
Expand All @@ -611,7 +611,7 @@ public void shouldExecuteEntrypointHooksToleratingTimeoutAndFailedFuture(TestCon
assertThat(hookOutcome.getStatus()).isEqualTo(ExecutionStatus.timeout);
assertThat(hookOutcome.getMessage()).isEqualTo(
"Timed out while executing action");
assertThat(hookOutcome.getExecutionTime()).isBetween(200L, 210L);
assertThat(hookOutcome.getExecutionTime()).isBetween(200L, 220L);
});
}));

Expand Down Expand Up @@ -1301,15 +1301,15 @@ public void shouldExecuteRawAuctionRequestHooksToleratingUnknownHookInAccountPla
.isEqualTo(ExecutionStatus.invocation_failure);
assertThat(hookOutcome.getMessage()).isEqualTo(
"Hook implementation does not exist or disabled");
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 10L);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 20L);
});

assertThat(group0Hooks.get(1)).satisfies(hookOutcome -> {
assertThat(hookOutcome.getHookId())
.isEqualTo(HookId.of("module-beta", "hook-a"));
assertThat(hookOutcome.getStatus()).isEqualTo(ExecutionStatus.success);
assertThat(hookOutcome.getAction()).isEqualTo(ExecutionAction.update);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 10L);
assertThat(hookOutcome.getExecutionTime()).isBetween(0L, 20L);
});
}));

Expand Down

0 comments on commit 36d9407

Please sign in to comment.