Support & information center

rtcSetEventsExpectation()

This is a variation of .rtcSetTestExpectation() that works between given events created using .rtcEvent().

Indicate expected outcome for the specific probe execution between two application defined events. This is used to decide if a test has successfully passed or failed.

The condition is evaluated at the end of the test, based on collected information and metrics. The command can be placed anywhere in the script and can appear multiple times with different constraint values.

testRTC offers additional assertion and expectation commands.

Arguments

NameTypeDescription
criteriastringThe criteria to test. See below for the available options
start-eventstringThe starting point in time for the evaluation. Events are creating using rtcEvent()
Learn more about event based test expectations
end-eventstringThe ending point in time for the evaluation. Events are created using rtcEvent()
Learn more about event based test expectations
messagestringMessage to invoke if criteria isn’t met
levelstringLevel of expectation:
  • “error” – error occurred – fail the test
  • “warning” – consider this as a warning
  • Default value: error

Criteria

A criteria is comprised of the metric to test, an operator and a value.

For example: “video.in > 0” will evaluate that the number of incoming video channels is greater than 0.

Operators

The available operators for the criteria are:

  • ==
  • >
  • <
  • >=
  • <=
  • !=

Complex expectations

You can also use the boolean operators and or or to build more complex expectations.

An example of using it is when you want to check for a certain threshold only on some of the channels. Assume for example that you have any incoming channels, but some of them are muted so they have no data flowing on them. But you still want to test for frame rate. Here’s how you can now do that:

client.rtcSetEventsExpectation("video.in.channel.bitrate == 0 or video.in.channel.fps > 0");
Code language: JavaScript (javascript)

Criteria metrics

The criteria is defined as a chained definition of the object we wish to evaluate, and depends on the metric type we wish to access.

The detailed list of available criteria metrics are found in the description of .rtcSetTestExpetaction().

Example

In the example below, the expectations check for the audio bitrate between two events created using .rtcEvent() in the test script. These events are called ‘Limit Network’ and ‘Stop Limit’.

// The below expectation is based on the events used to check network configuration client .rtcSetEventsExpectation("audio.in.bitrate >= 15", 'Limit Network', 'Stop Limit', "audio bitrate too low", 'error') .rtcSetEventsExpectation("audio.out.bitrate >= 15", 'Limit Network', 'Stop Limit', "audio bitrate too low", 'error') ;
Code language: JavaScript (javascript)

Was this article helpful?

Related Articles