44
55import static org .junit .jupiter .api .Assertions .*;
66
7+ import java .time .Duration ;
78import java .util .concurrent .atomic .AtomicInteger ;
89import org .junit .jupiter .api .Test ;
910import software .amazon .lambda .durable .config .StepConfig ;
@@ -157,7 +158,7 @@ void testAtLeastOnceReExecutesAfterCheckpointFailure() {
157158 }
158159
159160 @ Test
160- void testAtMostOnceThrowsExceptionAfterCheckpointFailure () {
161+ void testAtMostOnceNoRetryFailsAfterCheckpointFailure () {
161162 var executionCount = new AtomicInteger (0 );
162163
163164 var runner = LocalDurableTestRunner .create (String .class , (input , context ) -> {
@@ -170,6 +171,7 @@ void testAtMostOnceThrowsExceptionAfterCheckpointFailure() {
170171 },
171172 StepConfig .builder ()
172173 .semantics (StepSemantics .AT_MOST_ONCE_PER_RETRY )
174+ .retryStrategy (RetryStrategies .Presets .NO_RETRY )
173175 .build ());
174176 });
175177
@@ -183,4 +185,33 @@ void testAtMostOnceThrowsExceptionAfterCheckpointFailure() {
183185 assertEquals (ExecutionStatus .FAILED , result .getStatus ());
184186 assertEquals (1 , executionCount .get ());
185187 }
188+
189+ @ Test
190+ void testAtMostOnceRetriesAfterCheckpointFailure () {
191+ var executionCount = new AtomicInteger (0 );
192+
193+ var runner = LocalDurableTestRunner .create (String .class , (input , context ) -> {
194+ return context .step (
195+ "step" ,
196+ String .class ,
197+ stepCtx -> {
198+ var count = executionCount .incrementAndGet ();
199+ return "Executed " + count + " times" ;
200+ },
201+ StepConfig .builder ()
202+ .semantics (StepSemantics .AT_MOST_ONCE_PER_RETRY )
203+ .retryStrategy (RetryStrategies .fixedDelay (3 , Duration .ofSeconds (1 )))
204+ .build ());
205+ });
206+
207+ runner .run ("test" );
208+ assertEquals (1 , executionCount .get ());
209+
210+ runner .resetCheckpointToStarted ("step" );
211+ var result = runner .runUntilComplete ("test" );
212+
213+ assertEquals (ExecutionStatus .SUCCEEDED , result .getStatus ());
214+ assertEquals (2 , executionCount .get ());
215+ assertEquals ("Executed 2 times" , result .getResult (String .class ));
216+ }
186217}
0 commit comments