Testing Your Serverless Microservice

In the previous chapter, we created a fully functional serverless data API using API Gateway, Lambda, and DynamoDB, and we deployed it to the AWS CLI. The testing we showed was performed in the AWS Management Console and browser, which is fine for small amounts of simple code development as a proof of concept, but is not recommended for development or production systems.

It is much more efficient for a developer to first develop and test locally, and it is essential for continuous delivery to have automated tests. This chapter is all about testing.

Testing could easily cover a whole book, but we will keep things very practical and focused on testing your serverless code and the data API we deployed in Chapter 3, Deploying Your Serverless Stack. This will include unit testing, mocking, local debugging, integration testing, running the Lambda or serverless APIs with an HTTP server locally in a Docker container, and load testing.

In this chapter, we will cover the following topics:

  • Unit testing your Python Lambda code
  • Running and debugging your AWS Lambda code locally
  • Integration testing using real test data
  • The AWS Serverless Application Model (SAM) CLI
  • Loading and end-to-end testing at scale
  • Strategies to reduce the API's latency
  • Cleaning up
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset