-
Notifications
You must be signed in to change notification settings - Fork 238
Enabling Local Testing with RIE and Improving Tests Coverability #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0d6e155
Add local testing support with RIE
3b840a2
Improve code test coverage from 0.45 to 0.5
72c2c14
Replace the hardcoded versions with RELEASE versions
afffa7b
Replace Dockerfile base image with image that has RIE preinstalled
e89624f
Change from mvn central artifacts to locally built ones
09b932e
Update from java 11 to java 21 and remove duplicate entries from pom
1e47362
Clean up test coverage configuration
ec58561
Update README to reflect changes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,8 @@ | ||
FROM public.ecr.aws/lambda/java:21 | ||
|
||
COPY target/aws-lambda-java-runtime-interface-client-*.jar ${LAMBDA_TASK_ROOT}/ | ||
COPY target/aws-lambda-java-core-*.jar ${LAMBDA_TASK_ROOT}/ | ||
COPY target/aws-lambda-java-serialization-*.jar ${LAMBDA_TASK_ROOT}/ | ||
COPY test-handlers/EchoHandler.class ${LAMBDA_TASK_ROOT}/ | ||
|
||
CMD ["EchoHandler::handleRequest"] |
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -214,6 +214,24 @@ | |
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
<version>${jacoco.maven.plugin.version}</version> | ||
<configuration> | ||
<excludes> | ||
<!-- Exclude simple exceptions (compiler enforced) --> | ||
<exclude>**/*Exception.class</exclude> | ||
<!-- Exclude interfaces (compiler enforced) --> | ||
<exclude>**/Resource.class</exclude> | ||
<!-- Exclude simple DTOs/POJOs (data containers) --> | ||
<exclude>**/dto/*.class</exclude> | ||
<!-- Exclude constants classes (build-time values) --> | ||
<exclude>**/ReservedRuntimeEnvironmentVariables.class</exclude> | ||
<exclude>**/RapidErrorType.class</exclude> | ||
<!-- Exclude enum-like data holders --> | ||
<exclude>**/FrameType.class</exclude> | ||
<exclude>**/StructuredLogMessage.class</exclude> | ||
<!-- Exclude main entry point (runtime-only) --> | ||
<exclude>**/AWSLambda.class</exclude> | ||
</excludes> | ||
</configuration> | ||
Comment on lines
+217
to
+234
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
<executions> | ||
<execution> | ||
<id>default-prepare-agent</id> | ||
|
46 changes: 46 additions & 0 deletions
46
aws-lambda-java-runtime-interface-client/scripts/test-rie.sh
This file contains hidden or 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,46 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" | ||
SERIALIZATION_ROOT="$(dirname "$PROJECT_ROOT")/aws-lambda-java-serialization" | ||
|
||
if ! ls "$PROJECT_ROOT"/target/aws-lambda-java-runtime-interface-client-*.jar >/dev/null 2>&1; then | ||
echo "RIC jar not found. Please build the project first with 'mvn package'." | ||
exit 1 | ||
fi | ||
|
||
IMAGE_TAG="java-ric-rie-test" | ||
|
||
HANDLER="${1:-EchoHandler::handleRequest}" | ||
|
||
echo "Starting RIE test setup for Java..." | ||
|
||
# Build local dependencies if not present | ||
CORE_ROOT="$(dirname "$PROJECT_ROOT")/aws-lambda-java-core" | ||
if ! ls "$PROJECT_ROOT"/target/aws-lambda-java-core-*.jar >/dev/null 2>&1; then | ||
echo "Building local aws-lambda-java-core..." | ||
(cd "$CORE_ROOT" && mvn package -DskipTests) | ||
cp "$CORE_ROOT"/target/aws-lambda-java-core-*.jar "$PROJECT_ROOT/target/" | ||
fi | ||
|
||
if ! ls "$PROJECT_ROOT"/target/aws-lambda-java-serialization-*.jar >/dev/null 2>&1; then | ||
echo "Building local aws-lambda-java-serialization..." | ||
(cd "$SERIALIZATION_ROOT" && mvn package -DskipTests) | ||
cp "$SERIALIZATION_ROOT"/target/aws-lambda-java-serialization-*.jar "$PROJECT_ROOT/target/" | ||
fi | ||
|
||
echo "Compiling EchoHandler..." | ||
javac -source 21 -target 21 -cp "$(ls "$PROJECT_ROOT"/target/aws-lambda-java-runtime-interface-client-*.jar):$(ls "$PROJECT_ROOT"/target/aws-lambda-java-core-*.jar):$(ls "$PROJECT_ROOT"/target/aws-lambda-java-serialization-*.jar)" \ | ||
-d "$PROJECT_ROOT/test-handlers/" "$PROJECT_ROOT/test-handlers/EchoHandler.java" | ||
|
||
echo "Building test Docker image..." | ||
docker build -t "$IMAGE_TAG" -f "$PROJECT_ROOT/Dockerfile.rie" "$PROJECT_ROOT" | ||
|
||
echo "Starting test container on port 9000..." | ||
echo "" | ||
echo "In another terminal, invoke with:" | ||
echo "curl -s -X POST -H 'Content-Type: application/json' \"http://localhost:9000/2015-03-31/functions/function/invocations\" -d '{\"message\":\"test\"}'" | ||
echo "" | ||
|
||
exec docker run -it -p 9000:8080 -e _HANDLER="$HANDLER" "$IMAGE_TAG" |
20 changes: 20 additions & 0 deletions
20
aws-lambda-java-runtime-interface-client/test-handlers/EchoHandler.java
This file contains hidden or 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 @@ | ||
import com.amazonaws.services.lambda.runtime.Context; | ||
import com.amazonaws.services.lambda.runtime.RequestHandler; | ||
import java.util.Map; | ||
import java.util.HashMap; | ||
|
||
public class EchoHandler implements RequestHandler<Map<String, Object>, Map<String, Object>> { | ||
|
||
@Override | ||
public Map<String, Object> handleRequest(Map<String, Object> event, Context context) { | ||
context.getLogger().log("Processing event: " + event); | ||
|
||
Map<String, Object> response = new HashMap<>(event); | ||
response.put("timestamp", System.currentTimeMillis()); | ||
response.put("requestId", context.getAwsRequestId()); | ||
response.put("functionName", context.getFunctionName()); | ||
response.put("remainingTimeInMillis", context.getRemainingTimeInMillis()); | ||
|
||
return response; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!