Skip to content

Commit d17d35f

Browse files
committed
Cleaning up integration tests
1 parent 77d7006 commit d17d35f

File tree

2 files changed

+25
-53
lines changed

2 files changed

+25
-53
lines changed

services/s3/src/it/java/software/amazon/awssdk/services/s3/BucketAccelerateIntegrationTest.java

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
import org.junit.BeforeClass;
2525
import org.junit.Ignore;
2626
import org.junit.Test;
27+
import software.amazon.awssdk.core.interceptor.Context;
28+
import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
29+
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
2730
import software.amazon.awssdk.core.sync.RequestBody;
2831
import software.amazon.awssdk.regions.Region;
2932
import software.amazon.awssdk.services.s3.model.AccelerateConfiguration;
@@ -49,10 +52,6 @@
4952
/**
5053
* Integration tests for S3 bucket accelerate configuration.
5154
*/
52-
// TODO: "These tests are a bit flaky. Looks like S3 returns 307 Temporary Redirect occasionally
53-
// for a newly accelerated bucket. Not sure what the right fix is without following redirects
54-
// which we don't want to do for other reasons.
55-
@Ignore
5655
public class BucketAccelerateIntegrationTest extends S3IntegrationTestBase {
5756

5857
private static final String US_BUCKET_NAME = temporaryBucketName("s3-accelerate-us-east-1");
@@ -70,6 +69,7 @@ public static void setup() throws Exception {
7069
.serviceConfiguration(S3Configuration.builder()
7170
.accelerateModeEnabled(true)
7271
.build())
72+
.overrideConfiguration(o -> o.addExecutionInterceptor(new AccelerateValidatingInterceptor()))
7373
.build();
7474

7575
setUpBuckets();
@@ -84,47 +84,6 @@ private static void setUpBuckets() {
8484
createBucket(US_BUCKET_NAME);
8585
}
8686

87-
@Test
88-
public void testControlPlaneOperationsUnderAccelerateMode() throws Exception {
89-
enableAccelerateOnBucket();
90-
91-
Tagging tags = Tagging.builder()
92-
.tagSet(Tag.builder()
93-
.key("foo")
94-
.value("bar")
95-
.build())
96-
.build();
97-
98-
accelerateClient.putBucketTagging(PutBucketTaggingRequest.builder().bucket(US_BUCKET_NAME).tagging(tags).build());
99-
accelerateClient.putBucketVersioning(PutBucketVersioningRequest.builder()
100-
.bucket(US_BUCKET_NAME)
101-
.versioningConfiguration(
102-
VersioningConfiguration.builder()
103-
.status("Enabled")
104-
.build())
105-
.build());
106-
107-
// Retry a couple of times due to eventual consistency
108-
RetryableAssertion.doRetryableAssert(new AssertCallable() {
109-
@Override
110-
public void doAssert() {
111-
List<Tag> taggingConfiguration = accelerateClient
112-
.getBucketTagging(GetBucketTaggingRequest.builder().bucket(US_BUCKET_NAME).build()).tagSet();
113-
114-
assertEquals("foo", taggingConfiguration.get(0).key());
115-
assertEquals("bar", taggingConfiguration.get(0).value());
116-
}
117-
}, new RetryableParams().withMaxAttempts(30).withDelayInMs(200));
118-
119-
assertEquals(BucketVersioningStatus.ENABLED,
120-
accelerateClient.getBucketVersioning(GetBucketVersioningRequest.builder()
121-
.bucket(US_BUCKET_NAME)
122-
.build())
123-
.status());
124-
125-
accelerateClient.deleteBucketTagging(DeleteBucketTaggingRequest.builder().bucket(US_BUCKET_NAME).build());
126-
}
127-
12887
@Test
12988
public void testUpdateAccelerateConfiguration() throws InterruptedException {
13089

@@ -166,11 +125,15 @@ public void testAccelerateEndpoint() throws Exception {
166125

167126
// PutObject
168127
File uploadFile = new RandomTempFile(KEY_NAME, 1000);
169-
accelerateClient.putObject(PutObjectRequest.builder()
170-
.bucket(US_BUCKET_NAME)
171-
.key(KEY_NAME)
172-
.build(),
173-
RequestBody.fromFile(uploadFile));
128+
try {
129+
accelerateClient.putObject(PutObjectRequest.builder()
130+
.bucket(US_BUCKET_NAME)
131+
.key(KEY_NAME)
132+
.build(),
133+
RequestBody.fromFile(uploadFile));
134+
} catch (Exception e) {
135+
// We really only need to verify the request is using the accelerate endpoint
136+
}
174137
}
175138

176139
private void enableAccelerateOnBucket() throws InterruptedException {
@@ -204,4 +167,14 @@ public void testUnsupportedOperationsUnderAccelerateMode() {
204167
//fail("Exception is not expected!");
205168
}
206169
}
170+
171+
private static final class AccelerateValidatingInterceptor implements ExecutionInterceptor {
172+
173+
@Override
174+
public void beforeTransmission(Context.BeforeTransmission context, ExecutionAttributes executionAttributes) {
175+
if (!(context.request() instanceof ListBucketsRequest)) {
176+
assertEquals(context.httpRequest().host(), US_BUCKET_NAME + ".s3-accelerate.amazonaws.com");
177+
}
178+
}
179+
}
207180
}

services/s3/src/it/java/software/amazon/awssdk/services/s3/UploadLargeObjectIntegrationTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import software.amazon.awssdk.testutils.RandomTempFile;
2929
import software.amazon.awssdk.utils.IoUtils;
3030

31-
@Ignore("The tests are intended to run manually as it can take a relatively long time")
3231
public class UploadLargeObjectIntegrationTest extends S3IntegrationTestBase {
3332

3433
private static final String BUCKET = temporaryBucketName(UploadLargeObjectIntegrationTest.class);
@@ -51,13 +50,13 @@ public static void tearDownFixture() {
5150
}
5251

5352
@Test
54-
public void syncPutLargeObject() throws Exception {
53+
public void syncPutLargeObject() {
5554
s3.putObject(b -> b.bucket(BUCKET).key(SYNC_KEY), file.toPath());
5655
verifyResponse(SYNC_KEY);
5756
}
5857

5958
@Test
60-
public void asyncPutLargeObject() throws Exception {
59+
public void asyncPutLargeObject() {
6160
s3Async.putObject(b -> b.bucket(BUCKET).key(ASYNC_KEY), file.toPath()).join();
6261
verifyResponse(ASYNC_KEY);
6362
}

0 commit comments

Comments
 (0)