Serverless Testing - AWS Lambda



Let's start with what is Serverless Framework?

Build applications comprised of microservices that run in response to events, auto-scale for you, and only charge you when they run. This lowers the total cost of maintaining your apps, enabling you to build more logic, faster.

The Serverless Framework helps you develop and deploy your AWS Lambda functions, along with the AWS infrastructure resources they require. It's a CLI that offers structure, automation and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of Functions and Events.
  • It manages your code as well as your infrastructure
  • It supports multiple languages (Node.js, Python, Java, and more)
AWS Lambda is a compute service that lets you run code without provisioning or managing servers. You can also build serverless applications composed of functions that are triggered by events and automatically deploy them using AWS CodePipeline and AWS CodeBuild.

The Mantra is: Build auto-scaling, pay-per-execution, event-driven apps on AWS Lambda

While the Serverless Architecture introduces a lot of simplicity when it comes to serving business logic, some of its characteristics present challenges for testing. They are:
  1. The Serverless Architecture is an integration of separate, distributed services, which must be tested both independently, and together.
  2. The Serverless Architecture is dependent on internet/cloud services, which are hard to emulate locally.
  3. The Serverless Architecture can feature event-driven, asynchronous workflows, which are hard to emulate entirely.

To get through these challenges, and to keep the test pyramid in mind, keep the following principles in mind:
  1. Write your business logic so that it is separate from your FaaS provider (e.g., AWS Lambda), to keep it provider-independent, reusable and more easily testable.
  2. When your business logic is written separately from the FaaS provider, you can write traditional Unit Tests to ensure it is working properly.
  3. Write Integration Tests to verify integrations with other services are working correctly.
From an AWS book the three levels of testing for a serverless architecture:
  • Acceptance – does the whole system work?
  • Integration – does our code work against code we can’t change?
  • Unit – do our objects do the right thing, are they easy to work with?
  • A Lambda function is ultimately a piece of code that AWS invokes on your behalf when some input event occurs. To test that it integrates correctly with downstream systems you can invoke the function from your chosen test framework

Source: http://theburningmonk.com/2017/02/yubls-road-to-serverless-architecture-part-2/
https://read.acloud.guru/testing-and-the-serverless-approach-495cef7495ea
https://martinfowler.com/articles/microservice-testing/
https://martinfowler.com/articles/serverless.html
https://aws.amazon.com/blogs/compute/serverless-testing-with-aws-lambda/

Comments

  1. nice post! Thanks for delivering a good stuff related to DevOps, Explination is good, nice Article
    anyone want to learn advance devops tools or devops online training
    DevOps Online Training
    DevOps Training institute in Ameerpet

    ReplyDelete
  2. Anonymous13/6/19

    This comment has been removed by the author.

    ReplyDelete
  3. Nice Blog very use full inormation.AWS-certified experts help you develop a cloud strategy which aligns with your business transformation road map and implement cloud management solutions to harness the AWS Cloud Managed Services

    ReplyDelete
  4. I really liked your blog post.Much thanks again. Awesome.
    aws training
    r programming training

    ReplyDelete

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?