At the AWS re:Invent 2022, our very own Pawel Zubkiewicz, Master Cloud Architect at TT PSC and AWS Serverless Hero, presented “Automated testing for serverless applications” during one of the Dev Chat sessions.

Pawel is a passionate expert on serverless since the very beginning of his cloud journey in 2016 and has been exploring the topic of serverless testing since the fall of 2020. During the Dev Chat Pawel shared his thoughts on the theory behind testing serverless applications in the cloud and using real AWS services of locally emulated resources.

Challenges with serverless

Testing serverless applications is challenging because testing itself has always been hard, even in the pre-cloud, monolith era. In serverless we can’t control every aspect of infrastructure, more over Lambda function code does not work without other AWS services, which makes writing tests challenging.

The evolution of testing approaches (source: link)

Read on for Pawel’s 6 key takeaways from his talk

1. Automate all tests. An ineffective development workflow can be replaced with automated tests. Tests are executed locally, but they use real cloud resources.

Why do you test:

  • to have confidence that code works how we think it does
  • to have a (fast) feedback loop after making a change in code

2.  Don’t emulate AWS locally. Many serverless programmers complain about ineffective development flow. They write code, deploy to the cloud, invoke a Lambda function (it fails), check logs in Amazon CloudWatch, then start write code again. After several iterations like this, they finally have the working code, but that takes too long. Often, developers want to emulate cloud and test locally because they are after convenience and speed. Both can be achieved when testing using real cloud resources.

“Often I hear people SIMULATE the cloud because of convenience and speed, but both can be achieved when testing in the cloud.”

3. Use real cloud resources in tests. Instead of emulation of AWS on your local computer, you create resources in the cloud. For example, database (DynamoDB) and your integration test, executed locally connects to the DynamoDB in the cloud.

Why is emulation bad? Because it makes it hard to configure on local machine, and there is no warranty that it will work exactly the same as the real cloud.

4. Use an architecture style that facilitates test automation. Pawel’s favorite architecture style is hexagonal architecture, also known as ports and adapters, because it promotes the creation of loosely coupled application components and facilitates test automation. However, you may use any style you prefer as long as it makes testing easier.

5. Test Lambda privileges (IAM roles). In order to achieve the principle of least privilege, Pawel recommends writing tests that validate IAM roles. These tests are very similar to an integration test but use Lambda’s IAM Role to interact with AWS cloud; that way we may verify if it has correct privileges granted (in both ways, not too little, not too much. More importantly, on the screen there is a test that checks if a function is denied access to writing data – so a “negative” test)

6. Ease of use over internal complexity. Testing practice needs to be simple to use even for juniors. This doesn’t mean it was easy to define and build (it wasn’t). If it’s easy to write new tests people will do it, and benefits for the whole project/team/company outweigh the cost/time invested in building more complex structure/system underneath that enables it.

Pawel’s hope and conviction is wider adoption of serverless architecture. As serverless matures so do the practices around it as well. Years ago testing was problematic, and people used “testing issue” as an argument against using serverless. Today, severless no longer has the same testing issues.

Learn more about TTPSC’s cloud services: link

How useful was this post?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

If you violate the Regulations , your post will be deleted.
Your first and last name

_All posts in this category

Become a top example of a complete transition to Industry 4.0

Digital transformation and moving towards the idea of Industry 4.0 (I4.0) & Smart Factory (in AWS) are not easy. There are many obstacles…
Read more

How to get closer towards Industry 4.0?

Ensure business growth in the digital age. Dive into #digitaltransformation to find new opportunities, business models, make changes in your organization and bring…
Read more

How to implement Industry 4.0 smarter, faster, and easier?

The concept associated with Industry 4.0 is Smart Factory – in other words “intelligent factory”. This type of plant is based on integrated…
Read more

ThingWorx AWS Connector

The ubiquitous fourth industrial revolution, named Industry 4.0, is now one of the fastest growing IoT markets. The digital transformation journey is more…
Read more

How to achieve AWS cloud cost optimization with FinOps?

The cloud is not on-premise, which means that IT purchases don't happen according to a strategic plan, but immediately when the architect provisions…
Read more

Driving digital transformation in the cloud

The cloud is a key success factor in digital transformation. It provides companies with many decisive advantages. However, the prerequisite for this is…
Read more

What should you know about serverless computing?

Serverless cmputing still raises a lot of doubts, especially among those environments that are just starting to use cloud services or are just…
Read more

What is DevOps as a service and how you can benefit from it?

DevOps is an innovative methodology that introduced a new quality of work on IT projects. It is based on the cooperation of autonomous…
Read more

9 reasons why you should use the cloud in your business

According to "2019 State of the Cloud Report from Flexera" RightScale's report, 94% of companies use the cloud. It is no coincidence that…
Read more

How to start your journey with Azure and prepare for the AZ-900 exam

The demand for Cloud specialists is dynamically growing. How to get a wide range of competences and quickly familiarize yourself with the subject…
Read more

Cloud in a time of crisis – how to improve work in your company

The world we've known in recent years is changing a lot. It forces us to change our habits as well as the ways…
Read more

How to take care of the security of serverless applications in AWS?

The AWS re:Invent 2019 conference, similarly to previous editions, was full of interesting lectures, such as breakout sessions, which aimed at familiarizing the…
Read more

SSM parameters in AWS automation

Some time ago I was involved in a project that was to provide HA Windchill Cluster - actually, nothing new, the cluster itself…
Read more

How we touched the clouds – AWS re:invent 2019 seen with our eyes

Apart from the funding, participation in the AWS conference re:Invent requires engagement and a bit of persistence on the participants’ side. In our…
Read more

How to make use of Talend Open Studio in the medical industry?

The use of modern technologies in medicine is getting more and more popular. Paper patient records are becoming obsolete and are being replaced…
Read more

What is Amazon Web Services cloud?

Cloud computing is one of the world’s most rapidly developing technologies. It is successively replacing traditional server solutions, obtaining a larger and larger…
Read more

Why serverless is the future of software and apps

Every few years there is a new big thing in IT. Nowadays, all eyes are focused on Machine Learning (ML) and Artificial Intelligence…
Read more

_Let’s get in touch

Contact us