Synchronization Points

Applies to TestComplete 14.92, last modified on September 16, 2021
The Network Suite functionality is deprecated. We don’t recommend using it for distributed testing. Consider using a CI/CD system for managing distributed tests. See Migrating Distributed Tests to CI/CD Systems for details. In case you need to run web tests on multiple environments in parallel, you can also try using your project’s Execution Plan.

This topic contains information about using synchronization points to synchronize project execution on different machines engaged in distributed testing.

What Are Synchronization Points?

One of the ways to synchronize the execution of different projects participating in a distributed test is to use synchronization points (synchpoints). A synchpoint is a point within the test, at which the participating projects synchronize. During this kind of synchronization, execution of the participating projects is paused until all of these projects have reached the same synchpoint. After that, the projects simultaneously proceed. In this way, you can make sure that different projects start doing specific actions at the same time.

How synchronization works

Synchronization Points in TestComplete

Each synchronization point in a network suite is defined by its name and the set of projects that will be synchronized by that point. To use a particular synchpoint in several projects, you must subscribe all of these projects to the desired synchpoint. This means that you need to add a synchpoint with the same name to the SynchPoints collections of these projects:

Synchronization Points
You must add the desired synchpoint to the SynchPoints collections of all projects that should be synchronized by this synchpoint. However, it is not necessary to use each synchpoint in all of the projects that participate in distributed testing. For example, you may need three out of five slaves to synchronize before performing certain actions, while having the other two projects carrying out their tasks independently. In this case, you should add the desired synchpoints only to the SynchPoint collections of these three projects.

How Synchronization Works

Once a project reaches a synchpoint, it suspends its execution and waits until the other test projects subscribed to the same synchpoint reach it. The state of suspended projects (in terms of network suites, they are represented by tasks) changes to Synchronizing: SynchPoint_Name (where SynchPoint_Name is the name of the corresponding synchpoint). You can check the state of a project on the Run State page or from tests by using the Task.State property.

Once the last project among those subscribed to the specified synchpoint reaches it, the execution of this and other suspended projects are simultaneously resumed. Their state changes back to Running. The synchronization is considered to be accomplished.

If at least one of the projects subscribed to a certain synchpoint does not reach it, while the other projects are waiting for synchronization by the same synchpoint, synchronization will not be accomplished. At that, the suspended projects may hang waiting for that project to reach the specified checkpoint. To prevent the network suite from hanging, follow the recommendations below:

  • Keep track of all the synchpoints to which your projects are subscribed.

  • For each project, you can specify a time limit during which the project will wait for synchronization. This way you can break synchronization requests by using timeouts.

Note that if a project subscribed to a synchpoint does not reach it during the project execution, and the project execution is finished before the synchronization timeout specified for other projects elapses, the synchronization is considered to be successful.

Synchronizing Test Execution with Synchpoints From Scripts

Once you have subscribed all of the desired projects to the appropriate synchpoints, you can specify places within the tests at which the projects should synchronize. You can do this in two ways:

  • By calling the NetworkSuite.Synchronize method in the desired places in your tests and passing the name of the desired synchpoint to it.

  • By calling the SynchPoint.WaitFor method for the desired synchpoint in the desired places in your tests.

The following example demonstrates how you can synchronize tests execution by synchpoints from a script. This example uses the NetworkSuite.Synchronize method to simultaneously start creating new files on different computers. Remember that this code must be added to all projects that should create the files.

JavaScript, JScript

...
// Synchronize the script execution flow in the current project with script execution flows of other projects
NetworkSuite.Synchronize("Synchpoint1");

// Call the routine that creates files
CreateFiles(0);
...

Python

...
# Synchronize the script execution flow in the current project with script execution flows of other projects
NetworkSuite.Synchronize("Synchpoint1")

# Call the routine that creates files
CreateFiles(0)
...

VBScript

...
' Synchronize the script execution flow in the current project with script execution flows of other projects
Call NetworkSuite.Synchronize("Synchpoint1")

' Call the routine that creates files
Call CreateFiles(0)
...

DelphiScript

...
// Synchronize the script execution flow in the current project with script execution flows of other projects
NetworkSuite.Synchronize('Synchpoint1');

// Call the routine that creates files
CreateFiles(0);
...

C++Script, C#Script

...
// Synchronize the script execution flow in the current project with script execution flows of other projects
NetworkSuite["Synchronize"]("Synchpoint1");

