This topic illustrates a method for running test functions in parallel on multiple clients, but with different tests running on each client. This provides a realistic multi-user load as opposed to a load in which all clients perform the same operations at roughly the same time.
This 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 is 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 executes a randomly selected test, repeating for the specified number of tests.
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) // This syntax invokes Test1 to Test12, based on i @("Test{i}") () // Define the actual test functions Test1 () // Do the test . . . Test2 () // Do the test . . . . . . Test12 () // Do the test . . .