This example shows a complete end to end test of an ATM Banking Application. By Writing a simple Groovy script with less than 175 lines of code, we will execute a complex end to end work flow that will accomplish the following:
• Populate an empty database with programmed and conditioned data
• Simulated a complex end-to-end workflow that successfully generated:
• 1,000 Branches
• 40,000 Visa Debit Cards
• 10,000 Users
• 20,000 Customer Accounts
• 10,000 Checking
• 10,000 Savings
3. Make thousands of deposits, transfers, and withdrawals to test the ATM's workflows
In total, this test plan will simulate 169,943 combined withdrawal, deposit, and transfer transactions.
Scenarios and Configuration Files
The following sections provide a detailed break down of the Scenarios, configuration files and source code used to implement the end to end solution:
Scenarios
Nine Scenarios were used to accomplish all of the tasks in the end to end test.
- AccountDepositRestScenario.grs - Executes bank deposits over REST
- AccountTransferRestScenario.grs - Executes bank transfers over REST
- AccountTypeRestScenario.grs - Inserts new AccountTypes into the database over REST
- AccountWithdrawalRestScenario.grs - Executes back withdrawals over REST
- BranchRestScenario.grs - Inserts new Branches into the database over REST
- CardPoolRestScenario.grs - Inserts new Credit Cards into the CardPool table in the database over REST
- CardTypeRestScenario.grs - Inserts new Credit Card Types into the database over REST
- CustomerLevelRestScenario.grs - Inserts new Customer Levels into the database over REST
- OpenAccountRestScenario.grs - Opens user Checking and Savings accounts over REST
Configuration Files
Each configuration file is read by its respective Scenario to retrieve the URL for making a REST web service request. The URL was placed in the configuration file so that the URL could be modified to test on different testing environments where the URLs may be necessarily different.
- AccountDeposit.config
- AccountTransfer.config
- AccountType.config
- AccountWithdrawal.config
- Branch.config
- CardPool.config
- CardType.config
- CustomerLevel.config
- OpenAccount.config
AccountDeposit.config
AccountTransfer.config
AccountType.config
AccountWithdrawal.config
Branch.config
CardPool.config
CardType.config
CustomerLevel.config
OpenAccount.config
The Groovy Script
This section details the 175 line Groovy script that runs the end to end test/workflow. Here, the script is broken apart into different sections and each section is given a brief explanation.
Global Variables
Helper Methods
The helper methods do the following:
- elapsedTime - Calculates the time that has elapsed between a given start time and the current time.
- getConnection - connects to a local MySQL database via JDBC
- emptyTables - connects the genrocket_bank database and deletes all data from all tables
- getAverageBalance - calculates the average balance for checking or savings account
Initializing The Database
The simulation starts out with an empty database. Using the GenRocket API, the initialization method will directly load and execute four GenRocket Scenarios to populate the AccountType, CardTypes, CustomerLevels, TransactionTypes. It will also populate Branches and CardPool, by first dynamically setting the Branch loopCount to 1,000 and the cardPool loopCount to 40,000.
Simulation
For the running of the full end to end test/workflow, the method sumulationOne(), contains the business logic that follows the flow of the Activity Diagram shown below. The code logic will make decisions when withdrawals, deposits or transfers are made and dynamically load, modify and run the appropriate GenRocket Scenario that will immediately start generating the appropriate transactions in real time using the GenRocket RealtimeTestReceiver.
Simulation Activity Diagram
Simulation Pseudo Code
If you're not familiar with reading Activity Diagrams, here's pseudo code that explains the same workflow.
1: execute 10,000 withdraws from checking, 1 for each customer
check average checking balance across all customers
if (average checking > $500)
goto 1:
for each customer
transfer $750 from savings to checking
check average savings balance across all customers
if (average savings > $1500)
goto 1:
for each customer
deposit $2000 into checking, transfer $1500 from checking to savings
end simulation
SimulationOne Method
Details on How We Modified the AccountTransferRestScenario in Realtime
The video below (1 min 26 secs) will show how, in the simulation, we were able to dynamically modify the AccountTransferRestScenario, to switch transferring funds from a user's checking to savings, to transferring funds from a user's savings to checking; thus showing the power and flexibility one can have manipulating GenRocket Scenarios in realtime.