-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(browser): ensure browser state is EXECUTING when tests start #3074
Changes from 2 commits
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 |
---|---|---|
|
@@ -7,17 +7,20 @@ const logger = require('./logger') | |
// The browser is ready to execute tests. | ||
const READY = 1 | ||
|
||
// The browser is configuring before tests execution. | ||
const CONFIGURING = 2 | ||
|
||
// The browser is executing the tests. | ||
const EXECUTING = 2 | ||
const EXECUTING = 3 | ||
|
||
// The browser is not executing, but temporarily disconnected (waiting for reconnecting). | ||
const READY_DISCONNECTED = 3 | ||
const READY_DISCONNECTED = 4 | ||
|
||
// The browser is executing the tests, but temporarily disconnect (waiting for reconnecting). | ||
const EXECUTING_DISCONNECTED = 4 | ||
const EXECUTING_DISCONNECTED = 5 | ||
|
||
// The browser got permanently disconnected (being removed from the collection and destroyed). | ||
const DISCONNECTED = 5 | ||
const DISCONNECTED = 6 | ||
|
||
class Browser { | ||
constructor (id, fullName, collection, emitter, socket, timer, disconnectDelay, noActivityTimeout) { | ||
|
@@ -101,6 +104,8 @@ class Browser { | |
this.lastResult = new Result() | ||
this.lastResult.total = info.total | ||
|
||
this.state = EXECUTING | ||
|
||
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. Changing 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 agree that I've added additional state called CONFIGURING, which explains the actual state between 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! This is better. How about one more improvement? The READY state is IMO misnamed. After this change the states are: Browser.STATE_READY = READY
Browser.STATE_CONFIGURING = CONFIGURING
Browser.STATE_EXECUTING = EXECUTING
Browser.STATE_READY_DISCONNECTED = READY_DISCONNECTED
Browser.STATE_EXECUTING_DISCONNECTED = EXECUTING_DISCONNECTED
Browser.STATE_DISCONNECTED = DISCONNECTED But I think the code would be clearer if the initial state was Browser.STATE_CONNECTED = CONNECTED
Browser.STATE_CONFIGURING = CONFIGURING
Browser.STATE_EXECUTING = EXECUTING
Browser.STATE_READY_DISCONNECTED = READY_DISCONNECTED
Browser.STATE_EXECUTING_DISCONNECTED = EXECUTING_DISCONNECTED
Browser.STATE_DISCONNECTED = DISCONNECTED That clarifies the relationship with others states like This version of the new state would be documented eg: // The browser is connected but not yet been commanded to execute tests.
const CONNECTED = 1 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 don't have any strong opinion here about naming. |
||
if (info.total === null) { | ||
this.log.warn('Adapter did not report total number of specs.') | ||
} | ||
|
@@ -137,7 +142,7 @@ class Browser { | |
|
||
if (this.state === READY) { | ||
this.disconnect() | ||
} else if (this.state === EXECUTING) { | ||
} else if (this.state === CONFIGURING || this.state === EXECUTING) { | ||
this.log.debug('Disconnected during run, waiting %sms for reconnecting.', this.disconnectDelay) | ||
this.state = EXECUTING_DISCONNECTED | ||
|
||
|
@@ -156,7 +161,7 @@ class Browser { | |
if (this.state === EXECUTING_DISCONNECTED) { | ||
this.state = EXECUTING | ||
this.log.debug('Reconnected on %s.', newSocket.id) | ||
} else if (this.state === EXECUTING || this.state === READY) { | ||
} else if (this.state === READY || this.state === CONFIGURING || this.state === EXECUTING) { | ||
this.log.debug('New connection %s (already have %s)', newSocket.id, this.getActiveSocketsIds()) | ||
} else if (this.state === DISCONNECTED) { | ||
this.state = READY | ||
|
@@ -209,7 +214,8 @@ class Browser { | |
execute (config) { | ||
this.activeSockets.forEach((socket) => socket.emit('execute', config)) | ||
|
||
this.state = EXECUTING | ||
this.state = CONFIGURING | ||
|
||
this.refreshNoActivityTimeout() | ||
} | ||
|
||
|
@@ -267,6 +273,7 @@ Browser.factory = function ( | |
} | ||
|
||
Browser.STATE_READY = READY | ||
Browser.STATE_CONFIGURING = CONFIGURING | ||
Browser.STATE_EXECUTING = EXECUTING | ||
Browser.STATE_READY_DISCONNECTED = READY_DISCONNECTED | ||
Browser.STATE_EXECUTING_DISCONNECTED = EXECUTING_DISCONNECTED | ||
|
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.
I think a slightly better description would be
// The browser has been told to execute tests; it is configuring before tests execution.