+ All Categories
Home > Technology > (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

(DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Date post: 08-Jan-2017
Category:
Upload: amazon-web-services
View: 975 times
Download: 0 times
Share this document with a friend
53
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lucy Chang Sr. Software Engineer in Quality, Intuit CI/CD with Mocking & Resiliency Testing Using AWS Alfred Tan Sr. DevOps Manager, Intuit
Transcript
Page 1: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Lucy Chang

Sr. Software Engineer in Quality, Intuit

CI/CD with Mocking &

Resiliency Testing Using AWS

Alfred Tan

Sr. DevOps Manager, Intuit

Page 2: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS
Page 3: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS
Page 4: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Session Overview

• CI/CD and AWS onboarding

• Cross team AWS strategy alignment

• Automating AWS deployment

• Development work is blocked by dependency

• Integration tests fails due to unreliable dependency

• Need to do resiliency testing

Page 5: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

CI/CD in AWS

Page 6: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Our Challenges

• Security requirements

• Onboarding into CI/CD

• Highly Available

Page 7: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Our Solution - Slingshot

• Build security in

• Automate onboarding to CI/CD

• Build HA/DR in

Page 8: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

CI/CD Pipeline

Continuous Integration

Continuous Delivery/Deployment Pipeline

Promotion Criteria:

• Build pass: 100%

• Unit Test pass: 100%

• Code Coverage: >80%

Build

Promotion Criteria:

• BAT pass: 100%

CI

Promotion Criteria:

• Regression Test

pass: 100%

QA

Promotion Criteria:

• E2E Test pass:

100%

Test Run:

• E2E Test

• Performance Test

E2E/Perf

Test Run:

• Smoke Test pass: 100%

Prod

Page 9: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Slingshot Setup

Initial Setup

GitHub Repo

CI/CD Pipeline

KMS/SSH keys

S3 Buckets

Egress Proxy and Bastion Host

Splunk Forwarder

AWS Account SetupAWS Account

VPC, Subnets, Routing tables, Route 53 Zone Delegation

One time events

Page 10: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Slingshot Initial Setup

Region US-WEST-2

Bucket for Artifacts KMS Key for Secrets KMS Key for EBSBucket for Secrets

Internet

GatewayBastion

ASG

Splunk

Forwarder

Egress

ASG

Public Bastion Subnets Public Egress Subnets

Private DB Subnets

Private APP Subnets

Public ELB Subnets

Private WEB Subnets

Delegated DNS Zones

Page 11: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Slingshot Setup

Initial Setup

GitHub Repo

CI/CD Pipeline

KMS/SSH keys

S3 Buckets

Egress Proxy and Bastion Host

Splunk Forwarder

CI/CD

ELB

Web Tier

App Tier

CNAME

Recurring events

AWS Account SetupAWS Account

VPC, Subnets, Routing tables, Route 53 Zone Delegation

One time events

Page 12: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

CD with Blue-Green Deployment

ci-svc.intuit.com qa-svc.intuit.com svc.intuit.com

PreProd

Account

Prod

Account

Public ELB

Subnets

Private Web

Subnets

Private App

Subnets

100% 5%95% 100%0%

CI Web

Build 10

CI App

Build 10

CI Web

Build 12

CI App

Build 12

QA App

Build 10

QA Web

Build 10

QA App

Build 10

QA Web

Build 12

QA App

Build 12

Prod App

Build 10

Prod Web

Build 10

Prod App

Build 10

Prod Web

Build 12

Prod App

Build 12

Page 13: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Benefits

• Early feedback on changes flowing through the system

• Increase in quality

• Frequent releases to production

• Development productivity from day 1

Page 14: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Slingshot Demo

Page 15: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Recap

Challenges

• Security requirements

• Onboarding into CI/CD

• Highly Available

The Solution: Slingshot

• Build security in

• Automate onboarding to CI/CD

• Build HA/DR in

Page 16: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

The Next Problem

• Automation tests failed due to unreliable dependency server

• Builds are not promoted

Page 17: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Our Solution

Page 18: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Overview of Wiremock

Wiremock is a library for stubbing and proxying web services

• Stubbing

• Fault Injection

• Easy Set up

• Easy onboarding

Page 19: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

How does Wiremock work?

System

Under Test

Wiremock

Server

Dependency

ServerAutomation

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

= Stubs

Page 20: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Before Wiremock

SubnetELB for SUT

SUT 1

SUT 2

Dependency

Server

Subnet

Automation

Test

Page 21: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

We tried this

SubnetELB for SUT

SUT 1

SUT 2Subnet

Automation

Test

• Deploy Wiremock on SUT EC2 instance

• No consistent stub response!

= Stubs

Page 22: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Our Solution

ELB for WM

SUT 1

SUT 2Automation

Test

Wiremock(Stub

Dependency)

ELB for SUT

• Deploy Wiremock on dedicated EC2 and ELB

• Consistent Stub responses!

= Stubs

Page 23: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

If no stubs…

ELB for WM

SUT 1

SUT 2Automation

Test

Wiremock

ELB for SUT

Dependency

Server

WM will proxy the

request to

dependency

server

Page 24: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Wiremock Code Snipets

Page 25: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Starting Up Wiremock Server

java -jar wiremock-1.53-standalone.jar --verbose --port 8080 --proxy-all=[Dependency Server DNS Name]

Page 26: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

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” )));

