-
Notifications
You must be signed in to change notification settings - Fork 215
Increase timeout for connectivity tests and add error message #130
Changes from 3 commits
c86d6ad
886aeba
b4548b4
7c3f311
c3959fb
79b1d0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
if (event.candidate) { | ||
candidates.push(Call.parseCandidate(event.candidate.candidate)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to actually check the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit but shouldn't the message read "Invalid data transmitted?" There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just noticed this is a global now. Fix it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doh sorry about that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fixed in the latest commit. |
||
|
||
function hangup(errorMessage) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since you have There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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|. | ||
|
@@ -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.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
} else { | ||
reportError('Failed to gather specified candidates'); | ||
setTestFinished(); | ||
} | ||
} | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ''; | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the failure condition and above and make this one 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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_(); | ||
|
@@ -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(); | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...)