WSO2 Test Automation Framework : Approach and Adoption

37
WSO2 Test Automation Framework Approach and Adoption By Krishantha Samaraweera Technical Lead, Test Automation Dharshana Warusavitharana Software Engineer, Test Automation

description

 

Transcript of WSO2 Test Automation Framework : Approach and Adoption

Page 1: WSO2 Test Automation Framework : Approach and Adoption

WSO2 Test Automation Framework

Approach and Adoption

By

Krishantha SamaraweeraTechnical Lead, Test Automation

Dharshana WarusavitharanaSoftware Engineer, Test Automation

Page 2: WSO2 Test Automation Framework : Approach and Adoption

About WSO2

● Providing the only complete open source componentized cloud platform

● Dedicated to removing all the stumbling blocks to enterprise agility● Enabling you to focus on business logic and business value

● Recognized by leading analyst firms as visionaries and leaders● Gartner cites WSO2 as visionaries in all 3 categories of application

infrastructure● Forrester places WSO2 in top 2 for API Management

● Global corporation with offices in USA, UK & Sri Lanka● 200+ employees and growing

● Business model of selling comprehensive support & maintenance for our products

Page 3: WSO2 Test Automation Framework : Approach and Adoption

150+ globally positioned support customers

Page 4: WSO2 Test Automation Framework : Approach and Adoption

Agenda● Requirements and early efforts of Automation in WSO2.

● Approach and Adoption.

● Framework overview.

● Adopting scenarios and flexibility.

● Architecture overview.

● Automation Framework Structure.

● Anticipating challenges of automation.

● Demos

○ Admin service client API base integration test.

○ Selenium integration test.

○ Test with tooling support (Jmeter).

Page 5: WSO2 Test Automation Framework : Approach and Adoption

Requirements Of Automation At WSO2● Should be easy to adopt and manage.

● The automated test suites are subject to run on

○ Integration

○ Platform

○ Private or public cloud

● Environments on User / Tenant mode.

● Single test case should be able to

run seamlessly on all above executions.

● Should be able to run with nightly build

systems such as Bamboo or Jenkins

Page 6: WSO2 Test Automation Framework : Approach and Adoption

Requirements Of Automation At WSO2

● Should be able to run existing Jmeter test scripts.

● Should support UI Automation.

● All tests should be available as deliverable artifact - Platform

Automated Test Suite.

● Open source and release under apache License.

● Coverage and Reporting.

Page 7: WSO2 Test Automation Framework : Approach and Adoption

History Of Automation In WSO2● Developed first UI test framework in 2009 based on Selenium.

● Separate framework for testing Data Services.

● Developed component test framework in 2010

● Developed Integration test framework in 2011 - AKA CTF

● Various ruby, perl, ant and shell scripts to automate product testing with different web application containers and databases.

● System Test Framework in 2012

● Framework unification - Test Automation Framework = Integration test framework + System test framework in 2012 August

Page 8: WSO2 Test Automation Framework : Approach and Adoption

Approach to Test Automation At WSO2

Test Automation approach/design

Test Automation

Requirements

Understanding testing

Environments

Understanding System Under

Test

Page 9: WSO2 Test Automation Framework : Approach and Adoption

What we will Automate at WSO2● Platform scenarios.

● Integration scenarios.

● UI scenarios.

● Real world use cases.

● Performance and Security scenarios.

● Patches provided.

Page 10: WSO2 Test Automation Framework : Approach and Adoption

Overview of Automation Framework

Test Automation Framework is to make automation

● Eazy

● Organized

● Relevant

● Optimized

Page 11: WSO2 Test Automation Framework : Approach and Adoption

Technology Outline

Test Framework Build Systems

Code Coverage

Tooling SupportExecution Environment

Page 12: WSO2 Test Automation Framework : Approach and Adoption

In Automation WSO2 is focusing on the following execution

scenarios.

● Integration tests - Which verifies the product build at build level.

○ User mode which allows run product as a standalone user.

○ Tenant mode Which allows product run as a cloud based

deployment.

● Platform tests - Which verifies the scenarios on platforms which

contains more than one WSO2 product or integration with different

platforms.

● Cloud based deployment test (Stratos based tests) - Which

executes the tests based targeting cloud deployments.

Adopting Scenarios

Page 13: WSO2 Test Automation Framework : Approach and Adoption

Flexibilities Provided By Automation Framework

● Manage several products inside single test.

● Manage users in several product domains.

● Deployment of artifacts for different products under different

users.

● Automatic authentication.

● Configured admin service clients as test oriented API.

● Retrieving test environment configurations easily.

● Running same test in both local and Stratos environments.

