background image
<< Client/Server Testing - Testing in parallel, but not synchronously | Client/Server Testing - Application states and the recovery system >>
Client/Server Testing - testcase ParallelRandomLoadTest
<< Client/Server Testing - Testing in parallel, but not synchronously | Client/Server Testing - Application states and the recovery system >>
User's Guide
379
21 I
MPLEMENTING
C
LIENT
/S
ERVER
T
ESTING
Testing in parallel, but not synchronously
The following example suggests a method by which each client, operating in
a separate thread, executes a test that is assigned by a random number. The
RandSeed function is called first so that the random number sequence will be
the same for each iteration of this multi-user test scenario. This enables you
to subsequently repeat the test with the same conditions.
The example reads a list of client machines from a file, clients.txt, and
receives the test count as in input argument. These external variables make
the example scalable as to the number of machines being tested and the
number of tests to be run on each. The number of different testcases is twelve
in this example, but could be changed by modifying the SelectTest function
and adding further test functions. For each machine in the client machine list,
the example spawns a thread in which the specified client will execute a
randomly selected test, repeating for the specified number of tests.
Note that you could execute this test as it is written because it sets its own
application states. However, when you use multi-application support (as
described in Chapter 22) this is automatic. And if you wanted to use this
approach to drive different applications or to initialize a server before starting
the testing, you would have to add the multi-application support described in
the next chapter.
testcase ParallelRandomLoadTest (INTEGER iTestCount)
LIST OF STRING lsClients
RandSeed (3)
// list of client names
ListRead (lsClients, "clients.txt")
STRING sClientName
for each sClientName in lsClients
spawn
// Connect to client, which becomes current machine
Connect (sClientName)
SetAppState (MyAppState)
// Initialize application
TestClient (iTestCount)
Disconnect (sClientName)
rendezvous
TestClient (INTEGER iTestCount)
for i = 1 to iTestCount
SelectTest ()
SelectTest ()
INTEGER i = RandInt (1, 12)