How to Configure and Execute Tests on Clarity

  • By Dharshana Warusavitharana
  • 22 Jun, 2012

Pre-requisite:

JAVA JDK 1.6

Maven 3.

Introduction

WSO2 Clarity is a platform wide test automation solution for all WSO2 platform based products and cloud platform.WSO2 Clarity provides well defined infrastructure to write your tests and execute them in a easy manner.Clarity takes care most of your pains while you writing and executing automated tests. WSO2 Clarity provide the facility to write your test over several WSO2 products and configure them through Deployment Framework and start shutdown servers in a distributed production setup. WSO2 Clarity also provides third party tool support such as Selenium, Jmeter and SoapUi.

These are the steps to follow to setup Clarity on your machine.

1. Checkout  and build Clarity.

You can checkout Clarity from https://svn.wso2.org/repos/wso2/carbon/platform/trunk/platform-integration/system-test-framework


You will find the followind directory structure under <FRAMEWORK_HOME>

        |-- core
        |   |-- org.wso2.automation.platform.core
        |   |   |   |   `-- resources
        |   |   |   |       |-- artifacts
        |   |-- org.wso2.automation.test.api
        |   `-- org.wso2.automation.tools.core
        |-- reports
        |-- scenario
        |   |-- integration
        |   |   |-- org.wso2.automation.common.integration.perf
        |   |   `-- org.wso2.automation.common.integration.tests
        |   `-- platform
        |       `-- org.wso2.automation.cloud.platform.test
        `-- tools
            |-- jmeter
            |-- ravana
            |-- selenium
             `-- soapui

Now you have the package . Next you have to build the package using maven 3.

$mvn clean install -Dmaven.test.skip=true

2. Configuring Clarity for current environment

You can find framework property file which is located at the

<FRAMEWORK_HOME>/core/org.wso2.automation.platform.core/src/main/resources/framework.properties

This file contains all information about your environment. To configure WSO2 Clarity for your environment and configure package details you have to configure this property file.

2.1. Setting up the running environment

Clarity can use to execute tests on both Local and Stratos environments. Because you have to specify whether you are running on Stratos or not.
For this you have to set the property.

stratos.test=true
-Configured to run on Stratos setup.
stratos.test=false
-Configured to run on a local setup.

Apart of configurations for stratos you can add more configurations applicable to your current environment.

Some examples are shown below.

port.enable
-Configured to run with out initiating ports.
carbon.web.context.enable=false
-Configured to enable web context root.
service.deployment.delay=30000
-Configured leadtime to deploy services.

2.2.  Initiate product list and cloud Services


As per the production setup you may use selected set of WSO2 products.
For initiate product list you have to set the property “product.list
Add product code separated by the ","

product.list=BPS,AS,ESB

Product code reference.

AS = 'wso2as'
ESB = 'wso2esb'
GREG = 'wso2greg'
DSS ='wso2dataservices'
BPS = 'wso2bps'
IS = 'wso2is'
MS = 'wso2ms'
MB = 'wso2mb'
GS = 'wso2gs'
CEP = 'wso2brs'
BAM    = ‘wso2bam’

2.3. Setting Deployment Framework

Clarity Supports automated system configuration and server Startup/Shutdown process using script based configuration tool named  Deployment Framework.

deployment.framework.enable=true

For enabling Deployment framework and provide Deployment Framework path.

deployment.framework.home=/path/to/deployment-framework

Charity can be used to start and stop servers automatically. In order to start the servers automatically, you have to enable the deployment framework and set the path to framework as specified above.

Also, you can start the servers manually and run the framework by setting the deployment framework to false.

deployment.framework.enable=false
deployment.framework.home=/path/to/deployment-framework

2.4. Setting product environment.

For local setup you can configure host name , http port and https port , nhttp port and qpid port for each product you are using with in the product setup.

as.host.name=localhost
as.http.port=9764
as.https.port=9444

mb.host.name=localhost mb.http.port=9770 mb.https.port=9450 mb.qpid.port=5675
esb.host.name=localhost esb.http.port=9765 esb.https.port=9445 esb.nhttp.port=8280 esb.nhttps.port=8245

For Stratos setup you can configure host names like

app.service.host.name=appserver.stratoslive..wso2.com
esb.service.host.name=esb.stratoslive.wso2.com
greg.service.host.name=governance.stratoslive.wso2.com

2.5. Setting Selenium

The Clarity is giving support to include selenium tests with in your tests through selenium web driver
Sample selenium configuration is shown below.

browser.name=firefox             (chrome|firefox|opera|ie|htmlUnit) 
path.to.chrome.driver="/path/to/chromedriver"

#run selenium test on remote browser or not. (true|false)

remote.selenium.web.driver.start=false
remote.webdirver.url=http://hostName:4444/wd/hub/

2.6 Setting Data source

To provide your existing database for Clarity tests you have to configure database section . sample configuration is mentioned below. Mainly DB settings are used by dataservices.

database.driver.name=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306
db.user=root
db.password=root123
db.name=testDb

RSS Data Source configuration in Stratos. this user name and  password are used to create a user on RSS Manager in stratos and used in .dbs file as well

rss.database.user = tstusr1
rss.database.password =test123

3. Executing tests on Clarity

Clarity consists tests targeting individual product functionalities and test scenarios covering whole WSO2 platform.

3.1 Clarity test structure.

scenario
   |-- integration
   |   |-- org.wso2.automation.common.integration.perf
   |   `-- org.wso2.automation.common.integration.test
   `-- platform
       `-- org.wso2.automation.cloud.platform.test



Tests that are covering features of a individual products are available on the “integration” package. Test scenarios which use one or more WSO2 products come under platform module.

WSO2 Clarity provides capability to execute platform wide tests for a production setup consists of several WSO2 products. The tests which are consists of platform wide coverage are contained in the platform package.

3.2 Test Naming standards followed  by Clarity.

Clarity uses TestNg to execute tests so Clarity follows TestNg testing structure. Every testing package contains a test suite which are covering the particular scenario. In order to execute tests focusing on the scenarios you may need to have a quick look at the Naming of test suites used in the Clarity

[<productName>][<name of the Test>]TestSuite.java

For reference of [<productName>] please refer to section 2.2

3.3 Executing tests



For execute tests by using maven ,Assuming you have already build the Clarity

For execute applicable tests available in the Clarity  for initiated products

$mvn test

For run tests for a single product you can use ( Sample product WSO2 App Server)

$mvn test -Dtest=AS*TestSuite -DfailIfNoTests=false

Likewise you can run individual test by just providing the test name

$mvn test -Dtest=StratosAppServiceTest -DfailIfNoTests=false

4 Reporting

After executing the tests you can find the reports under reports directory.

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


In report directory it includes


1. Directories containing  separate results for each suite ( Directory name is as same as the suite name).
2. Junit Reports ( Surefire reports).
3. index.html (Dashboard for executed test).

Dharshana Kasun Warusavitharana

Software Engineer - Test Automation