Synchronizing Script Executions
As separate script executions are handled by separate Eggplant processes, and there is not a mechanism out of the box that allows the processes to be aware of each other, but through some clever scripting, it is possible to allow script executions to communicate and be synchronized to varying degrees.
The easiest way to facilitate communication between the scripts is through a simple, shared external data file, such as a text file, that they can each access independently. Next, one can override the code for commonly used commands, such as "Click" and "WaitFor", so that each time the commands are called, communication with the shared data file is executed, enabling the script executions to remain synchronized.
For a very simple example of how to synchronize running the same script against two different SUTs in parallel, see the example scripts:
DrivingScript contains the actual commands that automate the SUTs and perform the test.
Params TestDevice, OverrideScript //passing parameters with the connection information for the SUT, and the name of the override script (FirstSUT or SecondSUT)
Start Using OverrideScript //tell DrivingScript to start looking at the override script handlers before looking at its own command/function library
//begin code that should be synchronized
//end synchronized code
Stop Using OverrideScript
FirstSUT contains the code that acts to create a shared data file when a command is executed on the first SUT.
//a handler override, such as the one below for MoveTo, is needed for each command that should be synchronized
pass message and continue //passes the message, which is the name of the handler, or "MoveTo", in this case, as well as any parameters passed into the handler (if applicable)
CreateMyFile// creates the file once the MoveTo command happens
to CheckForNoFile-- checks for the absence of the file
repeat until file "C:\Users\Carrie\Desktop\synccheck.txt"does not exist
SecondSUT contains the code that checks whether the data file exists before executing the parallel command on the second SUT.
// pass message and continue
to CheckForFile// checks for the presence of the file
repeat until file "C:\Users\Carrie\Desktop\synccheck.txt"exists
FirstSUT and SecondSUT leverage handlers with the same names as standard commands to override, or to what is sometimes called overload, the functionality of those commands in DrivingScript. DrivingScript will be called twice in succession, once for each SUT. The execution using the OverrideScript=FirstSUT parameter must be passed first, as FirstSUT is the script that controls the initial creation of the shared data file. The two executions of DrivingScript will take turns creating and deleting the shared data file, while simultaneously taking turns executing each command.