Kubernetes your tests! automation with docker on google cloud platform

43
By Arik Lerner & Waseem Hamshawi Kubernetes your Tests! Testing with Docker on Google Cloud Platform The Journey Based On True Story!

Transcript of Kubernetes your tests! automation with docker on google cloud platform

Page 1: Kubernetes your tests! automation with docker on google cloud platform

By Arik Lerner & Waseem Hamshawi

Kubernetes your Tests! Testing with Docker on Google Cloud Platform

The JourneyBased On True Story!

Page 2: Kubernetes your tests! automation with docker on google cloud platform

{

“Name”: “Arik Lerner”,

“Role”: “Automation Infra Team Leader at LivePerson”,

“Data”: [

“3 years as Team Leader in Liveperson” ,

“2 years Java developer Reporting Platform Liveperson”

],

“Hobbies”: “Private pilot”

}

Active Prevention Department

Page 3: Kubernetes your tests! automation with docker on google cloud platform

{

“Name”: “Waseem Hamshawi”,

“Role”: “Senior Automation Infra Developer at Liveperson”,

“Data”: [

“2.5 years at Liveperson”,

“github: waseemh.github.io”,

],

“Hobbies”: “Running”

}

Waseem is Here!

Active Prevention Department

Page 4: Kubernetes your tests! automation with docker on google cloud platform

Short Story

From Manual Post Deployment Verification

TOAutomation

Page 5: Kubernetes your tests! automation with docker on google cloud platform

❏ Fast feedback

❏ Stable Environment

❏ Isolation

❏ Investigation tools - Hard to support (Video/HAR)

❏ Scale

❏ Efficiency

❏ Browser diversity

❏ Mobile Support

Requirements

Page 6: Kubernetes your tests! automation with docker on google cloud platform

Selenium HubRunning Test

Static VMs

Supported Requirements

Browser diversity

Mobile Support

Parallelism

Traditional Selenium Grid

Page 7: Kubernetes your tests! automation with docker on google cloud platform

Ranking:

Tooling

Deployment/Configuration

Feedback

Isolation

Efficiency

Scalability

❏ Less stable❏ Crashes - require restarts❏ Cancel build in progress leave open sessions

❏ Investigation tools - Hard to support (Video/HAR)

❏ Manual grid node Configuration/deployment

❏ Not scalable

❏ Slow feedback

❏ Not efficient - idle grid machines

Facing Issues

Page 8: Kubernetes your tests! automation with docker on google cloud platform
Page 9: Kubernetes your tests! automation with docker on google cloud platform

Cattle vs. Pets

VM

Container

● When they get ill you nurse them back to health

● You name them! And take of them!

● When they get ill you get another one!

● They are almost identical to one another

● Don't have specific names. Given numbers

● Can be simply replaced if they die

Page 10: Kubernetes your tests! automation with docker on google cloud platform

What Docker gives us ?

● Build it once run it everywhere!

● Resource Isolation

● Test Isolation

● Package format

● Implementation of a container

Docker

Page 11: Kubernetes your tests! automation with docker on google cloud platform

Chrome FirefoxVNC Server

Selenium Server Hub/Node JAR

Mobile Android

What is in a Selenium Container ?

Page 12: Kubernetes your tests! automation with docker on google cloud platform

VM

VM

VM

VM

NodesHUB

N Hub’s

Running Tests

Selenium Grid Architecture Makeover

Page 13: Kubernetes your tests! automation with docker on google cloud platform

Selenium Docker Images

hub.docker.com/r/selenium

Page 14: Kubernetes your tests! automation with docker on google cloud platform

DEMO

Page 15: Kubernetes your tests! automation with docker on google cloud platform

We need more than just Packaging and Isolation:

● Orchestration - Distribute containers

● Health Checks

● Resilience and Self-healing

● Scaling - making jobs bigger or smaller

Kubernetes Orchestrator

Page 16: Kubernetes your tests! automation with docker on google cloud platform

VM

VM

VM

VM

PodsHUB

N Hub’s

Running Tests

Selenium Grid Architecture Makeover

Page 17: Kubernetes your tests! automation with docker on google cloud platform

Testing on the Cloud!

Page 18: Kubernetes your tests! automation with docker on google cloud platform

Benefits of Cloud Platform

● Kubernetes cluster in a click of a button (GCP)

● No idle machines - Use when needed

● Costs per build/test - measurable

● Not part of Liveperson network

● Geolocation simulation

Page 19: Kubernetes your tests! automation with docker on google cloud platform

DEMO

Page 20: Kubernetes your tests! automation with docker on google cloud platform

Build Life Cycle

Page 21: Kubernetes your tests! automation with docker on google cloud platform

GCP - Selenium Grid lifecycle

Run tests

Kill Selenium Grid

Scale Down GCP Instances

Scale Out GCP Instances

Create Selenium Grid container cluster

Page 22: Kubernetes your tests! automation with docker on google cloud platform

Requirements

