Skip to content

Commit 08ad29d

Browse files
authored
Fix flaky tests (aws#2689)
1 parent 6d4a884 commit 08ad29d

File tree

3 files changed

+27
-66
lines changed

3 files changed

+27
-66
lines changed

services/route53/src/it/java/software/amazon/awssdk/services/route53/IntegrationTestBase.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

services/route53/src/it/java/software/amazon/awssdk/services/route53/Route53IntegrationTest.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.List;
2424
import java.util.UUID;
2525
import org.junit.AfterClass;
26+
import org.junit.BeforeClass;
2627
import org.junit.Test;
2728
import software.amazon.awssdk.awscore.exception.AwsServiceException;
2829
import software.amazon.awssdk.core.SdkGlobalTime;
@@ -55,12 +56,13 @@
5556
import software.amazon.awssdk.services.route53.model.RRType;
5657
import software.amazon.awssdk.services.route53.model.ResourceRecord;
5758
import software.amazon.awssdk.services.route53.model.ResourceRecordSet;
59+
import software.amazon.awssdk.testutils.service.AwsIntegrationTestBase;
5860

5961
/**
6062
* Integration tests that run through the various operations available in the
6163
* Route 53 API.
6264
*/
63-
public class Route53IntegrationTest extends IntegrationTestBase {
65+
public class Route53IntegrationTest extends AwsIntegrationTestBase {
6466

6567
private static final String COMMENT = "comment";
6668
private static final String ZONE_NAME = "java.sdk.com.";
@@ -69,6 +71,8 @@ public class Route53IntegrationTest extends IntegrationTestBase {
6971
private static final String TYPE = "TCP";
7072
private static final String IP_ADDRESS = "12.12.12.12";
7173

74+
private static Route53Client route53;
75+
7276
/**
7377
* The ID of the zone we created in this test.
7478
*/
@@ -77,13 +81,30 @@ public class Route53IntegrationTest extends IntegrationTestBase {
7781
/**
7882
* The ID of the change that created our test zone.
7983
*/
80-
private String createdZoneChangeId;
84+
private static String createdZoneChangeId;
8185

8286
/**
8387
* the ID of the health check.
8488
*/
8589
private String healthCheckId;
8690

91+
@BeforeClass
92+
public static void setup() {
93+
route53 = Route53Client.builder()
94+
.credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
95+
.region(Region.AWS_GLOBAL)
96+
.build();
97+
// Create Hosted Zone
98+
CreateHostedZoneResponse result = route53.createHostedZone(CreateHostedZoneRequest.builder()
99+
.name(ZONE_NAME)
100+
.callerReference(CALLER_REFERENCE)
101+
.hostedZoneConfig(HostedZoneConfig.builder()
102+
.comment(COMMENT).build()).build()
103+
);
104+
105+
createdZoneId = result.hostedZone().id();
106+
createdZoneChangeId = result.changeInfo().id();
107+
}
87108

88109
/**
89110
* Ensures the HostedZone we create during this test is correctly released.
@@ -103,22 +124,6 @@ public static void tearDown() {
103124
*/
104125
@Test
105126
public void testRoute53() throws Exception {
106-
// Create Hosted Zone
107-
CreateHostedZoneResponse result = route53.createHostedZone(CreateHostedZoneRequest.builder()
108-
.name(ZONE_NAME)
109-
.callerReference(CALLER_REFERENCE)
110-
.hostedZoneConfig(HostedZoneConfig.builder()
111-
.comment(COMMENT).build()).build()
112-
);
113-
114-
createdZoneId = result.hostedZone().id();
115-
createdZoneChangeId = result.changeInfo().id();
116-
117-
assertValidCreatedHostedZone(result.hostedZone());
118-
assertValidDelegationSet(result.delegationSet());
119-
assertValidChangeInfo(result.changeInfo());
120-
assertNotNull(result.location());
121-
122127

123128
// Get Hosted Zone
124129
GetHostedZoneRequest hostedZoneRequest = GetHostedZoneRequest.builder().id(createdZoneId).build();

services/s3control/src/test/java/software/amazon/awssdk/services/s3control/internal/functionaltests/signing/UrlEncodingTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.github.tomakehurst.wiremock.client.WireMock.get;
2020
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
2121
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
22+
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
2223
import static org.assertj.core.api.Assertions.assertThat;
2324

2425
import java.net.URI;
@@ -37,17 +38,17 @@
3738

3839

3940
public class UrlEncodingTest {
40-
private static final URI HTTP_LOCALHOST_URI = URI.create("http://localhost:8080/");
4141
private static final String EXPECTED_URL = "/v20180820/jobs/id";
4242

4343
private S3ControlClient s3Control;
4444
private ExecutionAttributeInterceptor interceptor;
4545

4646
@Rule
47-
public WireMockRule mockServer = new WireMockRule();
47+
public WireMockRule mockServer = new WireMockRule(0);
4848

4949
protected S3ControlClient buildClient() {
50-
this.interceptor = new ExecutionAttributeInterceptor(HTTP_LOCALHOST_URI);
50+
URI uri = URI.create("http://localhost:" + mockServer.port());
51+
this.interceptor = new ExecutionAttributeInterceptor(uri);
5152

5253
return S3ControlClient.builder()
5354
.credentialsProvider(() -> AwsBasicCredentials.create("test", "test"))

0 commit comments

Comments
 (0)