To collect AWS Lambda Function code coverage, we need to configure the AWS Lambda to attach Sealights java agent to the JVM startup command in the AWS Lambda Function execution environment:
Create an AWS Lambda Layer that contains the Sealights' Test Listener Java Agent JAR file.
This layer can be used by additional We need the AWS Lambda Layer with Sealights test listener jar. We can use the one published by Sealights or create the new one. The layer and the AWS Lambda Function need to be in the same AWS region.Use one of Sealights java AWS Lambda layers
arn:aws:lambda:eu-west-1:442677231940:layer:sl-java-agent:1
arn:aws:lambda:eu-west-2:442677231940:layer:sl-java-agent:1
arn:aws:lambda:us-east-1:442677231940:layer:sl-java-agent:1
arn:aws:lambda:us-west-2:442677231940:layer:sl-java-agent:1
Create AWS Lambda Layer yourself which contains SL Test Listener java agent jar. This layer can be reused by many AWS Lambda functions.
Configure your AWS Lambda Function to use the above layer (with SL Java Agent).
...
Create or modify JAVA_TOOL_OPTIONS environment variable on AWS Lambda Function configuration page: add
-javaagent
parameter pointing to SL Test Listener which is placed in /opt directory.JAVA_TOOL_OPTIONS environment variable value can also contain sl properties which that we need to pass to the agent, for example:
Code Block language bash -javaagent:/opt/sl-test-listener.jar -Dsl.buildSessionIdFile=/var/task/buildSessionId.txt -Dsl.log.level=info -Dsl.log.enabled=true -Dsl.enableUpgrade=false -Dsl.log.toConsole=truetags=aws-lambda -Dsl.featuresData.codeCoverageManagerVersion=v3 -Dsl.tags=aws-lambdacollectorUrl=http://mycollector.dns
You can set other environment variables - that will be picked up automatically by the agent - like SL_TOKEN, and SL_BUILDSESSIONID, SL_LAB_ID & SL_COLLECTOR_URL (whose names match the SL properties by replacing “
.
" in the SL property name with "_
").
...