Page 23: Kubernetes your tests! automation with docker on google cloud platform

Requirements

❏ Fast feedback

❏ Stable Environment

❏ Isolation

❏ Investigation tools - Hard to support (Video/HAR)

❏ Scale

❏ Efficiency

❏ Browser diversity

❏ Mobile Support

Page 24: Kubernetes your tests! automation with docker on google cloud platform

Ranking:

Tooling

Deployment/Configuration

Feedback

Isolation

Efficiency

Scalability

❏ Investigation tools - Video tools not reliable and not stable.

❏ Feedback ❏ Improved BUT still needs to wait for nodes to

connect into Hub❏ Point of failures

❏ Hub/Nodes is more failure points in the architecture that not really necessary

Facing Issues

Page 25: Kubernetes your tests! automation with docker on google cloud platform
Page 26: Kubernetes your tests! automation with docker on google cloud platform

waseemh-mac$ java -jar selenium-server-standalone-2.53.1.jar -role

Selenium server can run in one of the following roles: hub as a hub of a Selenium grid node as a node of a Selenium grid standalone as a standalone server not being a part of a grid

Test Hub Selenium Server(Node)

Selenium Standalone

Page 27: Kubernetes your tests! automation with docker on google cloud platform

Non-Grid Solution● Fast → Deploy Selenium Standalone containers on-demand● Short-lived → Selenium containers are destroyed once test ends● Distribute and manage containers with Kubernetes

TestcreateRemoteWebDriverSession(caps)

VM

VM

VM

VM

new RemoteWebDriver(External Endpoint)

Page 28: Kubernetes your tests! automation with docker on google cloud platform

Test Cluster

?

Page 29: Kubernetes your tests! automation with docker on google cloud platform

github.com/LivePersonInc/ephemerals

Ephemerals

Page 30: Kubernetes your tests! automation with docker on google cloud platform

Ephemerals API

Deploy

Endpoint IP:Portnew RemoteWebDriver(Endpoint IP:Port)

createRemoteWebDriver(desiredCapabilities)

TestTestTestTestTestTestTestTestTest

Page 31: Kubernetes your tests! automation with docker on google cloud platform

JUnit Integration@Rulepublic EphemeralResource<RemoteWebDriver> seleniumResource =

new EphemeralResource( new SeleniumEphemeral.Builder(deploymentContext) .withBrowser(FIREFOX_42) .withVideoRecording(true) .build());

@Testpublic void test() { RemoteWebDriver remoteWebDriver = seleniumResource.get(); .....}

Page 32: Kubernetes your tests! automation with docker on google cloud platform

DEMO

Page 33: Kubernetes your tests! automation with docker on google cloud platform

Challenges● Appium crashes/unresponsive, adb server restarts

● Android SDKs environment installation/maintenance

● Appium↔WebDriver API Versions Incompatibility

● Difficult to parallelise mobile tests● Scale mobile tests ?!

Mobile Testing

Emulator

Page 34: Kubernetes your tests! automation with docker on google cloud platform

Ephemeral’s Way

Emulator

Appium WebDriver

Test

Install (APK URL)

Ephemerals API

createMobileDriver(capabilities) Deploy

Appium Endpoint IP:Port

new AndroidDriver(Appium IP:Port)

Page 35: Kubernetes your tests! automation with docker on google cloud platform

DEMO

Page 36: Kubernetes your tests! automation with docker on google cloud platform

Requirements

Page 37: Kubernetes your tests! automation with docker on google cloud platform

Ranking:

Tooling

Deployment/Configuration

Feedback

Isolation

Efficiency

Scalability

Requirements

❏ Fast feedback

❏ Stable Environment

❏ Isolation

❏ Investigation tools - Hard to support (Video/HAR)

❏ Scale

❏ Efficiency

❏ Browser diversity

❏ Mobile Support

Page 38: Kubernetes your tests! automation with docker on google cloud platform

Beyond Selenium...

Deploy any test dependency inside a container

● Web Servers (/modules/nginx)● Temporary Databases (/modules/mysql)● Mock Servers (/modules/wiremock)● Any Docker Image (/modules/custom)

Page 39: Kubernetes your tests! automation with docker on google cloud platform

Talking Together...

Web Application

Nginx Ephemeral Selenium Ephemeral

EP

Test Script

EP

WireMock Ephemeral

EP

RESTAPI

HTTP

Page 40: Kubernetes your tests! automation with docker on google cloud platform

Ephemerals - Future Plans

● REST API (for non-Java tests)

● Support more cluster management systems:

○ Apache Mesos

○ Docker Swarm

● More modules

Page 41: Kubernetes your tests! automation with docker on google cloud platform

Takeaways

● Enhance traditional Selenium tools

● Containerization - Short lived, throwaway instances

● Scalable tests with Containers Orchestration

● Benefits of Testing on Cloud Platforms

Page 42: Kubernetes your tests! automation with docker on google cloud platform
Page 43: Kubernetes your tests! automation with docker on google cloud platform

THANK YOU!