-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
88 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH | ||
// | ||
// This file is part of the Restate SDK Test suite tool, | ||
// which is released under the MIT license. | ||
// | ||
// You can find a copy of the license in file LICENSE in the root | ||
// directory of this repository or package, or at | ||
// https://github.com/restatedev/sdk-test-suite/blob/main/LICENSE | ||
package dev.restate.sdktesting.tests | ||
|
||
import dev.restate.sdk.client.Client | ||
import dev.restate.sdktesting.contracts.FailingClient | ||
import dev.restate.sdktesting.contracts.FailingDefinitions | ||
import dev.restate.sdktesting.infra.InjectClient | ||
import dev.restate.sdktesting.infra.RestateDeployerExtension | ||
import dev.restate.sdktesting.infra.ServiceSpec | ||
import java.util.* | ||
import kotlinx.coroutines.test.runTest | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.DisplayName | ||
import org.junit.jupiter.api.Tag | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.RegisterExtension | ||
import org.junit.jupiter.api.parallel.Execution | ||
import org.junit.jupiter.api.parallel.ExecutionMode | ||
|
||
@Tag("always-suspending") | ||
class RunRetry { | ||
companion object { | ||
@RegisterExtension | ||
val deployerExt: RestateDeployerExtension = RestateDeployerExtension { | ||
withServiceSpec(ServiceSpec.defaultBuilder().withServices(FailingDefinitions.SERVICE_NAME)) | ||
} | ||
} | ||
|
||
@DisplayName("Run is retried until it succeeds") | ||
@Test | ||
@Execution(ExecutionMode.CONCURRENT) | ||
fun withSuccess(@InjectClient ingressClient: Client) = runTest { | ||
val attempts = 3 | ||
|
||
assertThat( | ||
FailingClient.fromClient(ingressClient, UUID.randomUUID().toString()) | ||
.sideEffectSucceedsAfterGivenAttempts(attempts)) | ||
.isGreaterThanOrEqualTo(attempts) | ||
} | ||
|
||
@DisplayName("Run is retried until it exhausts the retry attempts") | ||
@Test | ||
@Execution(ExecutionMode.CONCURRENT) | ||
fun withExhaustedAttempts(@InjectClient ingressClient: Client) = runTest { | ||
val attempts = 3 | ||
|
||
assertThat( | ||
FailingClient.fromClient(ingressClient, UUID.randomUUID().toString()) | ||
.sideEffectFailsAfterGivenAttempts(attempts)) | ||
.isGreaterThanOrEqualTo(attempts) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters