background image
<< Client/Server Testing - Testing clients concurrently | Client/Server Testing - Testing in parallel, but not synchronously >>
Client/Server Testing - How 4Test handles script deadlock
<< Client/Server Testing - Testing clients concurrently | Client/Server Testing - Testing in parallel, but not synchronously >>
User's Guide
377
21 I
MPLEMENTING
C
LIENT
/S
ERVER
T
ESTING
Testing clients concurrently
For example, suppose you want to initiate two concurrent database
transactions on the same record, and then test how well the server performs.
To accomplish this, you need to change the script shown in the previous
section to look like this:
testcase TestConcurrently ()
Connect ("server")
Connect ("client1")
Connect ("client2")
DoSomeSetup ("server")
// initialize server first
Disconnect ("server")
// testcase is thru with server
spawn
// start thread for client1
UpdateDatabase ("client1")
spawn
// start thread for client2
UpdateDatabase ("client2")
rendezvous
// synchronize
Disconnect ("client1")
Disconnect ("client2")
DoSomeSetup (STRING sMachine)
// define server setup
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)
// define update test
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)
An alternative but equivalent approach is to use the parallel statement in
place of the spawn and rendezvous:
testcase TestConcurrently2 ()
Connect ("server")
Connect ("client1")
Connect ("client2")