10 21 2015 1
play

10/21/2015 1 10/21/2015 Challenges Integration tests fails due - PDF document

10/21/2015 1 10/21/2015 Challenges Integration tests fails due to unreliable dependency servers Hard to test different test data permutations for dependency servers Need to do resiliency testing 2 10/21/2015 Our Solution


  1. 10/21/2015 1

  2. 10/21/2015 Challenges • Integration tests fails due to unreliable dependency servers • Hard to test different test data permutations for dependency servers • Need to do resiliency testing 2

  3. 10/21/2015 Our Solution Overview of Wiremock Wiremock is a library for stubbing and proxying web services • Stubbing • Fault Injection • Easy Set up • Easy onboarding 3

  4. 10/21/2015 How does Wiremock work? = Stubs System Wiremock Dependency Automation Server Server Under Test Test • Configure the Wiremock server to be man-in-the-middle • Increased integration test pass rate • Increased code coverage • Does not interrupt other team’s calling the SUT Overview of AWS 4

  5. 10/21/2015 Overview of AWS Amazon Web Services (AWS) is a cloud computing services • On-demand delivery of IT resources and applications • Pay-as-you-go pricing AWS Architecture ELB for SUT SUT 1 Subnet SUT 2 Subnet 5

  6. 10/21/2015 Before Wiremock ELB for SUT SUT 1 Subnet Automation Test SUT 2 Subnet Dependency Server Wiremock in AWS 6

  7. 10/21/2015 We tried this = Stubs ELB for SUT SUT 1 Subnet Automation Test SUT 2 Subnet • Deploy Wiremock on SUT EC2 instance • No consistent stub response! Our Solution SUT 1 = Stubs ELB for SUT Automation SUT 2 Test ELB for WM Wiremock (Stub Dependency) • Deploy Wiremock on dedicated EC2 and ELB • Consistent Stub responses! 7

  8. 10/21/2015 If no stubs… SUT 1 WM will proxy the ELB for SUT request to dependency server Automation SUT 2 Test ELB for WM Wiremock Dependency Server Wiremock Code Snipets 8

  9. 10/21/2015 Starting Up Wiremock Server java -jar wiremock-1.53-standalone.jar --verbose -- port 8080 --proxy-all=[Dependency Server DNS Name] Stubbing the response //This calls Wiremock API to stub the response stubFor(get(urlEqualTo (“/from/where”)) .willReturn(aResponse().withStatus(200) .withHeader("Cache-Control", "no-cache") .withHeader("Content-Type", ”text/plain" ) .withBody (“Taiwan” ))); 9

  10. 10/21/2015 Simulating Fault //This calls Wiremock API for fault injection stubFor(get(urlEqualTo (“/some/thing”)) .willReturn(aResponse() .withFault(Fault.EMPTY_RESPONSE))); Automate WM Deployment 10

  11. 10/21/2015 Automate Wiremock Deployment Chef is an infrastructure automation code tool we use • Code how you deploy and manage your infrastructure • Allows version control • Code can be reused Automate Wiremock Deployment We wrote a Wiremock Recipe • Download the Wiremock jar • Start up the Wiremock server 11

  12. 10/21/2015 Automate Wiremock Deployment Berkshelf is a dependency manager for chef • Get the Java recipe to download Java • Get the Wiremock recipe to deploy Wiremock server Chef Snipet #This will start the Wiremock server with the parameters passed in function start { cd "${USER_DIRECTORY}" ;java -jar wiremock-${WIREMOCK_VERSION}-standalone.jar --port ${PORT} --proxy-via ${PROXY_VIA} - – proxy-all= ${PROXY_ALL} --verbose > /var/log/wiremock.log 2>&1 & } 12

  13. 10/21/2015 Automate Wiremock Stack Creation Use AWS CloudFormation API • Provision EC2 instances and ELB • Create Auto Scaling Group • Set up other AWS resources Use WireMock Call Chef from CloudFormation 13

  14. 10/21/2015 How to Call Cookbook From CloudFormation Write shell scripts In the InstanceLaunchConfig section 1. Download and install chef 2. Run Chef. In this case, we created a Wiremock role to execute the Java and Wiremock cookbooks. Call Chef from CloudFormation "5_run_chef": { "command": { "Fn::Join": [ "", [ "/usr/bin/chef-solo -c /var/chef/config/solo.rb -o 'role[", { "Ref": "Role" }, "]' -E '", { "Ref": "Environment" },"'" ] ] } 14

  15. 10/21/2015 Deep Dives Demo Wiremock SUT Yelp Test Server Automation 15

  16. 10/21/2015 Recap Recap Solution: Wiremock • Tests don’t fail due to unreliable dependency servers • Less engineers’ time spent on unnecessary debugging • Resiliency issues are found before production • Less production escapes and firefighting • Happy Engineers 16

  17. 10/21/2015 What we learned What We Learned • The initial investment is worth it • Try to be flexible • Set up DNS 17

  18. 10/21/2015 References • My talk for CI/CD with Mocking and Resiliency Testing in AWS re:invent Conference • http://wiremock.org/ • https://www.chef.io/ • http://docs.aws.amazon.com/AWSCloudFormation/latest /APIReference/Welcome.html Contact Lucy Chang Senior Software Engineer in Quality , Intuit https://www.linkedin.com/pub/lucy-chang/11/312/a83 Twitter: @bingbongbong888 18

  19. 10/21/2015 Acknowledgement Paper Reviewers Moss Drake Dave Patterson Thank you! 19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend