Thursday, May 22, 2008

Concurrency Testing

Concurrency testing can be defined as the behavior and state of data when different users access the same data. The transition and business processing for the data is also an important aspect in this testing. Concurrency testing can be done by Team effort and only team effort. Users should define a strategy how many users will access and what set of data. Once this is freezed, the hardware requirements to do the same (preferable the hardware used should be of the same specifications). In any applications Concurrency testing is one of the important phases. Most of the times due to time constraints this phase is ignored or this is not done at all. Check the below example which will display the importance of doing concurrency testing. Mr. A is an account holder in a bank B. He issued a check to one of his friends Mr. C for 50,000/- on a certain date. Mr. A went to deposit some money in bank B on the same day when he issued a check. At this time the balance of Mr. A in bank B was 10,000/-. Now, unfortunately for him two tellers accessed Mr.A’s data at the same time. At 10.15 AM Teller A --> Mr. A’s Balance: 60,000/- Teller B --> Mr. A’s Balance: 60,000/- At 10.17 AM Teller A --> Deposit: 40,000/- --> Mr. A’s Balance: 100,000/- --> Updates At 10.20 AM Teller B --> Withdraws: 50,000/- --> Mr. A’s Balance: 10,000/- --> Updates Finally the balance of Mr. A is 10,000/-!!! The possibility of this situation occurring may be 1 out of 1000 chances. But, that 1 instance is also pretty important and may cause high customer dissatisfaction. As a result of this the customer may lose the confidence on the organization he is operating with (Bank B in the above example).
The problem caused here is due to the improper use of Database locks at the table level and most importantly at row level. Because of these kind of a problems concurrency testing is given more importance and should be performed on all systems that have scope for concurrent accessing of same data by multiple users.
We need to deal with certain issues before we go for concurrency testing, some of the important issues are
Simulation of real time scenario: It is very difficult to simulate the real time scenarios in test labs or test environment.
Accuracy in actions: Getting data and saving at the specific time is a tricky thing to do practically.
Verification of Data: The data need to be verified in each phase like at Start of test, before and after the actual transaction/change takes place etc.
Load on the Application Server: It is difficult to determine the exact load to be simulated on the application server in order to carry out the concurrency testing and to make the transaction/change that will cause the failure of the system.
Scalability of the Application (Only in high end applications): The application should be scalable enough to sustain the load that is created during the concurrency testing.
Data persistency: Data persistency just means that the data is stored somewhere, usually DB or file, for whatever time necessary. It is important to know where and how the data is stored as part of performing concurrency testing.

Below checklist can be of use while performing the concurrency testing

  • Define the data set to be tested for concurrency (including screens also)
  • Outline a strategy who and how
  • Define Hardware
  • Execute test for Phase 1 (Data changed and updated)
  • Execute test for Phase 2 (Same data changed and updated)
  • Check Data at the end of each phase
Note: Concurrency testing is often confused with Load/Stress testing. The ability to with stand a huge amount of data or cater to huge number of users corresponds to Stress testing.

No comments: