running unit test on serverless infrastructure
play

Running Unit Test on Serverless Infrastructure Adinata Thayib - PowerPoint PPT Presentation

Running Unit Test on Serverless Infrastructure Adinata Thayib @dieend source: xkcd.com 85% less Running Unit Test on Serverless Infrastructure Adinata Thayib @dieend About Pocket Gems Mobile Game Company War Dragons & Episode


  1. Running Unit Test on Serverless Infrastructure Adinata Thayib @dieend

  2. source: xkcd.com

  3. 85% less

  4. Running Unit Test on Serverless Infrastructure Adinata Thayib @dieend

  5. About Pocket Gems ● Mobile Game Company ○ War Dragons & Episode ● 10 years old (and hiring!) ● > 4K tests

  6. Frustration

  7. What is the problem? Running full unit tests suite is slow Is it worth solving? ● Productivity ● Deployment Speed

  8. How to make test suite complete faster? 1. Have fewer unit tests

  9. How to make test suite complete faster? 1. Have fewer unit tests 2. Divide & Conquer a.k.a Parallelize the unit tests execution

  10. How do we parallelize test execution? 1. Run it locally with multiple CPUs 2. Run it in multiple machine 3. Run it in serverless infrastructure

  11. Running locally with multiple CPUs Nosetests Multiprocess plugin: ● Collect tests into a Queue object ● Configure the child process ● Start process which poll from the test Queue

  12. Running locally with multiple CPUs Collect:

  13. Running locally with multiple CPUs Collect: The plugin can't know (unless you tell it) if a context fixture can be called many times concurrently (is re-entrant), or if it can be shared among tests running in different processes. Therefore, if a context has fixtures, the default behavior is to dispatch the entire suite to a worker as a unit.

  14. Running with Multiple Machine No out of the box python solution. Ruby Alternative (Knapsack Pro - for Ruby and JS). Python WIP

  15. Running with Multiple Machine

  16. Running with Multiple Machine

  17. Designing the solution Constraint: ● We won't have engineer resources to manage the worker machine full time Opportunity: ● We use GAE: all the tests don't have external fixtures ● We use GAE: 100% python code and aren't using many binary dependencies Proposed Solution ● Use AWS Lambda to remove the necessity on managing worker machine

  18. Running with serverless infrastructure

  19. Running with serverless infrastructure

  20. Running with serverless infrastructure nosetest plugin with custom selector

  21. Running with serverless infrastructure Running Test... thread.join() Parse output

  22. What we learned

  23. What we learned 1. AWS Lambda Source File Limits 2. Concurrent Executions 3. Network Bandwidth 4. Longest running unit tests is the weakest link 5. Binary Dependencies 6. No re-entrant fixture support

  24. After 2 years...

  25. ~21min faster

  26. > 1000 executions/month

  27. > 350hr engineering hours are saved each month

  28. Monthly Impact Assuming engineering hour cost Minute saved each 21 mins execution $50/month (Bay Area): Monthly Execution 1000 execution Hours 350 hr Monthly Saved ~$17,500 Engineering Cost

  29. ~$120 monthly cost

  30. > $17K Saving per months

  31. Assuming engineering hour cost Monthly Saved ~$17,500 Engineering Cost $50/month (Bay Area): Monthly Cost ~$(120) Total ~$17,380 Initial Investment: Engineering Cost to Build ~$8,000 4 engineering weeks Break Even Point < 1 month

  32. >70 engineers adopted it

  33. Frustration Others might have the same frustration with you. You might solve everyone's problem.

  34. Q&A Channel Discussion: #talk-unit-test-serverless Send me a tweet: @dieend

  35. Channel Discussion: #talk-unit-test-serverless Send me a tweet: @dieend Thank you

Recommend


More recommend