Skip to content
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

Parallelize nightwatch #4481

Merged
merged 33 commits into from
Jan 4, 2017
Merged

Parallelize nightwatch #4481

merged 33 commits into from
Jan 4, 2017

Conversation

jkassemi
Copy link
Contributor

Mock server implementation allows mocking requests based on user, which permits running multiple tests in parallel. Worker count set to n=10, may adjust while tuning performance for Jenkins environment.

@va-bot va-bot temporarily deployed to vetsgov-pr-4481 December 22, 2016 19:32 Inactive
@va-bot va-bot temporarily deployed to vetsgov-pr-4481 December 22, 2016 19:35 Inactive
initUserMock(level);
let tokenCounter = 0;

function getUserToken() {
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 considered trying to use a selenium-based session id, but the session id is not sent in the request to the mock server, and using less magic around this felt more maintainable.

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems fine to me. (If I've learned anything about Selenium in the last few days, it's to not rely on its APIs...)


function logIn(token, client, url, level) {
initUserMock(token, level);

client
.url(`${E2eHelpers.baseUrl}${url}`)
.waitForElementVisible('body', Timeouts.normal);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately setting the users' session prior to waiting for the body to show on this page provided inconsistent results. I'd love if there were a way to set the session on the first page request so we didn't need to make two for every login. This may be possible by passing a session parameter in the URL or finding a way for the react application to read the users' session id from a method or the redux state instead of directly from local storage.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this because localStorage isn't set until the body is already loaded? If that's the case, I'd guess that the URL paramater approach would be the way to go. It would just take a couple of changes in test-server.js, I think.

Something for a future PR, perhaps!

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 believe that's the case. I'll set up to do some more testing in the future if we find there's a good performance improvement to be had from this.

@va-bot va-bot temporarily deployed to vetsgov-pr-4481 December 22, 2016 19:43 Inactive
});
}

module.exports = mock;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is somewhat out of convention - might consider changing this to export multiple methods or singularizing the name of the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems fine for now. The helpers.js files aren't particularly idiomatic anyway...

Copy link
Contributor

@alexose alexose left a comment

Choose a reason for hiding this comment

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

These all seem like solid, straightforward changes. 👍

@@ -47,7 +45,12 @@ module.exports = {
log_path: './logs/selenium',
host: '127.0.0.1',
port: selenium_server_port,
}
},
cli_args: { },
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

cli_args: { },
test_workers: {
enabled: true,
workers: 10,
Copy link
Contributor

Choose a reason for hiding this comment

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

10 seems excessive... I think "auto" is a better option here. Worth testing, maybe.

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 saw better responses discarding auto, which I believe defaults to the number of cpu's on the system. I'm guessing that the waits, pauses, and polling for elements to appear prevents the process from becoming cpu-bound.

@@ -1,50 +1,46 @@
if (!process.env.BUILDTYPE || process.env.BUILDTYPE === 'development') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing we are ditching these now that we check buildtype at the /script/run-nightwatch.js level. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case I removed the guard because these features are now included in staging and production, so the tests should be run against the build in all build types.

But yes, going forward #4497 provides a means of adequately testing features from a single build type, negating the need to guard test runs against development features at all.

initUserMock(level);
let tokenCounter = 0;

function getUserToken() {
Copy link
Contributor

Choose a reason for hiding this comment

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

That seems fine to me. (If I've learned anything about Selenium in the last few days, it's to not rely on its APIs...)


function logIn(token, client, url, level) {
initUserMock(token, level);

client
.url(`${E2eHelpers.baseUrl}${url}`)
.waitForElementVisible('body', Timeouts.normal);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this because localStorage isn't set until the body is already loaded? If that's the case, I'd guess that the URL paramater approach would be the way to go. It would just take a couple of changes in test-server.js, I think.

Something for a future PR, perhaps!

});
}

module.exports = mock;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems fine for now. The helpers.js files aren't particularly idiomatic anyway...

@jkassemi
Copy link
Contributor Author

jkassemi commented Jan 3, 2017

Test runtimes (observed):

parallelization unit e2e accessibility
no 43s 4m59s 3m13s
yes 44s 1m13s 1m13s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants