Testing Clients Plus Server Serially

In a client/server application, the server and its clients typically run on different target machines. This topic explains how to build tests that test the server and its clients in a serial fashion. In this scenario, the SetMachine function switches among the target machines on which the server and its clients are running. The following script fragment tests a client/server database application in the following steps:
  1. Connect to three target machines, which are server, client1, and client2.
  2. Call the DoSomeSetup function, which calls SetMachine to make "server" the current target machine, and then perform some setup.
  3. Call the UpdateDatabase function once for each client machine. The function sets the target machine to the specified client, then does a database update. It creates a timer to time the operation on this client.
  4. Disconnect from all target machines.

Example

This example shows how you direct sets of test case statements to particular machines. If you were doing functional testing of one application, you might want to drive the server first and then the application. However, this example is not realistic because it does not show the support necessary to bring the different machines to their different application states and to recover from a failure on any machine.

testcase TestClient_Server ()
  Connect ("server")
  Connect ("client1")
  Connect ("client2")
  DoSomeSetup ("server")
  UpdateDatabase ("client1")
  UpdateDatabase ("client2")
  DisconnectAll ()

DoSomeSetup (STRING sMachine)
  HTIMER hTimer
  hTimer = TimerCreate ()
  TimerStart (hTimer)
  SetMachine (sMachine)
  // code to do server setup goes here
  TimerStop (hTimer)
  Print ("Time on {sMachine} is: {TimerStr (hTimer)}")
  TimerDestroy (hTimer)

UpdateDatabase (STRING sMachine)
  HTIMER hTimer
  hTimer = TimerCreate ()
  TimerStart (hTimer)
  SetMachine (sMachine)
  // code to update database goes here
  TimerStop (hTimer)
  Print ("Time on {sMachine} is: {TimerStr (hTimer)}")
  TimerDestroy (hTimer)