Coder Social home page Coder Social logo

evozniak / running-playwright-on-aws-lambda Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paulogoncalvesbh/running-playwright-on-aws-lambda

1.0 0.0 0.0 7.27 MB

Running hundreds of Playwright E2E tests in a few seconds with AWS Lambda

License: GNU General Public License v3.0

Dockerfile 0.93% JavaScript 98.80% Makefile 0.26%

running-playwright-on-aws-lambda's Introduction

Running hundreds of Playwright tests in a few seconds with AWS Lambda

Give the repository a star โญ, it encourages me to create advanced software quality content 100% free

This project has a playwright implementation so that it is consumed via AWS Lambda, allowing to parallelize the execution of all files and making the execution much faster.

The success of this implementation demonstrates that, in scenarios where E2E testing is needed to validate critical behaviors that are not possible in another type of test, it is possible to use AWS Lambda to run this same test on all Pull Requests, not just a few times in day.

Result

With playwright on serverless it was possible to run 110 files, with 221 tests, in less than 25 seconds. This same test running without parallelization would take 23 minutes.

To see the execution in detail, you can access the pipeline log by clicking here.

The gif below demonstrates the execution:

Gif showing playwright execution

Pricing

Running hundreds of Lambda functions that last a few seconds has little impact on the final cost.

AWS Lambda Price:

The AWS Lambda free usage tier includes 1M free requests per month and 400,000 GB-seconds of compute time per month.

Source: https://aws.amazon.com/lambda/pricing/

Application diagram

Diagram

CloudWatch metrics

Below are some important CloudWatch metrics.

110 lambda functions were invoked, however my account has a limit of 50 parallel executions, which made the total execution double in time.

The average time that a lambda function takes to run is 7 seconds, which is less than the total of 23 seconds that takes to run the test.

However 23 seconds is a quiet time to wait when running an E2E test in a pipeline. I think we both agree that it's better than 23 minutes.

Parallel executions

Limited to 50.

Parallel runs limited to 50

Invocations

1 invocation per test file in ./tests/E2E.

Number of calls equal to 110, 1 per test file

Duration

The longest running lambda function was 10.2 seconds, less than half of the total execution time of all functions.

With a higher concurrent execution we would have better results in total time.

Duration showing the longest lambda was 10.2 seconds

More information

To understand how tests are run and AWS Lambda is built I recommend accessing the pipelines in ./.github/workflows/ and the Makefile.

Run locally (without using AWS Lambda)

Acess the directory ./tests and execute:

npm ci

Run the test with:

npm test

LICENSE GNU General Public License v3.0

running-playwright-on-aws-lambda's People

Contributors

evozniak avatar paulogoncalvesbh avatar

Stargazers

Joost Peters avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.