Closed
Description
I'm using TestContainers to run localstack in Java. Here is some pseudo code of what I am doing :
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {Application.class, Properties.class}, webEnvironment =
SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SomeClass {
@ClassRule
public static LocalStackContainer localstack = new LocalStackContainer()
.withServices(LocalStackContainer.Service.KINESIS).withServices(LocalStackContainer.Service.S3);
@BeforeClass
public static void beforeClass() throws InterruptedException, IOException {
localKinesisClient = AmazonKinesisClientBuilder.standard()
.withEndpointConfiguration(localstack.getEndpointConfiguration(LocalStackContainer.Service.KINESIS))
.withCredentials(localstack.getDefaultCredentialsProvider()).build();
s3Client = AmazonS3Client.builder().withEndpointConfiguration(localstack.getEndpointConfiguration(LocalStackContainer.Service.S3))
.withCredentials(localstack.getDefaultCredentialsProvider()).build();
new AWSXRay().beginDummySegment();
environmentVariables.set("AWS_CBOR_DISABLE", "1");
CreateStreamRequest createStreamRequest = new CreateStreamRequest();
logger.info("Create Stream");
try {
localKinesisClient.createStream(createStreamRequest.withStreamName(streamName).withShardCount(1));
} catch (ResourceInUseException exception) {
logger.info("Stream: " + streamName + "already exists.");
}
s3Client.createBucket(s3BucketName);
//Fails on this line when trying to insert a file of size 1MB
s3Client.putObject(s3BucketName,"file",getFileContentsAsString("src/test/resources/largetextfield1mb.txt"));
environmentVariables.set("KINESIS_URL", localstack.getEndpointConfiguration(LocalStackContainer.Service.KINESIS).getServiceEndpoint());
environmentVariables.set("KINESIS_REGION", localstack.getEndpointConfiguration(LocalStackContainer.Service.KINESIS).getSigningRegion());
environmentVariables.set("S3_URL", localstack.getEndpointConfiguration(LocalStackContainer.Service.S3).getServiceEndpoint());
environmentVariables.set("S3_REGION", localstack.getEndpointConfiguration(LocalStackContainer.Service.S3).getSigningRegion());
System.getenv("KINESIS_URL");
System.getenv("S3_URL");
Thread.sleep(500);
}
}
I get the following error :
Method threw 'com.amazonaws.SdkClientException' exception.
Unable to execute HTTP request: Read timed out
The above code works when I try saving something simple like a word; e.g. "someWord" but fails when I use the 1mb string. Anyway to fix this? This is my current disk set up for docker :