Load testing is an inherent part of the software testing life-cycle. It allows software testers to determine, how a newly developed software application performs under normal and peak conditions. To execute load testing, a software tester has to update large amounts of data to simulate a real-time scenario. But what about the test data after completion of load testing? Data certainly has to be cleaned up; an important activity of a software tester after completion of load testing is data cleanup. Data has to be cleaned up to ensure it does not influence the regression testing.

Data Cleanup

This blog aims to provide broad insights on the process of cleaning up workflow data, which is generated during load testing. We would be focusing largely on the workflow data generated using the Bonitasoft BPM tool. The approach outlined in this blog is useful to integrate the Bonita engine using the Bonitasoft REST API from any client.

Real-time Illustration

An instance of a workflow project that was executed using Bonita has been cited to help readers understand real-time challenges faced during the course of workflow process implementation. The scope of the workflow project was to automate case creation utilizing the data available in a spreadsheet (MS Excel format). The entire process had to be automated using Bonita tool.

Data Cleanup Challenges

The development team successfully created the software application as per client’s requirement. It was now left to the software testing teams to undertake testing, which also comprised load testing. The testing team decided to create cases ranging from 1,000 to 10,000 to test the Bonita application. The next challenge a software tester confronts after completion of load testing is data cleanup, which is a critical process, as any residual data can impact other software tests. So, how do you clean up the load testing data?
A software tester generally has two options for data cleanup:

  1. Clean up the data by simply deleting the .bar file from “Apps” tab in the admin console. However, due to the enormous volume of load test cases, the deletion process is rather slow or at times fails, showing a ‘transaction timeout’ message.
  2. The second option is to delete bulk data, using the Bonitasoft client API, which is faster and ideal for cases where a large amount of data is involved.
How to Configure Bonitasoft Client API Project

The first step is to create a Maven project in your IDE (based on your preference). Add the Bonitasoft library and its dependencies in the pom.XML file as mentioned below.
[xml]
<dependency>
<groupId>com.bonitasoft.engine</groupId>
<artifactId>bonita-server-sp</artifactId>
<version>${bonita.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bonitasoft.engine</groupId>
<artifactId>console-server-sp</artifactId>
<version>${bonita.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bonitasoft.engine</groupId>
<artifactId>bonita-common-sp</artifactId>
<version>${bonita.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bonitasoft.engine</groupId>
<artifactId>bonita-client-sp</artifactId>
<version>${bonita.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>xmlpull</groupId>
<artifactId>xmlpull</artifactId>
<version>1.1.3.1</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3_min</artifactId>
<version>1.1.4c</version>
</dependency>
[/xml]

Bonita Client Program – Data Cleanup

After creation of a Maven project with the required Bonitasoft dependencies. Write a Java main program, which can interact with the Bonitasoft server using the REST API

Define the API type and Bonita parameters:

Add the following parameters to define the API type, which will be used by a client program to communicate with the Bonita engine.
[java]
Map<String, String> map = new HashMap<String, String>();
map.put("server.url", "http://localhost:8081");
map.put("application.name", "bonita");
APITypeManager.setAPITypeAndParams(ApiAccessType.HTTP, map);
[/java]

Log on to Bonita using Login API:

[java]
final LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();
// log in to the tenant to create a session
final APISession session = loginAPI.login(USER_NAME, PASSWORD);
[/java]
The above session needs to be passed to the Bonita tool to access any engine API.

Workflow process cleanup instances:

Obtain respective process definition IDs using process API’s as mentioned below:
[java]
ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI(session);
long processId = processAPI.getProcessDefinitionId(PROCESS_NAME, VERSION);
[/java]
Utilize any of the following methods of process API’s to delete process instances:
[java]
ProcessAPI. deleteProcessInstances(long processDefId, int start, int end)
ProcessAPI. deleteArchivedProcessInstances(long processDefId, int start, int end)
ProcessAPI. deleteProcessInstance(long processInstanceId)
[/java]
Below are the instructions to delete open cases:

Delete Open Cases

[java]
List<ProcessInstance> openCases = processAPI.getProcessInstances((int) processId, 1000, ProcessInstanceCriterion.DEFAULT);
for(ProcessInstance pi : openCases) {
processAPI.deleteProcessInstance(pi.getId());
}
[/java]

Delete Archived Cases in Batches:

[java]
int i = 0;
while(i<100) {
long deletedCount = processAPI.deleteArchivedProcessInstances(processId, 1, 10);
i++;
}
[/java]

Cleanup Process Definitions:

[java]
processAPI.disableAndDeleteProcessDefinition(processId);
[/java]

Log out from the Bonita Tool:

[java]
loginAPI.logout(session);
[/java]

Here’s the Complete Main Client Program Code:

[java]
public class ProcessCleanupClient {
private static final String SERVER_URL = "http://localhost:8081";
private static final String APPLICATION_NAME = "bonita";
private static final String USER_NAME = "admin";
private static final String PASSWORD = "bpm";
private static final String PROCESS_NAME = "Sample_Process";
private static final String VERSION = "2.00.06";
static {
// Define the REST parameters
Map<String, String> map = new HashMap<String, String>();
map.put("server.url", SERVER_URL);
map.put("application.name", APPLICATION_NAME);
APITypeManager.setAPITypeAndParams(ApiAccessType.HTTP, map);
}
public static void main(String[] args) {
LoginAPI loginAPI = null;
APISession session = null;
try {
// get the LoginAPI using the TenantAPIAccessor
loginAPI = TenantAPIAccessor.getLoginAPI();
// log in to the tenant to create a session
session = loginAPI.login(USER_NAME, PASSWORD);
final LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();
ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI(session);
long processId = processAPI.getProcessDefinitionId(PROCESS_NAME, VERSION);
//delete open cases
List<ProcessInstance> openCases = processAPI.getProcessInstances((int) processId, 1000, ProcessInstanceCriterion.DEFAULT);
for(ProcessInstance pi : openCases) {
processAPI.deleteProcessInstance(pi.getId());
}
//delete archived cases
int i = 0;
while(i<100) {
long deletedCount = processAPI.deleteArchivedProcessInstances(processId, 1, 10);
i++;
}
//delete process definition
processAPI.disableAndDeleteProcessDefinition(processId);
} catch(Exception e) {
//handle exception here
} finally {
//logout
if(loginAPI != null && session != null) {
loginAPI.logout(session);
}
}
}
}
[/java]

Summary

Cleaning up data post completion of load testing can be critical task, if not planned and executed meticulously, it can impact other test results. The above suggestions will certainly be helpful to software testers for effectively managing data cleanup activities, especially for workflow processes that have been created using the Bonita tool.

Author

Hari Prasad Alla is a Associate Technical Architect at Evoke Technologies. He has strong expertise in requirements analysis, design, implementation and release. He has technically adept in Bonitasoft BPM, Java, Spring MVC, Spring Batch, Spring Integration, Hibernate, Web Services (SOAP, REST), JMS, Jasper reports, Hadoop and NoSQL (MongoDB).
Please follow and share

1 Comment

  1. Ajitesh

    December 4, 2014

    Great write-up!

Leave a comment