Support & information center

rtcSetTestValue()

testRTC allows you to share key/value pairs between the probes in the same test run. This script command together with .rtcWaitForTestValue() can be used for such information sharing and for synchronization across probes.

Within a test run, one probe will call .rtcSetTestValue(). This will generate a key/value pair that will be stored in a shared memory across all probes in the test run. The other probes can then call .rtcWaitForTestValue() with the same key parameter to retrieve the value.

Arguments

NameTypeDescription
keystringThe key to share across probes in the test run
valuestringThe value to set for the key

Code example

The code below makes all probes in the test run to wait until the first probe in the test gets to a certain point in the script. If the value isn’t received within 30 seconds, the other probes will fail the test.

var idx = Number(process.env.RTC_AGENT_NUM);

if (idx === 1)
{
    client
        // Probe 1 sends a message
        .rtcSetTestValue("start", "Ready");
}
else
{
    client
        // Other probes receive the message
        .rtcWaitForTestValue('start', function (value) {}, 30000);
}Code language: JavaScript (javascript)

Notes

  • If you plan on running multiple sessions in parallel where each needs to synchronize separately (like multiple rooms running in parallel in a large stress test), then you should use .rtcSetSessionValue() instead
  • This method is useful for:
    1. Synchronizing probes to start after a given point in time, such as having the students join a session after the teacher logs in, or dial a call after the other user becomes available
    2. Send information that is needed, such as the URL or session ID that is created ad hoc by one probe that is needed for the other probes in order to join the same session
  • testRTC supports other synchronization mechanisms


Was this article helpful?

Related Articles