|
@@ -43,8 +43,12 @@ public class TestSlidingWindowRetryPolicy {
|
|
public void testNeverRetry() {
|
|
public void testNeverRetry() {
|
|
ContainerRetryContext retryContext =
|
|
ContainerRetryContext retryContext =
|
|
ContainerRetryContext.NEVER_RETRY_CONTEXT;
|
|
ContainerRetryContext.NEVER_RETRY_CONTEXT;
|
|
- Assert.assertFalse("never retry", retryPolicy.shouldRetry(
|
|
|
|
- new SlidingWindowRetryPolicy.RetryContext(retryContext), 12));
|
|
|
|
|
|
+ SlidingWindowRetryPolicy.RetryContext windowContext = new
|
|
|
|
+ SlidingWindowRetryPolicy.RetryContext(retryContext);
|
|
|
|
+ Assert.assertFalse("never retry", retryPolicy.shouldRetry(windowContext,
|
|
|
|
+ 12));
|
|
|
|
+ Assert.assertEquals("remaining retries", 0,
|
|
|
|
+ windowContext.getRemainingRetries());
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -52,8 +56,13 @@ public class TestSlidingWindowRetryPolicy {
|
|
ContainerRetryContext retryContext = ContainerRetryContext.newInstance(
|
|
ContainerRetryContext retryContext = ContainerRetryContext.newInstance(
|
|
ContainerRetryPolicy.RETRY_ON_ALL_ERRORS, null, -1,
|
|
ContainerRetryPolicy.RETRY_ON_ALL_ERRORS, null, -1,
|
|
0, 10);
|
|
0, 10);
|
|
- Assert.assertTrue("always retry", retryPolicy.shouldRetry(
|
|
|
|
- new SlidingWindowRetryPolicy.RetryContext(retryContext), 12));
|
|
|
|
|
|
+ SlidingWindowRetryPolicy.RetryContext windowContext = new
|
|
|
|
+ SlidingWindowRetryPolicy.RetryContext(retryContext);
|
|
|
|
+ Assert.assertTrue("always retry", retryPolicy.shouldRetry(windowContext,
|
|
|
|
+ 12));
|
|
|
|
+ Assert.assertEquals("remaining retries",
|
|
|
|
+ ContainerRetryContext.RETRY_FOREVER,
|
|
|
|
+ windowContext.getRemainingRetries());
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -65,19 +74,28 @@ public class TestSlidingWindowRetryPolicy {
|
|
Assert.assertTrue("retry 1",
|
|
Assert.assertTrue("retry 1",
|
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
|
retryPolicy.updateRetryContext(windowRetryContext);
|
|
retryPolicy.updateRetryContext(windowRetryContext);
|
|
|
|
+ Assert.assertEquals("remaining retries", 1,
|
|
|
|
+ windowRetryContext.getRemainingRetries());
|
|
|
|
|
|
clock.setTime(20);
|
|
clock.setTime(20);
|
|
Assert.assertTrue("retry 2",
|
|
Assert.assertTrue("retry 2",
|
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
|
retryPolicy.updateRetryContext(windowRetryContext);
|
|
retryPolicy.updateRetryContext(windowRetryContext);
|
|
|
|
+ Assert.assertEquals("remaining retries", 1,
|
|
|
|
+ windowRetryContext.getRemainingRetries());
|
|
|
|
|
|
clock.setTime(40);
|
|
clock.setTime(40);
|
|
Assert.assertTrue("retry 3",
|
|
Assert.assertTrue("retry 3",
|
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
|
retryPolicy.updateRetryContext(windowRetryContext);
|
|
retryPolicy.updateRetryContext(windowRetryContext);
|
|
|
|
+ Assert.assertEquals("remaining retries", 1,
|
|
|
|
+ windowRetryContext.getRemainingRetries());
|
|
|
|
|
|
clock.setTime(45);
|
|
clock.setTime(45);
|
|
Assert.assertFalse("retry failed",
|
|
Assert.assertFalse("retry failed",
|
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
|
retryPolicy.shouldRetry(windowRetryContext, 12));
|
|
|
|
+ retryPolicy.updateRetryContext(windowRetryContext);
|
|
|
|
+ Assert.assertEquals("remaining retries", 0,
|
|
|
|
+ windowRetryContext.getRemainingRetries());
|
|
}
|
|
}
|
|
}
|
|
}
|