Upload
wso2
View
2.103
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
WSO2 Test Automation Framework
Approach and Adoption
By
Krishantha SamaraweeraTechnical Lead, Test Automation
Dharshana WarusavitharanaSoftware Engineer, Test Automation
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
150+ globally positioned support customers
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).
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
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.
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
Approach to Test Automation At WSO2
Test Automation approach/design
Test Automation
Requirements
Understanding testing
Environments
Understanding System Under
Test
What we will Automate at WSO2● Platform scenarios.
● Integration scenarios.
● UI scenarios.
● Real world use cases.
● Performance and Security scenarios.
● Patches provided.
Overview of Automation Framework
Test Automation Framework is to make automation
● Eazy
● Organized
● Relevant
● Optimized
Technology Outline
Test Framework Build Systems
Code Coverage
Tooling SupportExecution Environment
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
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.
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.
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
Framework Core
Core
PlatformExecutionManager
PlatformSuiteManager
PlatformTestManager
PlatformAnnotationTransferManager
PlatformInvokedMethodManager
PlatformReportManager
Environment Context
Framework Annotations
Artifact Management
User Management
Server ManagementCoverage
Custom Error Reporting
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/
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
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.
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.
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
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.
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
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.
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
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.
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.
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
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
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.
Project Structure of Automated Tests
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.
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.
Write First Selenium Test : Demo 2Scenario To be Automated:
Deploy a webapp through admin console as a war file and invoke once deployed successfully.
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.
Questions?
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