Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 19f160e

Browse files
committed
CSV reporter and getStats classes refactoring
1 parent 0cbcee1 commit 19f160e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1313
-1765
lines changed

KITE-AppRTC-Test/configs/iceconnection.apprtc.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
"tupleSize": 2,
1414
"description": "This test check the ICEConnection state between two browsers communicating via appr.tc",
1515
"testImpl": "org.webrtc.kite.apprtc.tests.IceConnectionTest",
16+
"csvReport": true,
1617
"payload" : {
1718
"url": "https://appr.tc",
1819
"takeScreenshotForEachTest": true,
1920
"getStats" : {
2021
"enabled": true,
21-
"statsCollectionTime": 2,
22+
"statsCollectionTime": 5,
2223
"statsCollectionInterval": 1,
2324
"peerConnections": ["appController.call_.pcClient_.pc_"],
2425
"selectedStats" : ["inbound-rtp", "outbound-rtp", "candidate-pair", "track"]

KITE-AppRTC-Test/configs/js.iceconnection.apprtc.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
}
2929
],
30-
"browsers": [
30+
"clients": [
3131
{
3232
"browserName": "chrome",
3333
"version": "74",

KITE-AppRTC-Test/js/IceConnectionTest.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
const {TestUtils, WebDriverFactory, KiteBaseTest} = require('kite-common');
2-
32
// Steps & checks
43
const {OpenAppUrlStep, ConnectToAppRoomStep, GetStatsStep} = require('./steps');
54
const {PeerConnectionCheck, RemoteVideoDisplayCheck} = require('./checks');
6-
75
// Pages
86
const {AppRTCJoinPage, AppRTCMeetingPage} = require('./pages');
97

10-
// KiteBaseTest config
11-
const globalVariables = TestUtils.getGlobalVariables(process);
12-
const capabilities = require(globalVariables.capabilitiesPath);
13-
const payload = require(globalVariables.payloadPath);
14-
158
class IceConnectionTest extends KiteBaseTest {
16-
constructor(name, globalVariables, capabilities, payload) {
17-
super(name, globalVariables, capabilities, payload);
9+
constructor(name, kiteConfig) {
10+
super(name, kiteConfig);
1811
}
1912

2013
async testScript() {
2114
try {
22-
this.driver = await WebDriverFactory.getDriver(capabilities, capabilities.remoteAddress);
15+
this.driver = await WebDriverFactory.getDriver(this.capabilities, this.remoteUrl);
2316
this.page = new AppRTCJoinPage(this.driver);
2417

2518
let openAppUrlStep = new OpenAppUrlStep(this);
@@ -39,7 +32,7 @@ class IceConnectionTest extends KiteBaseTest {
3932
await getStatsStep.execute(this);
4033
}
4134

42-
await super.waitAllSteps();
35+
await this.waitAllSteps();
4336
} catch (error) {
4437
console.log(error);
4538
} finally {
@@ -50,5 +43,8 @@ class IceConnectionTest extends KiteBaseTest {
5043

5144
module.exports = IceConnectionTest;
5245

53-
var test = new IceConnectionTest('IceConnection Test', globalVariables, capabilities, payload);
54-
test.run();
46+
(async () => {
47+
const kiteConfig = await TestUtils.getKiteConfig(__dirname);
48+
let test = new IceConnectionTest('IceConnection Test', kiteConfig);
49+
await test.run();
50+
})();

KITE-AppRTC-Test/js/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
},
1313
"license": "ISC",
1414
"dependencies": {
15-
"fs": "^0.0.1-security",
16-
"kite-common": "0.1.3",
17-
"selenium-webdriver": "^4.0.0-alpha.1",
15+
"kite-common": "0.1.6",
1816
"express": "^4.15.2",
1917
"socket.io": "^2.2.0"
2018
}

KITE-AppRTC-Test/js/server.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ io.on('connection', function(socket) {
2121
})
2222

2323
socket.on("done", (id) => {
24-
console.log("Test done for " + id);
2524
doneArray.push(id);
2625
})
2726

KITE-AppRTC-Test/js/steps/GetStatsStep.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class GetStatsStep extends TestStep {
2929
let summaryStats = await TestUtils.extractJson(stats, 'both');
3030

3131
// Data
32-
this.testReporter.textAttachment(this.report, 'Raw stats', JSON.stringify(stats), "json");
33-
this.testReporter.textAttachment(this.report, 'Summary stats', JSON.stringify(summaryStats), "json");
32+
this.testReporter.textAttachment(this.report, 'Raw stats', JSON.stringify(stats, null, 4), "json");
33+
this.testReporter.textAttachment(this.report, 'Summary stats', JSON.stringify(summaryStats, null, 4), "json");
3434

3535
} catch (error) {
3636
console.log(error);

KITE-AppRTC-Test/src/main/java/org/webrtc/kite/apprtc/checks/BitrateCheck.java

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,16 @@
1616
package org.webrtc.kite.apprtc.checks;
1717

1818
import io.cosmosoftware.kite.exception.KiteTestException;
19-
import io.cosmosoftware.kite.report.Reporter;
20-
import io.cosmosoftware.kite.report.Status;
2119
import io.cosmosoftware.kite.interfaces.Runner;
20+
import io.cosmosoftware.kite.report.Status;
2221
import io.cosmosoftware.kite.steps.TestCheck;
23-
import org.openqa.selenium.WebDriver;
24-
import org.webrtc.kite.apprtc.pages.AppRTCMeetingPage;
22+
import org.webrtc.kite.stats.RTCStatList;
23+
import org.webrtc.kite.stats.RTCStats;
2524

26-
import javax.json.Json;
27-
import javax.json.JsonArray;
28-
import javax.json.JsonObject;
25+
import java.util.List;
2926

30-
import static io.cosmosoftware.kite.entities.Timeouts.FIVE_SECOND_INTERVAL;
3127
import static io.cosmosoftware.kite.entities.Timeouts.ONE_SECOND_INTERVAL;
32-
import static org.webrtc.kite.stats.StatsUtils.getStatOvertime;
28+
import static org.webrtc.kite.stats.StatsUtils.getPCStatOvertime;
3329

3430
public class BitrateCheck extends TestCheck {
3531
private int expectedBitrate = -1;
@@ -54,68 +50,31 @@ private void updateReport() {
5450

5551
@Override
5652
protected void step() throws KiteTestException {
57-
String stat = direction.equalsIgnoreCase("sending") ? "inbound-rtp" : "outbound-rtp";
58-
JsonArray selectedStat =
59-
Json.createArrayBuilder()
60-
.add(stat)
61-
.build();
6253
// Get a stats array of the selected stat for 5 seconds
63-
JsonObject stats = getStatOvertime(
64-
webDriver, FIVE_SECOND_INTERVAL, ONE_SECOND_INTERVAL, selectedStat).build();
65-
double avgBitrate = computeBitrate(stats.getJsonArray("statsArray"), stat, mediaType);
66-
System.out.println("avgBitrate lah =>>>>>> " + avgBitrate);
54+
int duration = 5;
55+
RTCStatList stats = getPCStatOvertime(
56+
webDriver,"", 5 * ONE_SECOND_INTERVAL, ONE_SECOND_INTERVAL);
57+
double startingTotalByteCount = stats.get(0).getTotalBytesByMedia(direction, mediaType);
58+
double endingTotalByteCount = stats.get(duration - 1).getTotalBytesByMedia(direction, mediaType);
59+
double avgBitrate = (endingTotalByteCount - startingTotalByteCount)/duration;
6760
// Assuming that there's a 10% tolerance to the test result:
6861
reporter.textAttachment(report, "Bitrate check",
6962
"Expected : [" + 0.9*expectedBitrate + " -> " + 1.1*expectedBitrate + "], found " + avgBitrate , "plain" );
7063
if (avgBitrate < 0.9*expectedBitrate || 1.1*expectedBitrate < avgBitrate) {
7164
throw new KiteTestException("Expected bitrate to be in [" + 0.9*expectedBitrate + "," + 1.1*expectedBitrate + "], found " + avgBitrate, Status.FAILED);
7265
}
7366
}
74-
67+
7568
public void setExpectedBitrate(int expectedBitrate) {
7669
this.expectedBitrate = expectedBitrate;
7770
updateReport();
7871
}
7972

8073
public void setOption(String option) {
8174
this.mediaType = option.startsWith("a")? "audio" : "video";
82-
this.direction = option.contains("s")? "sending" : "receiving";
75+
this.direction = option.endsWith("s")? "outbound" : "inbound";
8376
updateReport();
8477
}
8578

86-
private double computeBitrate(JsonArray stats, String statName, String mediaType) throws KiteTestException {
87-
int totalBytes = 0;
88-
int totalDuration = 0;
89-
try {
90-
JsonObject firstMediaStat =
91-
getMediaObject(stats.getJsonObject(0).getJsonObject(statName), mediaType);
92-
JsonObject lastMediaStat =
93-
getMediaObject(stats.getJsonObject(stats.size() - 1).getJsonObject(statName), mediaType);
94-
95-
String byteType = statName.contains("inbound") ? "bytesReceived" : "bytesSent";
96-
97-
totalBytes = Integer.parseInt(lastMediaStat.getString(byteType))
98-
- Integer.parseInt(firstMediaStat.getString(byteType));
99-
System.out.println("totalBytes->" + totalBytes);
100-
totalDuration= (int) (Long.parseLong(lastMediaStat.getString("timestamp"))
101-
- Long.parseLong(firstMediaStat.getString("timestamp"))) / ONE_SECOND_INTERVAL;
102-
103-
} catch (Exception e) {
104-
throw new KiteTestException("Null point exception detected, please check if the stats are correct", Status.BROKEN, e.getCause());
105-
}
106-
if (totalDuration == 0) {
107-
throw new KiteTestException("Total duration seems to be zero, please check the algorithm", Status.BROKEN);
108-
}
109-
return totalBytes / totalDuration;
110-
}
111-
112-
private JsonObject getMediaObject(JsonObject statObject, String mediaType) {
113-
for (String key: statObject.keySet()) {
114-
JsonObject mediaObject = statObject.getJsonObject(key);
115-
if (mediaObject.getString("mediaType").equalsIgnoreCase(mediaType)) {
116-
return mediaObject;
117-
}
118-
}
119-
return null;
120-
}
79+
12180
}

KITE-AppRTC-Test/src/main/java/org/webrtc/kite/apprtc/checks/PeerConnectionCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
package org.webrtc.kite.apprtc.checks;
1717

1818
import io.cosmosoftware.kite.exception.KiteTestException;
19-
import io.cosmosoftware.kite.report.Status;
2019
import io.cosmosoftware.kite.interfaces.Runner;
20+
import io.cosmosoftware.kite.report.Status;
2121
import io.cosmosoftware.kite.steps.TestCheck;
2222
import org.webrtc.kite.apprtc.pages.AppRTCMeetingPage;
2323

KITE-AppRTC-Test/src/main/java/org/webrtc/kite/apprtc/checks/RemoteVideoDisplayCheck.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
package org.webrtc.kite.apprtc.checks;
1717

1818
import io.cosmosoftware.kite.exception.KiteTestException;
19-
import io.cosmosoftware.kite.report.Reporter;
19+
import io.cosmosoftware.kite.interfaces.Runner;
2020
import io.cosmosoftware.kite.report.Status;
2121
import io.cosmosoftware.kite.steps.TestCheck;
22-
import io.cosmosoftware.kite.interfaces.Runner;
2322
import org.webrtc.kite.apprtc.pages.AppRTCMeetingPage;
2423

2524
public class RemoteVideoDisplayCheck extends TestCheck {

KITE-AppRTC-Test/src/main/java/org/webrtc/kite/apprtc/checks/RemoteVideoHDCheck.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
package org.webrtc.kite.apprtc.checks;
1717

1818
import io.cosmosoftware.kite.exception.KiteTestException;
19-
import io.cosmosoftware.kite.report.Reporter;
19+
import io.cosmosoftware.kite.interfaces.Runner;
2020
import io.cosmosoftware.kite.report.Status;
2121
import io.cosmosoftware.kite.steps.TestCheck;
22-
import io.cosmosoftware.kite.interfaces.Runner;
2322
import org.webrtc.kite.apprtc.pages.AppRTCMeetingPage;
2423

2524
import javax.json.JsonObject;

0 commit comments

Comments
 (0)