Nghia Do
Nghia Do

Reputation: 2658

Smoke test approach for AWS Lambda

I have many AWS Lambda using Java 8. We are using Blue/Green deployment for all Lambda which is having Smoke/Live aliases. We are using Jenkins to deploy aws lambda with below steps

  1. Check out: which is to checkout lambda source from git.
  2. Build & Unit test with Junit .
  3. Code Coverages with Jacoco
  4. Deploy it using Smoke alias.
  5. Now we want to perform Smoke Test for the lambda against Smoke alias
  6. If smoke test cases passes, we will promote Smoke alias to Live alias.

For the step 5, could you please advice if we have approaches to perform "smoke test" for a lambda?

I would think we need to actually execute the lambda itself (not junit) but if so actual business rules ran and then it can generate many things output to targets such as dynamodb and s3 ...

So share best practices you have for your real project. Thanks.

I'm thinking should I add a special param which will be passed through Smoke tests and then the lambda itself has a logic to deal with that param.

Upvotes: 0

Views: 1974

Answers (1)

JD D
JD D

Reputation: 8097

I have struggled with this concept as well.

Assuming you are externalizing your configurations (e.g. DynamoDB tables, S3 locations, etc) via something like environment variables or SSM Parameters: ideally you would have your "smoke" or staging versions of the Lambda point to smoke test (i.e. non-production) resources.

One problem with using aliases is you can not have different environment variables for different aliases.

With that in mind, the typical approach for smoke/integration testing lambdas is to abandon using aliases deploy the staging resources as different/separate functions from your production resources.

This can be done more easily if you have a SAM/Cloudformation template that can deploy your lambdas and their dependencies so you can easily setup development, smoketest and production stacks. You will want to create a parameter for a prefix/suffix that you can give the resources to differentiate the different deployments.

When you are satisfied with your smoke testing results, you simply deploy the tested version of the lambda code to your production lambdas.

Upvotes: 0

Related Questions