● Reporting TestNg and surefire reports for all your tests.

● Tooling support of Selenium and Jmeter.

Page 14: WSO2 Test Automation Framework : Approach and Adoption

Architecture Overview

● Depends on TestNg Listeners.

● Platform wide single framework

● Context providing interfaces.

● Admin Service based Automation API.

● Selenium page object repository and element mapper.

● Automation framework Utils.

● Coverage and Reporting.

Page 15: WSO2 Test Automation Framework : Approach and Adoption

Automation Framework Overall Architecture

user.csv / tenant.csv

automation.properties

instrument.txt

Result

Automation Framework CoreTest

Dashboard

MavenTest Managers

Test Suite

Surefire

TestNg Automation Framework API

Automation Framework Utills

User Populator

Coverage(emma

Server manager

Custom Reporter

Context Provider

Page 16: WSO2 Test Automation Framework : Approach and Adoption

Framework Core

Core

PlatformExecutionManager

PlatformSuiteManager

PlatformTestManager

PlatformAnnotationTransferManager

PlatformInvokedMethodManager

PlatformReportManager

Environment Context

Framework Annotations

Artifact Management

User Management

Server ManagementCoverage

Custom Error Reporting

Page 17: WSO2 Test Automation Framework : Approach and Adoption

Execution Template - TestNg

Execution Started@BeforeSuite

@AfterSuite

Execution Closed

@BeforeTest

@AfterTest

@BeforeClass

@BeforeGroups

@BeforeMethod

@AfterMethod

@AfterGroups

@AfterClass

Reference:- http://www.ibm.com/developerworks/java/library/j-testng/

Page 18: WSO2 Test Automation Framework : Approach and Adoption

TestNg Listeners● Listeners are interfaces allows to modify TestNG's

behavior.

● Listeners are binned to a testNg execution.

● Listeners implement the interface org.testng.ITestListener○ IExecutionListener

■ Triggers at start and end of any execution.■ ISuiteListener.

○ ITestListner■ Triggers at suite start and end.■ Triggers at Test start, Finish, Failure, Skip and partial failure.

● Reporters implement the interface org.testng.IReporter ○ Notified when all the suites have been run by TestNG. ○ The IReporter instance receives a summary of entire test run

Page 19: WSO2 Test Automation Framework : Approach and Adoption

Usage of Listeners

● PlatformExecutionManager (IExecutionListener)○ onExecutionStart()

■ Emma instrumentations

■ Server start

○ onExecutionFinish()

■ Server Shutdown

■ Emma report generation

● PlatformSuiteManager (ISuiteListener)○ Set environment properties ex- Key Store Paths

○ Populate Users.

Page 20: WSO2 Test Automation Framework : Approach and Adoption

Usage of Listeners contd..

● PlatformReportManager (IReporter)○ Generate TestNg Report

○ Generate surefire report

○ Export data for Dashboard

● PlatformInvokedMethodManager (InvokedMethodListener)○ Artifact deployment in platform scenarios.

● PlatformAnnotationTransferManager (IAnnotationTransformer)○ Annotation-Platform-user type based test selection.

Page 21: WSO2 Test Automation Framework : Approach and Adoption

Context providing interfaces

● Execution Based context - automation.properties

● Platform Based Context - automation.properties

● User Based Context - user.csv / tenant.csv

● Coverage Based Context - instrumentation.txt

Page 22: WSO2 Test Automation Framework : Approach and Adoption

Automation Properties

stratos.test=false#execution.environment = integration|platform|stratosexecution.environment=integration#execution.mode = user|tenant|allexecution.mode=userport.enable=truecarbon.web.context.enable=falseservice.deployment.delay=30000cluster.enable=trueproduct.list=ESBbuilder.enable=truecoverage.enable=true

● To configure Test framework

for the environment and

configure package details

● Contains all information about The environment.

Page 23: WSO2 Test Automation Framework : Approach and Adoption

Context provider Architecture

user.csv / tenant.csv

automation.properties

instrument.txt

EnvironmentContext

ContextProvider

GroupContextProvider

NodeReader

UrlGenerator

NodeContextProvider

Result

Global Context

FrameworkContextProvider

UserInfoReader

Global Context

Test

Context Initiator

Page 24: WSO2 Test Automation Framework : Approach and Adoption

Server Management

● Needs to configure the server and start the server with in the

test case.

● Most of the cases it might be ○ Single serve with single instance

○ Single server with multiple instance

○ Multiple product servers in a clustered environment.

● In this module framework is managing○ Extract and configure the server.

○ Add offsets and deploy custom modules needs for the test.

Page 25: WSO2 Test Automation Framework : Approach and Adoption

Test Execution Modes● Handled by a custom annotation introduced at test class and method level

● Annotations are based on the execution environment and the user type of the test

● Tests are skipped at the "PlatformAnnotationTransferManager"

● integration_all, integration_user, integration_tenant, platform_all, platform_user,

platform_tenant, stratos, all

@SetEnvironment(executionEnvironments = {ExecutionEnvironment.integration_all})

public void createGroup() throws Exception

{ }

#execution.environment = integration|platform|stratosexecution.environment=integration#execution.mode = user|tenant|allexecution.mode=user

Page 26: WSO2 Test Automation Framework : Approach and Adoption

Automation Framework API

● Test Friendly api wrapping service stubs.

○ Depends on service stubs.

○ Provides unified approach for perform verify and assert

of each admin service.

● Encapsulates the complexity of changing all available tests

in a case of a stub change.

● Maintain Page object classes for Selenium Automation.

● Using UI maps to store locators required for test scripts.

● Updates with the relevant release version.

Page 27: WSO2 Test Automation Framework : Approach and Adoption

Automation Framework Utils● Includes all utility classes that can play supportive role inside a

test.

○ Ex :-

■ Axis2 Client.

■ Wire message monitor.

■ Custom server startup scenarios (Axis2, Tomcat,Qpid).

■ Concurrency test scenarios.

● Provides common methodology for all development teams to

maintain a set of supportive classes without changing the Core.

● Reusability of utility methods in integration and platform tests.

Page 28: WSO2 Test Automation Framework : Approach and Adoption

Reporting

● Includes TestNg reports ,

SureFire report, And Emma

Coverage report

● Directories containing separate

results for each suite ( Directory

name is as same as the suite

name).

● Surefire reports.

● index.html (Dashboard for

executed test).

|-- reports | |-- BPSStructuredSuite | | |-- classes.html | | |-- FlowClient.html | | |-- FlowClient.properties | | |-- FlowClient.xml | | |-- ForEachClient.html | | |-- ForEachClient.properties | | |-- ForEachClient.xml | |-- index.html | |-- junitreports | | |-- TEST-org.wso2.automation.common.test.bps.mgts.BpelStructAct_FlowClient.xml | | |-- TEST-org.wso2.automation.common.test.bps.mgtst.BpelStructAct_forEachClient.xml

Page 29: WSO2 Test Automation Framework : Approach and Adoption

Platform Automated Test Suite● Distribution contain product integration and platform test jars.

● ANT based test jar executor - using TestNg ant task

● Ability to execute tests on different environments.

● Provide options to run test suites, packages and individual

classes.

● TestNg reports.

● Generate mail with test results.

● Preview build available at https://svn.wso2.

org/repos/wso2/people/krishantha/wso2pats-1.1.2.zip

Page 30: WSO2 Test Automation Framework : Approach and Adoption

Future Challenges ● Getting others to believe on automated tests.

● Improve coverage on Integration test scenarios.

● Adopting framework demanding requirement changes.

● Adopting framework with complex deployment scenarios.

Page 31: WSO2 Test Automation Framework : Approach and Adoption

Project Structure of Automated Tests

Page 32: WSO2 Test Automation Framework : Approach and Adoption

Coverage Statistics

Product Name LOC Coverage Class Coverage

ESB 38% 66%

G-Reg 46% 65%

DSS 49% 73%

CEP 57% 74%

MB 47% 90%

AS 20% 36%

API-Mgt 21% 42%

● Included only integration test coverage.

● Also guarded by loads of dependency and component level unit tests.

● UI test coverage not included.

Page 33: WSO2 Test Automation Framework : Approach and Adoption

Write First Integration Test : Demo 1Scenario To be Automated:

Deploy a webapp on WSO2 application server and invoke it once deployed successfully. Then remove the webapp at the end of test execution.

Page 34: WSO2 Test Automation Framework : Approach and Adoption

Write First Selenium Test : Demo 2Scenario To be Automated:

Deploy a webapp through admin console as a war file and invoke once deployed successfully.

Page 35: WSO2 Test Automation Framework : Approach and Adoption

Write Fist Jmeter Test : Demo 3Scenario To be Automated: Deploy Simple Axis2Service on WSO2 Application Server and invoke it. Then remove the service at the end of test execution.

Page 36: WSO2 Test Automation Framework : Approach and Adoption

Questions?

Page 37: WSO2 Test Automation Framework : Approach and Adoption

Engage with WSO2

● Helping you get the most out of your deployments● From project evaluation and inception to development

and going into production, WSO2 is your partner in ensuring 100% project success