Support & information center

AppRTC sample test script

AppRTC is Google’s original sample/demo for a peer-to-peer WebRTC implementation. In December 2021, Google decided to no longer support the hosted version of it and only offer it as a github repository.

In the past, we provided the AppRTC test script as a sample of using our service, but ever since the hosted version of it was removed from the internet, we had to remove it from our own samples.

If you are using it as your baseline, then the script below is a good starting point.

Preparation

The script below creates random URL on AppRTC for the first probe joining the session, and then have the second probe joins the same random URL. You can use the script “as is” – just make sure the service URL points to your server.

Using the test script

In testRTC, create a new test script:

  1. Copy the code from the bottom of this article to your test script (or use the existing sample in your account)
  2. Decide the number of probes you want to use
    1. Concurrent probes will be good starting point – keep it at an even number (you need pairs of probes for this)
    2. Session size must be 2 for the AppRTC application to work properly
  3. Replace the Service URL of the script with the URL where your AppRTC signaling server is located

Test execution

Run the script. It does everything for you.

Test script code

/* This example shows how to automate AppRTC scenarios in testRTC SCENARIO * Browser 1 goes to appr.tc and creates a random room * Browser 1 sends room URL to browser 2 * Browser 2 waits for room URL to arrive * Browser 2 joins the room * Both browsers run for 2 minutes SCALING To scale the test, change the number of concurrent users. You can't change the number of users per session, as AppRTC only allows 2 users in a room. THINGS TO PLAY WITH * Probe configurations (look after the script): - Location of probes - Media files to use - Network configuration and quality - Browser version * Number of concurrent users (in a paid account. Evals limited to 2 max) * Service URL - trying VP9 and H264 instead of VP8 NOTES We've decided to run AppRTC here with VP8 (look at the Service URL above). Just as easily, testRTC can support VP9, H.264 or any other codec and feature supported by the browser being used. */ // Variables that we will use in this example var agentType = Number(process.env.RTC_IN_SESSION_ID); var sec = 1000; // We set a few expectations. If these don't happen, the test will fail // In AppRTC case, we want to make sure we have: // 1. An incoming and outgoing audio and video channels // 2. Media being sent on these channels client.resizeWindow(1280, 720) .rtcSetTestExpectation("audio.in == 1") .rtcSetTestExpectation("audio.out == 1") .rtcSetTestExpectation("video.in == 1") .rtcSetTestExpectation("video.out == 1") .rtcSetTestExpectation("audio.in.bitrate > 0") .rtcSetTestExpectation("audio.out.bitrate > 0") .rtcSetTestExpectation("video.in.bitrate > 0") .rtcSetTestExpectation("video.out.bitrate > 0"); if (agentType === 1) { // Browser 1 actions take place here // Open initial AppRTC URL and join a randomly allocated room client .url(process.env.RTC_SERVICE_URL) .waitForElementVisible('body', 10*sec) .waitForElementVisible('#join-button', 10*sec) .pause(1000) .click('#join-button') .waitForElementVisible('#videos', 30*sec) .waitForElementVisible('#room-link', 30*sec) .pause(5*sec) .rtcScreenshot("Alone in call") // Send the room URL to the second browser .url(function (result) { this.assert.equal(typeof result, "object"); this.assert.equal(result.status, 0); var roomUrl = result.value; this.assert.equal(!!roomUrl, true); client .rtcInfo('Sending Room url %s', roomUrl) .rtcProgress("Waiting @ " + roomUrl) .rtcSetSessionValue("roomUrl", roomUrl); }); } else { // Browser 2 actions take place here // Wait for Browser 1 to send us the URL for this call client .rtcWaitForSessionValue('roomUrl', function (urlToJoin) { client .rtcInfo('Joining ', urlToJoin) .rtcProgress("Joining " + urlToJoin) .url(urlToJoin) .waitForElementVisible('body', 30*sec) .waitForElementVisible('#confirm-join-button', 30*sec) .pause(2*sec) .rtcScreenshot("Joining") .click('#confirm-join-button') .waitForElementVisible('#videos', 30*sec); }, 30*sec); } // Now that the browser is connected and in the room, we wait client .pause(60*sec) .rtcScreenshot("in call") .pause(60*sec) .rtcProgress("Bye");
Code language: JavaScript (javascript)

Was this article helpful?

Related Articles