Skip to content

Commit

Permalink
AWS2 components have to set client.endpointOverride() to work on Loca…
Browse files Browse the repository at this point in the history
…lstack apache#2216
  • Loading branch information
ppalaga committed May 14, 2021
1 parent ef2ed10 commit e68feb9
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
package org.apache.camel.quarkus.component.aws2.cw.it;

import io.quarkus.test.junit.NativeImageTest;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

//TODO disabled because of https://github.com/apache/camel-quarkus/issues/2216
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+")
@NativeImageTest
class Aws2CwIT extends Aws2CwTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@
import org.awaitility.Awaitility;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.testcontainers.containers.localstack.LocalStackContainer.Service;
import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
import software.amazon.awssdk.services.cloudwatch.model.Datapoint;
import software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsRequest;
import software.amazon.awssdk.services.cloudwatch.model.Statistic;

//TODO disabled because of https://github.com/apache/camel-quarkus/issues/2216
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+")
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
class Aws2CwTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
package org.apache.camel.quarkus.component.aws2.ddb.it;

import io.quarkus.test.junit.NativeImageTest;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

@NativeImageTest
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+") // TODO https://github.com/apache/camel-quarkus/issues/2216
class Aws2DdbIT extends Aws2DdbTest {

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@
import org.hamcrest.Matchers;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+") // TODO
// https://github.com/apache/camel-quarkus/issues/2216
class Aws2DdbTest {

private static final Logger LOG = Logger.getLogger(Aws2DdbTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.quarkus.test.junit.NativeImageTest;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

//TODO disabled because of https://github.com/apache/camel-quarkus/issues/2216
//TODO disabled on Localstack, see https://github.com/apache/camel-quarkus/issues/2595
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+")
@NativeImageTest
class Aws2LambdaIT extends Aws2LambdaTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

//TODO disabled because of https://github.com/apache/camel-quarkus/issues/2216
//TODO disabled on Localstack, see https://github.com/apache/camel-quarkus/issues/2595
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+")
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
Expand Down Expand Up @@ -83,13 +83,30 @@ public void e2e() {
.statusCode(200)
.body("$", Matchers.hasItem(functionName));

RestAssured.given()
.contentType(ContentType.JSON)
.body("{ \"firstName\": \"" + name + "\"}")
.post("/aws2-lambda/invoke/" + functionName)
.then()
.statusCode(200)
.body("greetings", Matchers.is("Hello " + name));
/* Sometimes this does not succeed immediately */
Awaitility.await()
.pollDelay(200, TimeUnit.MILLISECONDS)
.pollInterval(500, TimeUnit.MILLISECONDS)
.atMost(120, TimeUnit.SECONDS)
.until(
() -> {
ExtractableResponse<?> response = RestAssured.given()
.contentType(ContentType.JSON)
.body("{ \"firstName\": \"" + name + "\"}")
.post("/aws2-lambda/invoke/" + functionName)
.then()
.extract();
System.out.println("Function " + functionName + " returned " + response.statusCode()
+ "; will retry until timeout");
switch (response.statusCode()) {
case 200:
final String greetings = response.jsonPath().getString("greetings");
return greetings;
default:
return null;
}
},
Matchers.is("Hello " + name));

RestAssured.given()
.delete("/aws2-lambda/delete/" + functionName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import io.quarkus.test.junit.NativeImageTest;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

//TODO disabled because of https://github.com/apache/camel-quarkus/issues/2216
/* Disabled on Localstack because Localstack does not send e-mails which we do assume in our tests
* See https://github.com/localstack/localstack/issues/339#issuecomment-341727758 */
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+")
@EnabledIfEnvironmentVariable(named = "MAILSLURP_API_KEY", matches = "[a-zA-Z0-9]+")
@NativeImageTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
import software.amazon.awssdk.services.ses.model.DeleteVerifiedEmailAddressRequest;
import software.amazon.awssdk.services.ses.model.VerifyEmailAddressRequest;

//TODO disabled because of https://github.com/apache/camel-quarkus/issues/2216
/* Disabled on Localstack because Localstack does not send e-mails which we do assume in our tests
* See https://github.com/localstack/localstack/issues/339#issuecomment-341727758 */
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+")
@EnabledIfEnvironmentVariable(named = "MAILSLURP_API_KEY", matches = "[a-zA-Z0-9]+")
@QuarkusTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
package org.apache.camel.quarkus.component.aws2.sqs.it;

import io.quarkus.test.junit.NativeImageTest;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

@NativeImageTest
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+") // TODO https://github.com/apache/camel-quarkus/issues/2216
class Aws2SqsSnsIT extends Aws2SqsSnsTest {

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

import static org.hamcrest.core.Is.is;

@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches = "[a-zA-Z0-9]+") // TODO
// https://github.com/apache/camel-quarkus/issues/2216
class Aws2SqsSnsTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,9 @@ public Aws2TestEnvContext(String accessKey, String secretKey, String region, Opt
properties.put("camel.component.aws2-" + s + ".secret-key", secretKey);
properties.put("camel.component.aws2-" + s + ".region", region);

switch (service) {
case S3:
case KINESIS:
case FIREHOSE:
properties.put("camel.component.aws2-" + s + ".override-endpoint", "true");
properties.put("camel.component.aws2-" + s + ".uri-endpoint-override",
ls.getEndpointOverride(service).toString());
break;
default:
// TODO https://github.com/apache/camel-quarkus/issues/2216
break;
}
properties.put("camel.component.aws2-" + s + ".override-endpoint", "true");
properties.put("camel.component.aws2-" + s + ".uri-endpoint-override",
ls.getEndpointOverride(service).toString());
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Map<String, String> start() {
.distinct()
.toArray(Service[]::new);

LocalStackContainer localstack = new LocalStackContainer(DockerImageName.parse("localstack/localstack:0.12.6"))
LocalStackContainer localstack = new LocalStackContainer(DockerImageName.parse("localstack/localstack:0.12.11"))
.withServices(services);
localstack.start();

Expand Down

0 comments on commit e68feb9

Please sign in to comment.