PakhomovAlexander commented on code in PR #2956:
URL: https://github.com/apache/ignite-3/pull/2956#discussion_r1427781298
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/ExecutionOptions.java:
##########
@@ -21,20 +21,28 @@
* Compute job execution options.
*/
public class ExecutionOptions {
- public static final ExecutionOptions DEFAULT = new ExecutionOptions(0);
+ public static final ExecutionOptions DEFAULT = new ExecutionOptions(0, 0);
Review Comment:
what do you think about introducing builder for this class? It looks like we
are going to add more fields here and massive constructors with some magic
numbers might be confusing.
##########
modules/compute/src/test/java/org/apache/ignite/internal/compute/executor/ComputeExecutorTest.java:
##########
@@ -114,4 +119,61 @@ public Integer execute(JobExecutionContext context,
Object... args) {
}
}
+ @Test
+ void retryJobFail() {
+ AtomicInteger runTimes = new AtomicInteger();
+
+ int maxRetries = 5;
+
+ JobExecution<Integer> execution = computeExecutor.executeJob(
+ new ExecutionOptions(0, maxRetries),
+ RetryJobFail.class,
+ new Object[]{runTimes}
+ );
+
+ await().until(execution::status, jobStatusWithState(FAILED));
+
+ assertThat(runTimes.get(), is(maxRetries + 1));
+ }
+
+ private static class RetryJobFail implements ComputeJob<Integer> {
+
+ @Override
+ public Integer execute(JobExecutionContext context, Object... args) {
+ AtomicInteger runTimes = (AtomicInteger) args[0];
+ runTimes.incrementAndGet();
+ throw new RuntimeException();
+ }
+ }
+
+ @Test
+ void retryJobSuccess() {
+ AtomicInteger runTimes = new AtomicInteger();
+
+ int maxRetries = 5;
+
+ JobExecution<Integer> execution = computeExecutor.executeJob(
+ new ExecutionOptions(0, maxRetries),
+ RetryJobSuccess.class,
+ new Object[]{runTimes, maxRetries}
+ );
+
+ await().until(execution::status, jobStatusWithState(COMPLETED));
+
+ assertThat(runTimes.get(), is(maxRetries + 1));
+ }
Review Comment:
Now it can be overtesting but in the future, this test can prevent tricky
bugs. I am talking about checking the happy path when the job just passes and
it is executed exactly once.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]