You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
aws test event server
hot replacement lambda
hot replacement lambda cleanup
hot replacement lambda cleanup 2
lambda http finish
add gson to benchmarks
do not enable mock lambda if LambdaClint
final dev mode touches lambda
lambda native testing
comment
comment
finish it
process resources
fix banned dependency
fix banned dependency
fixes
debug lambda test mode
finish mock event initial
process res
logging remove
lambda fixes
lambda continuous testing test
Copy file name to clipboardexpand all lines: devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/examples/amazon-lambda-example/codestart.yml
Copy file name to clipboardexpand all lines: devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/examples/amazon-lambda-example/java/src/test/resources/application.yml
Copy file name to clipboardexpand all lines: devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/examples/funqy-amazon-lambda-example/codestart.yml
Copy file name to clipboardexpand all lines: devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/examples/funqy-amazon-lambda-example/java/src/test/resources/application.yml
Copy file name to clipboardexpand all lines: docs/src/main/asciidoc/amazon-lambda.adoc
+44-66
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,9 @@ Your lambdas can use injection annotations from CDI or Spring and other Quarkus
14
14
Quarkus lambdas can be deployed using the Amazon Java Runtime, or you can build a native executable and use
15
15
Amazon's Custom Runtime if you want a smaller memory footprint and faster cold boot startup time.
16
16
17
+
Quarkus's integration with lambdas also supports Quarkus's Live Coding development cycle. You an
18
+
bring up your Quarkus lambda project in dev or test mode and code on your project live.
19
+
17
20
include::./status-include.adoc[]
18
21
19
22
== Prerequisites
@@ -330,96 +333,71 @@ dependencies {
330
333
----
331
334
332
335
333
-
== Integration Testing
334
-
The Quarkus Amazon Lambda extension has a matching test framework that provides functionality to execute standard JUnit tests on your AWS Lambda function,
335
-
via the integration layer that Quarkus provides. This is true for both JVM and native modes.
336
-
It provides similar functionality to the SAM CLI, without the overhead of Docker.
337
-
338
-
To illustrate, the project generated by the Maven archetype, generates a JUnit test for the `RequestHandler<?, ?>` implementation, which is shown below.
339
-
The test replicates the execution environment, for the function that is selected for invocation, as described <<choose, above>>.
336
+
== Live Coding and Unit/Integration Testing
337
+
To mirror the AWS Lambda environment as closely as possible in a dev environment,
338
+
the Quarkus Amazon Lambda extension boots up a mock AWS Lambda event server in Quarkus Dev and Test mode.
339
+
This mock event server simulates a true AWS Lambda environment.
340
340
341
-
To use the integration tests in your project there is a required property, in `src/test/resources/application.properties`. If not included, the integration tests will be in a constant loop.
341
+
While running in Quarkus Dev Mode, you can feed events to it by doing an HTTP POST to `http://localhost:8080`.
342
+
The mock event server will receive the events and your lambda will be invoked. You can perform live coding on your lambda
343
+
and changes will automatically be recompiled and available the next invocation you make. Here's an example:
342
344
343
-
[source,properties]
344
-
----
345
-
quarkus.lambda.enable-polling-jvm-mode=true
345
+
[source,bash]
346
346
----
347
+
$ mvn clean quarkus:dev
347
348
348
-
NOTE: If you are following along with the example Maven archetype project for AWS Lambda in this guide,
349
-
it includes the required property `quarkus.lambda.enable-polling-jvm-mode=true` in the test `application.properties`.
350
-
351
-
[source,java]
349
+
$ curl -d "{\"name\":\"John\"}" -X POST http://localhost:8080
352
350
----
353
-
@QuarkusTest
354
-
public class LambdaHandlerTest {
355
351
356
-
@Test
357
-
public void testSimpleLambdaSuccess() throws Exception {
358
-
InputObject in = new InputObject();
359
-
in.setGreeting("Hello");
360
-
in.setName("Stu");
352
+
For your unit tests, you can also invoke on the mock event server using any HTTP client you want. Here's an example
353
+
using rest-assured. Quarkus starts up a separate Mock Event server under port 8081.
354
+
The default port for Rest Assured is automatically set to 8081 by Quarkus so you can invoke
355
+
on this endpoint.
361
356
362
-
OutputObject out = LambdaClient.invoke(OutputObject.class, in);
If your code uses CDI injection, this too will be executed, along with mocking functionality, see the link:getting-started-testing[Test Guide] for more details.
387
+
The mock event server is also started for `@NativeImageTest` unit tests so will work
388
+
with native binaries too. All this provides similar functionality to the SAM CLI local testing, without the overhead of Docker.
418
389
419
-
To add JUnit functionality for native tests, add the `@NativeImageTest` annotation to a subclass of your test class, which will execute against your native image, and can be leveraged in an IDE.
390
+
Finally, if port 8080 or port 8081 is not available on your computer, you can modify the dev
391
+
and test mode ports with application.properties
420
392
393
+
[source, subs=attributes+]
394
+
----
395
+
quarkus.lambda.mock-event-server.dev-port=8082
396
+
quarkus.lambda.mock-event-server.test-port=8083
397
+
----
421
398
422
399
== Testing with the SAM CLI
400
+
If you do not want to use the mock event server, you can test your lambdas with SAM CLI.
423
401
424
402
The https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html[AWS SAM CLI]
425
403
allows you to run your lambdas locally on your laptop in a simulated Lambda environment. This requires
Copy file name to clipboardexpand all lines: extensions/amazon-lambda-http/deployment/src/main/java/io/quarkus/amazon/lambda/http/deployment/AmazonLambdaHttpProcessor.java
0 commit comments