Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Increase timeout for connectivity tests and add error message #130

Merged
merged 6 commits into from
Oct 28, 2015
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false
language: node_js
node_js:
- 0.10
- 4.1

env:
matrix:
Expand Down
42 changes: 36 additions & 6 deletions src/js/conntest.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,62 @@ function hostConnectivityTest() {
}

function runConnectivityTest(iceCandidateFilter, config) {
var candidates = [];
var call = new Call(config);
call.setIceCandidateFilter(iceCandidateFilter);

// Collect all candidate for validation.
call.pc1.onicecandidate = function(event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I prefer addEventListener('icecandidate', {...} ), I find it less error-prone in case there is multiple listeners.
Also it is used way more along this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sorry about that, should have ofc used addEventListener (I usually do...)

if (event.candidate) {
candidates.push(Call.parseCandidate(event.candidate.candidate));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to actually check the iceCandidateFilter here. Also, I think it's nice to log valid candidates out with reportSuccess just like we do here: https://github.com/webrtc/testrtc/blob/master/src/js/nettest.js#L87

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to gather all candidates in case we want to report different messages for different candidate types, otherwise the candidates array should probably be named reflexiveCandidates instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic is wrong here - if the relay test fails for example, won't you still have gathered reflexive candidates which will end up triggering the warning?

What do you think about filtering and logging here (quite nice to visualize which IPs are being used for each test) and use a separate mechanism to detect that the current test is the reflexive one in hangup?

Maybe something like:

if (error && candidates.length && iceCandidateFilter === Call.isReflexive) {
  reportWarning('...')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yes that looks like a better approach, will take a stab at it.

}
};

var ch1 = call.pc1.createDataChannel(null);
ch1.addEventListener('open', function() {
ch1.send('hello');
});
ch1.addEventListener('message', function(event) {
clearTimeout(timeout);
if (event.data !== 'world') {
reportFatal();
reportError('Data not transmitted.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but shouldn't the message read "Invalid data transmitted?"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed ;)

} else {
reportSuccess('Data successfully transmitted between peers.');
setTestFinished();
}
hangup();
});
call.pc2.addEventListener('datachannel', function(event) {
var ch2 = event.channel;
ch2.addEventListener('message', function(event) {
if (event.data !== 'hello') {
clearTimeout(timeout);
reportFatal();
hangup('Data not transmitted.');
} else {
ch2.send('world');
}
});
});
call.establishConnection();
timeout = setTimeout(reportFatal.bind(null, 'Timed out'), 2000);
timeout = setTimeout(hangup.bind(null, 'Timed out'), 5000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this is a global now. Fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh sorry about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fixed in the latest commit.


function hangup(errorMessage) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if call.close()/pc.close() does stop the peer connection immediatly and flushes away any pending ondata event. If it does not there is a chance this hangup is called twice... gosh we really need to start passing a test object instead of having this global methods to reportError/Warning/etc...

I guess no action needs to be done now, but we should fix it eventually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've actually seen it being called twice but not much we can do until we pass the test object as you suggest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it's not anymore, must have seen that when testing stuff. I think this one is ready to go now;)

if (errorMessage) {
var reflexiveCandidateFound = function() {
for (var candidate in candidates) {
if (Call.isReflexive(candidates[candidate])) {
return true;
}
}
};

var warningMessage = 'Server reflexive candidate received but cannot ' +
'connect. Most likely due to the network environment.';
if (reflexiveCandidateFound) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you have reflexiveCandidateFound as a function, wouldn't you need to call it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed ;). Javascript nuisances ;).

Fixed and properly tested the negative condition as well ;)

reportWarning(warningMessage);
} else {
reportError(errorMessage);
}
}
clearTimeout(timeout);
call.close();
setTestFinished();
}
}
15 changes: 13 additions & 2 deletions src/js/nettest.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ function gatherCandidates(config, params, isGood) {
try {
pc = new RTCPeerConnection(config, params);
} catch (error) {
return reportFatal('Fail to create peer connection: ' + error);
if (params.optional[0].googIPv6) {
return reportWarning('Failed to create peer connection, IPv6 ' +
'might not be setup/supported on the network.');
} else {
return reportError('Failed to create peer connection: ' + error);
}
}

// In our candidate callback, stop if we get a candidate that passes |isGood|.
Expand All @@ -91,7 +96,13 @@ function gatherCandidates(config, params, isGood) {
}
} else {
pc.close();
reportFatal('Failed to gather specified candidates');
if (!params.optional[0].googIPv6) {
reportWarning('Failed to gather IPv6 candidates, it ' +
'might not be setup/supported on the network.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are missing many setTestFinished() in the places where you replace reportFatal with reportError/Warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

} else {
reportError('Failed to gather specified candidates');
setTestFinished();
}
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/ui/testrtc-suite.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
},
_iconForState: function (state) {
if (state === 'failure') { return 'close'; }
if (state === 'warning') { return 'check'; }
if (state === 'warning') { return 'warning'; }
if (state === 'success') { return 'check'; }
if (state === 'running') { return 'more-horiz'; }
return '';
Expand Down Expand Up @@ -129,7 +129,7 @@
this.opened = false;
} else if (errors === 0 && warnings > 0) {
this.state = 'warning';
this.opened = false;
this.opened = true;
} else {
this.state = 'failure';
this.opened = true;
Expand Down
18 changes: 16 additions & 2 deletions src/ui/testrtc-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
_iconForState: function(state) {
if (state === 'running') return 'more-horiz';
if (state === 'success') return 'check';
if (state === 'warning') return 'warning';
if (state === 'failure') return 'close';
if (state === 'disabled') return '';
return '';
Expand Down Expand Up @@ -137,8 +138,18 @@
done: function() {
this.setProgress(null);
var success =
(this.errorCount === 0 && (this.successCount + this.warningCount) > 0);
this.state = (success ? 'success' : (this.isDisabled ? 'disabled' : 'failure'));
(this.errorCount + this.warningCount === 0 && this.successCount > 0);

if (success) {
this.state = 'success';
} else if (this.errorCount > 0) {
this.state = 'failure';
} else if (this.warningCount > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the failure condition and above and make this one
"if (warningCount > 0 && errorCount == 0) { warning }"
Then add an else condition to catch everything remaining as error.

E.g. if you had errorCount and warningCount==0, your code at the moment does not sets any state. Which seems bogus to me. So I think using failure as a catch all is a better alternative.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes thank you for pointing this out, I thought about exactly this but then I forgot to do anything about it.

this.state = 'warning';
} else if (this.isDisabled) {
this.state = 'disabled';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else { failure }


this.traceTestEvent({status: this.state});
report.logTestRunResult(this.name, this.state);
this.doneCallback_();
Expand Down Expand Up @@ -180,6 +191,9 @@
this.traceTestEvent({info: str});
},

// Use only for error callbacks upon test invocation, not to end the test,
// use report<Status>(message) and setTestFinished() for that.
// TODO: Figure out a better way to do this.
reportFatal: function(str) {
this.reportError(str);
this.done();
Expand Down
2 changes: 1 addition & 1 deletion test/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Installs Chrome or Firefox if missing and sets default browser to
# chrome stable.
#
echo "\nPreparing Selenium webdriver tests."
echo "Preparing Selenium webdriver tests."

BINDIR=./browsers/bin
export BROWSER=${BROWSER-chrome}
Expand Down