mirror of https://github.com/dapr/java-sdk.git
fix flaky integration test SdkResiliencytIT (#960)
* fix flaky integration test SdkResiliencytIT Signed-off-by: MregXN <mregxn@gmail.com> * Update sdk-tests/src/test/java/io/dapr/it/resiliency/SdkResiliencytIT.java Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Signed-off-by: MregXN <46479059+MregXN@users.noreply.github.com> * Update sdk-tests/src/test/java/io/dapr/it/resiliency/SdkResiliencytIT.java Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Signed-off-by: MregXN <46479059+MregXN@users.noreply.github.com> * Update sdk-tests/src/test/java/io/dapr/it/resiliency/SdkResiliencytIT.java Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Signed-off-by: MregXN <46479059+MregXN@users.noreply.github.com> --------- Signed-off-by: MregXN <mregxn@gmail.com> Signed-off-by: MregXN <46479059+MregXN@users.noreply.github.com> Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Co-authored-by: Artur Souza <artursouza.ms@outlook.com>
This commit is contained in:
parent
da395f8dac
commit
4ef96e19f4
|
@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
*/
|
||||
public class SdkResiliencytIT extends BaseIT {
|
||||
|
||||
private static final int NUM_ITERATIONS = 30;
|
||||
private static final int NUM_ITERATIONS = 35;
|
||||
|
||||
private static final Duration TIMEOUT = Duration.ofMillis(100);
|
||||
|
||||
|
@ -116,6 +116,8 @@ public class SdkResiliencytIT extends BaseIT {
|
|||
public void retryAndTimeout() {
|
||||
AtomicInteger toxiClientErrorCount = new AtomicInteger();
|
||||
AtomicInteger retryOneClientErrorCount = new AtomicInteger();
|
||||
|
||||
while (true){
|
||||
for (int i = 0; i < NUM_ITERATIONS; i++) {
|
||||
String key = randomStateKeyPrefix + "_" + i;
|
||||
String value = Base64.getEncoder().encodeToString(key.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -139,13 +141,18 @@ public class SdkResiliencytIT extends BaseIT {
|
|||
assertEquals(value, savedValue);
|
||||
}
|
||||
|
||||
// Asserts that we had at least one success per client.
|
||||
assertTrue(toxiClientErrorCount.get() < NUM_ITERATIONS);
|
||||
assertTrue(retryOneClientErrorCount.get() < NUM_ITERATIONS);
|
||||
// We should have at least one success per client, otherwise retry.
|
||||
if(toxiClientErrorCount.get() < NUM_ITERATIONS && retryOneClientErrorCount.get() < NUM_ITERATIONS){
|
||||
// This assertion makes sure that toxicity is on
|
||||
assertTrue(toxiClientErrorCount.get() > 0);
|
||||
assertTrue(retryOneClientErrorCount.get() > 0);
|
||||
// A client without retries should have more errors than a client with one retry.
|
||||
assertTrue(toxiClientErrorCount.get() > retryOneClientErrorCount.get());
|
||||
break;
|
||||
}
|
||||
toxiClientErrorCount.set(0);
|
||||
retryOneClientErrorCount.set(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue