Skip to content

Commit

Permalink
Lambda IT
Browse files Browse the repository at this point in the history
  • Loading branch information
jimomulloy committed May 21, 2023
1 parent 41f1ea8 commit 8dc7926
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package jomu.instrument.pipeline;

import java.util.Arrays;
import java.util.List;

import org.jetbrains.annotations.NotNull;

import software.constructs.Construct;
import software.amazon.awscdk.Environment;
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.Environment;
import software.amazon.awscdk.StageProps;
import software.amazon.awscdk.pipelines.CodeBuildStep;
import software.amazon.awscdk.pipelines.CodePipeline;
import software.amazon.awscdk.pipelines.CodePipelineSource;
import software.amazon.awscdk.pipelines.ManualApprovalStep;
import software.amazon.awscdk.pipelines.ShellStep;
import software.amazon.awscdk.pipelines.StageDeployment;
import software.constructs.Construct;

public class InstrumentAppStack extends Stack {
public InstrumentAppStack(final Construct scope, final String id) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package jomu.instrument.pipeline;

import software.constructs.Construct;
import jomu.instrument.eventbridge.boundary.EventsStack;
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.Stage;
import software.amazon.awscdk.StageProps;
import software.constructs.Construct;

public class InstrumentAppStage extends Stage {
public InstrumentAppStage(final Construct scope, final String id) {
Expand Down
10 changes: 10 additions & 0 deletions instrument-aws/instrument-s3handler-st/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>jomu</groupId>
<artifactId>instrument-s3handler</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-amazon-lambda</artifactId>
Expand Down Expand Up @@ -74,6 +79,11 @@
<artifactId>lambda</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package jomu.instrument.aws.s3handler;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@RegisterRestClient(configKey = "base_uri")
public interface GreetingsResource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import static org.junit.jupiter.api.Assertions.assertNotNull;

import jakarta.inject.Inject;

import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.inject.RestClient;

import jakarta.inject.Inject;

//@QuarkusTest
public class GreetingsResourceIT {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
package jomu.instrument.aws.s3handler;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.containsString;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class LambdaHandlerTest {

// @Test
public void testSimpleLambdaSuccess() throws Exception {
// you test your lambdas by invoking on http://localhost:8081
// this works in dev mode too
//@Test
public void testSimpleLambdaSuccess() throws Exception {
// you test your lambdas by invoking on http://localhost:8081
// this works in dev mode too

// InputObject in = new InputObject();
// in.setName("Stu");
// in.setGreeting("Hello");
// given().contentType("application/json").accept("application/json").body(in).when().post().then().statusCode(200)
// .body(containsString("Hello Stu"));
}
InputObject in = new InputObject();
in.setName("Stu");
in.setGreeting("Hello");
given()
.contentType("application/json")
.accept("application/json")
.body(in)
.when()
.post()
.then()
.statusCode(200)
.body(containsString("Hello Stu"));
}

}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
quarkus.lambda.handler=test
#quarkus.lambda.handler=test
31 changes: 20 additions & 11 deletions instrument-aws/instrument-s3handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,18 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<!--dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-amazon-lambda</artifactId>
<scope>test</scope>
</dependency>
</dependency-->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.amazonservices</groupId>
Expand All @@ -112,16 +108,21 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<!--dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependency-->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>lambda</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jomu</groupId>
<artifactId>instrument</artifactId>
Expand All @@ -134,9 +135,17 @@
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>localstack</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.eclipse.microprofile.config.inject.ConfigProperty;

import io.quarkus.runtime.StartupEvent;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Alternative;
import jakarta.inject.Inject;

import org.eclipse.microprofile.config.inject.ConfigProperty;

import io.quarkus.runtime.StartupEvent;
import jomu.instrument.control.ParameterManager;
import jomu.instrument.store.ObjectStorage;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Alternative;

import jomu.instrument.InstrumentException;
import jomu.instrument.audio.features.AudioFeatureFrame;
import jomu.instrument.monitor.Visor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Alternative;

import jomu.instrument.Instrument;
import jomu.instrument.store.InstrumentStoreService;
import jomu.instrument.workspace.tonemap.ToneMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;

import com.google.gson.Gson;

import io.quarkus.runtime.StartupEvent;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;
import jomu.instrument.Instrument;
import jomu.instrument.control.Controller;
import jomu.instrument.control.InstrumentParameterNames;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import jakarta.inject.Inject;
import jakarta.inject.Named;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.S3Event;
import com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification.S3EventNotificationRecord;

import jakarta.inject.Inject;
import jakarta.inject.Named;

@Named("test")
public class S3ObjectCreateListener implements RequestHandler<S3Event, OutputObject> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;

import jakarta.inject.Inject;

Expand All @@ -11,7 +12,7 @@ class ProcessingServiceTest {
@Inject
ProcessingService processingService;

// @Test
@Test
void testProcess() {
try {
InputObject input = new InputObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.services.lambda.LambdaClient;
import software.amazon.awssdk.services.lambda.model.InvocationType;
import software.amazon.awssdk.services.lambda.model.InvokeRequest;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.core.SdkBytes;

public class InvokeLambdaIT {
public class S3ObjectCreateListenerIT {
LambdaClient client;

@BeforeEach
Expand All @@ -26,7 +27,7 @@ public void invokeLambdaAsynchronously() {
SdkBytes payload = SdkBytes.fromUtf8String(json);

InvokeRequest request = InvokeRequest.builder()
.functionName("airhacks_lambda_greetings_boundary_Greetings")
.functionName("instrument_S3ObjectCreateListener")
.payload(payload)
.invocationType(InvocationType.REQUEST_RESPONSE)
.build();
Expand Down
2 changes: 1 addition & 1 deletion instrument-aws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<modules>
<module>instrument-s3handler</module>
<module>instrument-s3handler-cdk</module>
<!--module>instrument-s3handler-st</module-->
<module>instrument-s3handler-st</module>
</modules>
</project>
4 changes: 1 addition & 3 deletions instrument-desktop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,10 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
<version>2.15.0.Final</version>
</dependency>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down

0 comments on commit 8dc7926

Please sign in to comment.