Page 27: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Simulating Fault

//This calls Wiremock API for fault injection

stubFor(get(urlEqualTo(“/some/thing”))

.willReturn(aResponse()

.withFault(Fault.EMPTY_RESPONSE)));

Page 28: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Benefits

• We fixed the CI/CD pipeline

• No more unnecessary test failures debugging

• Less production escapes and firefighting

Page 29: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Recap

The Second Challenge

• Integration tests failures broke CICD pipeline

• Hard to do resiliency testing

The Solution : Wiremock

Page 30: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Next Step

Why don’t we combine them?

Page 31: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Slingshot With Wiremock

Page 32: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Slingshot with Wiremock

W

ASG

Web

ASG

App

ASG

System Under Test

Region US-WEST-2

Availability Zone #1

Wiremock

ASG

Wiremock

Internet Gateway

Dependency

Server

AWS Region X / Datacenter X

Page 33: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Automate WM Deployment

Page 34: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

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

Page 35: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Automate Wiremock Deployment

We wrote a Wiremock Recipe

• Download the Wiremock jar

• Start up the Wiremock server

Page 36: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

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

Page 37: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

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 & }

Page 38: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Automate Wiremock Stack Creation

Use AWS CloudFormation API

• Provision EC2 instances and ELB

• Create Auto Scaling Group

• Set up other AWS resources

Page 39: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Use WireMock in Slingshot

Call Chef from CloudFormation

Page 40: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

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.

Page 41: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

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" },"'" ] ]

}

Page 42: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Benefits

• A simplified CI/CD pipeline onboarding

• A successful CI/CD pipeline with increased test pass rate

• Resiliency testing capability built in

• Security features built in

Page 43: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Deep Dives

Page 44: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Demo

SUT Wiremock

ServerYelpTest

Automation

Page 45: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Recap

Page 46: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Recap

Combined Solution: Slingshot with Wiremock

• CI/CD pipeline easy onboarding

• Builds are auto-promoted

• Less Engineers’ time spent on debugging

• Resiliency issue found before production

• Happy Engineers

Page 47: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

What we learned

Page 48: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

What We Learned

• The initial investment is worth it

• Try to be flexible

• Set up DNS

Page 49: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

References

• http://www.pnsqc.org/the-journey-of-mocking-in-aws/

• http://wiremock.org/

• https://www.chef.io/

• http://docs.aws.amazon.com/AWSCloudFormation/latest

/APIReference/Welcome.html

Page 50: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Related Sessions

Breakout Session:

ARC344

How Intuit Improves Security and Productivity with

AWS Virtual Networking, identity, and Account

Services

Track: Architecture

Session Level: Advanced (300 level)

Session Time: Thursday, Oct 8, 2:45 PM – 3:45 PM–

Palazzo

Page 51: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Contact

Lucy Chang

Sr. Software Engineer in Quality , Intuit

https://www.linkedin.com/pub/lucy-chang/11/312/a83

Alfred Tan

Sr. DevOps Manager, Intuit

https://www.linkedin.com/pub/alfred-tan/1/938/9b

Page 52: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Thank you!

Page 53: (DEV310) CI/CD of Services with Mocking & Resiliency Testing Using AWS

Remember to complete

your evaluations!


Recommended