Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
import java.util.stream.Collectors;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.services.sqs.SqsAsyncClient;
import software.amazon.awssdk.testutils.retry.RetryableTest;


/**
Expand Down Expand Up @@ -84,7 +84,7 @@
/**
* Test runs heavy load and expects average batch sizes to be close to max.
*/
@Test
@RetryableTest(maxRetries = 3)
void sendMessage_whenHighLoadScenario_shouldEfficientlyBatchMessages() throws Exception {
int expectedBatchSize = 25; // more than double the actual max of 10
int rateLimit = 1000 / SEND_FREQUENCY_MILLIS * expectedBatchSize;
Expand Down Expand Up @@ -126,7 +126,7 @@
/**
* Test runs a load that should cause an average batch size of 5.
*/
@Test
@RetryableTest(maxRetries = 3)
void sendMessage_whenMediumLoadScenario_shouldCreateHalfSizeBatches() throws Exception {
int expectedBatchSize = 5;
int rateLimit = 1000 / SEND_FREQUENCY_MILLIS * expectedBatchSize;
Expand Down Expand Up @@ -157,7 +157,7 @@
.isLessThan(messageCount / 3d);
}

@Test
@RetryableTest(maxRetries = 3)
void sendMessage_whenLowLoadScenario_shouldCreateSmallBatches() throws Exception {
int expectedBatchSize = 1;
int rateLimit = 1000 / SEND_FREQUENCY_MILLIS * expectedBatchSize;
Expand Down Expand Up @@ -217,5 +217,8 @@

executor.shutdown();
executor.awaitTermination(10, TimeUnit.SECONDS);

// Wait for batch manager to flush all pending batches
Thread.sleep(SEND_FREQUENCY_MILLIS * 3);

Check warning on line 222 in services/sqs/src/test/java/software/amazon/awssdk/services/sqs/batchmanager/BatchingEfficiencyUnderLoadTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this use of "Thread.sleep()".

See more on https://sonarcloud.io/project/issues?id=aws_aws-sdk-java-v2&issues=AZri1O3CFmD0c8YG6Wqn&open=AZri1O3CFmD0c8YG6Wqn&pullRequest=6609
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import java.net.URI;
import java.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.core.exception.ApiCallAttemptTimeoutException;
import software.amazon.awssdk.core.exception.ApiCallTimeoutException;
import software.amazon.awssdk.http.crt.AwsCrtHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonClient;
import software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonClientBuilder;
import software.amazon.awssdk.testutils.retry.RetryableTest;

@WireMockTest
public class CrtHttpClientApiCallTimeoutTest {
Expand All @@ -49,7 +49,7 @@ public void setup(WireMockRuntimeInfo wiremock) {
.credentialsProvider(() -> AwsBasicCredentials.create("akid", "skid"));
}

@Test
@RetryableTest(maxRetries = 3)
void apiCallAttemptExceeded_shouldThrowApiCallAttemptTimeoutException() {
stubFor(any(anyUrl()).willReturn(aResponse().withStatus(200).withBody("{}").withFixedDelay(2000)));
try (ProtocolRestJsonClient client =
Expand All @@ -61,7 +61,7 @@ void apiCallAttemptExceeded_shouldThrowApiCallAttemptTimeoutException() {
}
}

@Test
@RetryableTest(maxRetries = 3)
void apiCallExceeded_shouldThrowApiCallAttemptTimeoutException() {
stubFor(any(anyUrl()).willReturn(aResponse().withStatus(200).withBody("{}").withFixedDelay(2000)));
try (ProtocolRestJsonClient client = clientBuilder.overrideConfiguration(b -> b.apiCallTimeout(Duration.ofMillis(10)))
Expand Down
Loading