Testing In Parallel but Not Synchronously

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.

Note: You can execute this test as it is written because it sets its own application states. However, when you use multi-application support, this is automatic. And if you want to use this approach to drive different applications or to initialize a server before starting the testing, you must add multi-application support.
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
      // Connect to client, which becomes current machine
      Connect (sClientName)
      SetAppState ("MyAppState")           // Initialize application
      TestClient (iTestCount)
      Disconnect (sClientName)

  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 . . .