// Call the routine that creates files
CreateFiles(0);
...

The following example demonstrates how you can use the SynchPoint.WaitFor method to simultaneously start creating new files on different computers.

JavaScript, JScript

...
// Synchronize the script execution flow of the current project with script execution flows of other projects
NetworkSuite.SynchPoints.Synchpoint1.WaitFor();

// Call the routine that creates files
CreateFiles(0);
...

Python

...
# Synchronize the script execution flow of the current project with script execution flows of other projects
NetworkSuite.SynchPoints.Synchpoint1.WaitFor()

# Call the routine that creates files
CreateFiles(0)
...

VBScript

...
' Synchronize the script execution flow of the current project with script execution flows of other projects
Call NetworkSuite.SynchPoints.Synchpoint1.WaitFor

' Call the routine that creates files
Call CreateFiles(0)
...

DelphiScript

...
// Synchronize the script execution flow of the current project with script execution flows of other projects
NetworkSuite.SynchPoints.Synchpoint1.WaitFor;

// Call the routine that creates files
CreateFiles(0);
...

C++Script, C#Script

...
// Synchronize the script execution flow of the current project with script execution flows of other projects
NetworkSuite["SynchPoints"]["Synchpoint1"]["WaitFor"]();

// Call the routine that creates files
CreateFiles(0);
...

Synchronizing Test Execution with Synchpoints From Keyword Tests

You can call the NetworkSuite.Synchronize or SynchPoint.WaitFor method from keyword tests by using the Run Code Snippet operation. For example, to synchronize projects by using the NetworkSuite.Synchronize method, simply add the operation to a desired place in the test, specify the following code in the ensuing dialog and click OK:

JavaScript, JScript

NetworkSuite.Synchronize("Synchpoint1");

Python

NetworkSuite.Synchronize("Synchpoint1")

VBScript

NetworkSuite.Synchronize("Synchpoint1")

DelphiScript

NetworkSuite.Synchronize('Synchpoint1');

C++Script, C#Script

NetworkSuite["Synchronize"]("Synchpoint1");

The following image demonstrates calling the NetworkSuite.Synchronize method with the Run Code Snippet operation in a VBScript test project:

Calling the Synchronize method from keyword test

You can also create script routines that call the NetworkSuite.Synchronize or SynchPoint.WaitFor method and then call these routines from keyword tests using the Run Script Routine or Run Test operation. For information on how to call the method from script, see above.

Managing Synchpoints

To view the project’s synchpoint list

To view the list of all the synchpoints to which the current project is subscribed, expand the NetworkSuite | SynchPoints project item in the Project Explorer panel.

To add a synchpoint

To subscribe a project to a particular synchpoint:

  • Right-click the NetworkSuite | SynchPoints item in the Project Explorer panel and select Add | New Item from the context menu.
  • In the resulting dialog, enter the desired synchpoint name (it must be unique within the project) and press OK.

After adding a new synchpoint to the project, insert the NetworkSuite.Synchronize or SynchPoint.WaitFor method call within the project script code or keyword test, at which you want this project to synchronize with other projects.

To rename a synchpoint

To rename an existing synchpoint:

  • In the Project Explorer panel, right-click the desired synchpoint in the NetworkSuite | SynchPoints list and select Rename from the context menu.
  • Enter the new synchpoint name and press Enter to apply the changes.

Note, that by renaming a synchpoint, you actually unsubscribe the project from the old synchpoint and subscribe it to a new synchpoint. So, remember to correct the synchpoint name in the appropriate NetworkSuite.Synchronize or SynchPoint.WaitFor method call in the project’s script code or keyword test. You may also need to rename this synchpoint in other projects participating in your network suite.

To delete a synchpoint

To exclude a project from synchronization by a particular synchpoint, you should remove this synchpoint from the project. To do this:

  • Right-click the desired synchpoint in the NetworkSuite | SynchPoints list in the Project Explorer panel and choose Delete from the context menu.

-- or --

  • Select the desired synchpoint under the NetworkSuite | SynchPoints node in the Project Explorer and press Del.

After deleting a synchpoint, remember to remove the NetworkSuite.Synchronize or SynchPoint.WaitFor method call that uses that synchpoint from the project’s tests.

See Also

Synchronizing Projects in Network Suites
Synchronizing Projects - Overview
Critical Sections
Network Suite Variables
Distributed Testing
Projects Participating in Distributed Testing
Distributed Testing - Basic Concepts

Highlight search results