Integration testing
Unlike unit testing, which tests a unit of the system, integration testing focuses on testing the Lambda function as a whole. So, how do we test Lambda functions in a local development environment without deploying them to AWS? Read on to find out more.
RPC communications
If you read the code under the hood of the official Go library for AWS Lambda (https://github.com/aws/aws-lambda-go), you will notice that Go-based Lambda functions are invoked using net/rpc
over TCP. Every Go Lambda function starts a server on a port defined by the _LAMBDA_SERVER_PORT
environment variable and waits for incoming requests. To interact with the function, two RPC methods are used:
Ping
: Used to check whether the function is still alive and runningInvoke
: Used to perform a request
With this knowledge in mind, we can simulate a Lambda function's execution, and perform integration testing or pre-deploy tests to reduce the waiting time when deploying the function to AWS but before checking its...