Learn, Share and Keep Learning
| Software Testing - One CPU Better than Two CPU |
|
This is a very interesting real life example of a classic concurrency issue and very neatly illustrates the abstract process of fault finding a race condition. What makes it particularly interesting is that rather than involving high performance multi-threaded code it is in an automated user interface test. The Problem
The Symptoms The Cause The Detailed Diagnosis What is happening is that the test was exceuting the function directing any open windows to close, and then shortly afterwards again running the same code. In investigating the difference between the various scenarios is was found:
Around this point it became clear what had been happening and it's related to the way the OS apportions time slices and the time it takes for these windows to close. On a single core machine time slices are doled out to the many tasks on the machine in a pre-emptive manner in order to achieve multi-tasking. Of course this is going on with the processes of TestComplete and the application under test; on single core it's something like 5 ms of TestComplete then 5 ms of the application, plus change for vital tasks the operating system has to perform like passing messages between applications. With so much time (?! - really!) when an application effectively has the machine to itself it's easy to see how an action initiated by TestComplete can be entirely completed when the application under test gets its time slice. Although there is a race condition in the test script code, having a single core "forces a winner" which results in correct operation for a large proportion of the time. On multiple cores the race condition can be exposed and if in fact highly likely to be exposed: TestComplete goes through all the open forms and directs them to close; the application under test, having another core to run on starts to do this immediately; TestComplete then repeats the order to the forms to close; some of the forms being in process of closing down, this is an error and is raised as such in the test script. The Cure The Moral of the Story
In this case is seemed natural to assume that what TestComplete presents as happening as being the exact case. Namely the script directs the application windows to close and they close without issue; in this view, what could be incorrect in performing the same logically flawless operation twice? If all the windows closed, then closing zero windows is wasteful but not incorrect. Since we know the reality is not that simple and the window closing process was initiated and then it was attempted again on windows that were already closing it is easy to see how it is incorrect to tell a window to close twice. At best it might ignore the request, at worst it may be literally unable to respond to the request. Hopefully this simple example has illustrated a vital issue in the testing of complex applications and the development of test scripts and in the future when a similar issue crops up the same checklist will help uncover the root cause quickly:
|
| Last Updated on Friday, 06 February 2009 16:33 |