Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testing Serverless Applications @ Serverless Days Tel Aviv

Testing Serverless Applications @ Serverless Days Tel Aviv

Slobodan Stojanović

June 04, 2019
Tweet

More Decks by Slobodan Stojanović

Other Decks in Programming

Transcript

  1. @slobodan_ • Automated testing? • Manual testing? • Manual testing

    by your end users?* * Also known as testing in production
  2. Slobodan Stojanovic CTO @ Cloud Horizon CTO @ VacationTracker.io co-author

    of Serverless Applications with Node.js book @slobodan_
  3. @slobodan_ • Azure Functions Core Tools (for Azure functions) •

    AWS SAM CLI (for AWS SAM) • Third-party tools (ie. localstack) • docker-lambda for AWS Lambda local simulation • Run Node.js function locally • And more…
  4. @slobodan_ You can run parts of your code locally to

    speed up the development, but not everything
  5. @slobodan_ Integration tests are cheaper, but also more important! Because

    common serverless app is split into many small pieces
  6. @slobodan_ Not to another cloud vendor, but to your new

    service, new or changed integration…
  7. @slobodan_ "Allow an application to equally be driven by users,

    programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases." Alistair Cockburn
 Creator of Hexagonal architecture
  8. @slobodan_ const {
 httpResponse, parseApiEvent,
 SnsRepository
 } = require('../common')
 const

    main = require('./main')
 async function handler(event) { const { body, headers } = parseApiEvent(event) // Create instance of SNS notification repository
 const notification = new SnsRepository(
 process.env.topic ) // Invoke main function with all dependencies
 await main(body, headers, notification)
 return httpResponse()
 }
  9. @slobodan_ Units are smaller and easier to test, but deployment,

    triggers and permissions are not trivial
  10. @slobodan_ • AWS SAM • AWS CDK • Serverless Framework

    • Claudia.js • .architect • and many others
  11. @slobodan_ There are many awesome monitoring tools, and a lot

    of them are from Israel!* * Epsagon, Lumigo, and others.
  12. @slobodan_ There are tools that can help you to improve

    your permissions and keep your app secure.* * Protego, Puresec, and others.
  13. @slobodan_ • You can run/test some parts of serverless app

    locally, but not everything. • Automated tests are important, but be smart. • Use hexagonal architecture to stay flexible. • Make sure you are tracking errors, unless you want them to scale, too.