aboutsummaryrefslogtreecommitdiff
path: root/webrtc
diff options
context:
space:
mode:
authorhoussainy@google.com <houssainy@google.com>2014-09-30 15:20:15 +0000
committerhoussainy@google.com <houssainy@google.com>2014-09-30 15:20:15 +0000
commitd0bb5862f52e28311be62abd1272f9217a87079b (patch)
tree30ac5d9aa614bd80324b48de528e1f39cc389d4e /webrtc
parentdb75a66b0fa7f3a734206aa339ca598924c48d42 (diff)
downloadwebrtc-d0bb5862f52e28311be62abd1272f9217a87079b.tar.gz
Collecting stats every fixed time in webrtc_video_streaming.js test
and prepare the format these collected stats to be plotted using one of external dev-tools. R=andresp@webrtc.org Review URL: https://webrtc-codereview.appspot.com/29589004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7340 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc')
-rw-r--r--webrtc/tools/rtcbot/test.js57
-rw-r--r--webrtc/tools/rtcbot/test/webrtc_video_streaming.js16
2 files changed, 68 insertions, 5 deletions
diff --git a/webrtc/tools/rtcbot/test.js b/webrtc/tools/rtcbot/test.js
index 23a3f9c219..7e9c335445 100644
--- a/webrtc/tools/rtcbot/test.js
+++ b/webrtc/tools/rtcbot/test.js
@@ -17,10 +17,9 @@ var vm = require('vm');
var BotManager = require('./botmanager.js');
function Test(botType) {
- // TODO(houssainy) set the time out.
this.timeout_ = setTimeout(
this.fail.bind(this, "Test timeout!"),
- 10000);
+ 100000);
this.botType_ = botType;
}
@@ -74,12 +73,64 @@ Test.prototype = {
this.botManager_ = new BotManager();
this.botManager_.spawnNewBot(name, this.botType_, doneCallback);
},
+
+ createStatisticsReport: function (outputFileName) {
+ return new StatisticsReport(outputFileName);
+ },
+}
+
+StatisticsReport = function (outputFileName) {
+ this.output_ = [];
+ this.output_.push("Version: 1");
+ this.outputFileName_ = outputFileName;
+}
+
+StatisticsReport.prototype = {
+ collectStatsFromPeerConnection: function (prefix, pc) {
+ setInterval(this.addPeerConnectionStats.bind(this, prefix, pc), 100);
+ },
+
+ addPeerConnectionStats: function (prefix, pc) {
+ pc.getStats(onStatsReady.bind(this));
+
+ function onStatsReady(reports) {
+ for (index in reports) {
+ var stats = {};
+ stats[reports[index].id] = collectStats(reports[index].stats);
+
+ var data = {};
+ data[prefix] = stats;
+
+ this.output_.push({
+ type: "UpdateCounters",
+ startTime: (new Date()).getTime(),
+ data: data,
+ });
+ }
+ };
+
+ function collectStats(stats) {
+ var outputStats = {};
+ for (index in stats) {
+ var statValue = parseFloat(stats[index].stat);
+ outputStats[stats[index].name] = isNaN(statValue)?
+ stats[index].stat : statValue;
+ }
+ return outputStats;
+ };
+ },
+
+ finish: function (doneCallback) {
+ fs.writeFile("test/reports/" + this.outputFileName_ + "_" +
+ (new Date()).getTime() +".json", JSON.stringify(this.output_),
+ doneCallback);
+ },
}
function runTest(botType, testfile) {
console.log("Running test: " + testfile);
var script = vm.createScript(fs.readFileSync(testfile), testfile);
- script.runInNewContext({ test: new Test(botType), setInterval: setInterval
+ script.runInNewContext({ test: new Test(botType), setInterval: setInterval,
setTimeout: setTimeout });
}
diff --git a/webrtc/tools/rtcbot/test/webrtc_video_streaming.js b/webrtc/tools/rtcbot/test/webrtc_video_streaming.js
index a907976384..7b0457c96a 100644
--- a/webrtc/tools/rtcbot/test/webrtc_video_streaming.js
+++ b/webrtc/tools/rtcbot/test/webrtc_video_streaming.js
@@ -7,15 +7,17 @@
// be found in the AUTHORS file in the root of the source tree.
//
// A unidirectional video and audio flowing test from bot 1 to bot 2.
+// The test succeeds after collecting stats for 10 seconds from both bots
+// and then write these stats to a file.
//
// Note: the source of the video and audio stream is getUserMedia().
//
-// TODO(houssainy): get a condition to terminate the test.
-//
function testVideoStreaming(bot1, bot2) {
var pc1 = null;
var pc2 = null;
+ var report = test.createStatisticsReport("webrtc_video_streaming");
+
test.wait([
createPeerConnection.bind(bot1),
createPeerConnection.bind(bot2) ],
@@ -81,11 +83,21 @@ function testVideoStreaming(bot1, bot2) {
test.fail);
pc1.setRemoteDescription(answer, onSetSessionDescriptionSuccess,
test.fail);
+ collectStats();
}
function onSetSessionDescriptionSuccess() {
test.log("Set session description success.");
}
+
+ function collectStats() {
+ report.collectStatsFromPeerConnection("bot1", pc1);
+ report.collectStatsFromPeerConnection("bot2", pc2);
+
+ setTimeout(function() {
+ report.finish(test.done);
+ }, 10000);
+ }
}
}