-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
557 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-integration-tests-aws2</artifactId> | ||
<version>1.8.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>camel-quarkus-integration-test-aws2-lambda</artifactId> | ||
<name>Camel Quarkus :: Integration Tests :: AWS 2 Lambda</name> | ||
<description>Integration tests for Camel Quarkus AWS 2 Lambda extension</description> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-bom-test</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-main</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-aws2-lambda</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-jackson</artifactId> | ||
</dependency> | ||
|
||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>iam</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-aws2-lambda-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-main-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>native</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<properties> | ||
<quarkus.package.type>native</quarkus.package.type> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
127 changes: 127 additions & 0 deletions
127
...a/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.quarkus.component.aws2.lambda.it; | ||
|
||
import java.net.URI; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.DELETE; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.core.Response.Status; | ||
import javax.ws.rs.ext.Provider; | ||
|
||
import org.apache.camel.CamelExecutionException; | ||
import org.apache.camel.ProducerTemplate; | ||
import org.apache.camel.component.aws2.lambda.Lambda2Constants; | ||
import org.apache.camel.component.aws2.lambda.Lambda2Operations; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import software.amazon.awssdk.services.lambda.model.FunctionConfiguration; | ||
import software.amazon.awssdk.services.lambda.model.InvalidParameterValueException; | ||
import software.amazon.awssdk.services.lambda.model.ListFunctionsResponse; | ||
|
||
@Path("/aws2-lambda") | ||
@ApplicationScoped | ||
public class Aws2LambdaResource { | ||
@ConfigProperty(name = "aws-lambda.role-arn") | ||
String roleArn; | ||
|
||
@Inject | ||
ProducerTemplate producerTemplate; | ||
|
||
@Path("/create/{functionName}") | ||
@POST | ||
@Consumes("application/zip") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public Response createFunction(byte[] message, @PathParam("functionName") String functionName) throws Exception { | ||
final String response = producerTemplate.requestBodyAndHeaders( | ||
componentUri(functionName, Lambda2Operations.createFunction), | ||
message, | ||
new LinkedHashMap<String, Object>() { | ||
{ | ||
put(Lambda2Constants.ROLE, roleArn); | ||
put(Lambda2Constants.RUNTIME, "nodejs12.x"); | ||
put(Lambda2Constants.HANDLER, "index.handler"); | ||
} | ||
}, | ||
String.class); | ||
return Response | ||
.created(new URI("https://camel.apache.org/")) | ||
.entity(response) | ||
.build(); | ||
} | ||
|
||
@Path("/listFunctions") | ||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public List<String> listFunctions() throws Exception { | ||
return producerTemplate.requestBody( | ||
componentUri("foo", Lambda2Operations.listFunctions), | ||
null, | ||
ListFunctionsResponse.class) | ||
.functions().stream() | ||
.map(FunctionConfiguration::functionName) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Path("/invoke/{functionName}") | ||
@POST | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public String invoke(byte[] message, @PathParam("functionName") String functionName) throws Exception { | ||
return producerTemplate.requestBody( | ||
componentUri(functionName, Lambda2Operations.invokeFunction), | ||
message, | ||
String.class); | ||
} | ||
|
||
@Path("/delete/{functionName}") | ||
@DELETE | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public void delete(@PathParam("functionName") String functionName) throws Exception { | ||
producerTemplate.requestBody( | ||
componentUri(functionName, Lambda2Operations.deleteFunction), | ||
null, | ||
Object.class); | ||
} | ||
|
||
private static String componentUri(String functionName, Lambda2Operations operation) { | ||
return "aws2-lambda:" + functionName + "?operation=" + operation; | ||
} | ||
|
||
@Provider | ||
public static class ExceptionMapper implements javax.ws.rs.ext.ExceptionMapper<CamelExecutionException> { | ||
@Override | ||
public Response toResponse(CamelExecutionException exception) { | ||
if (exception.getCause() instanceof InvalidParameterValueException) { | ||
return Response.status(Status.BAD_REQUEST).entity(exception.getCause().getMessage()).build(); | ||
} | ||
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(exception.getMessage()).build(); | ||
} | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
integration-tests-aws2/aws2-lambda/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## --------------------------------------------------------------------------- | ||
## Licensed to the Apache Software Foundation (ASF) under one or more | ||
## contributor license agreements. See the NOTICE file distributed with | ||
## this work for additional information regarding copyright ownership. | ||
## The ASF licenses this file to You under the Apache License, Version 2.0 | ||
## (the "License"); you may not use this file except in compliance with | ||
## the License. You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## --------------------------------------------------------------------------- | ||
|
||
camel.component.aws2-lambda.access-key=${AWS_ACCESS_KEY} | ||
camel.component.aws2-lambda.secret-key=${AWS_SECRET_KEY} | ||
camel.component.aws2-lambda.region=${AWS_REGION:us-east-1} |
27 changes: 27 additions & 0 deletions
27
...-lambda/src/test/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.quarkus.component.aws2.lambda.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 Aws2LambdaIT extends Aws2LambdaTest { | ||
|
||
} |
Oops, something went wrong.