Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

[wip] Re-enable test:browser #1251

Closed
wants to merge 39 commits into from
Closed

Conversation

giorgiosironi
Copy link
Contributor

No description provided.

@giorgiosironi
Copy link
Contributor Author

@giorgiosironi
Copy link
Contributor Author

https://alfred.elifesciences.org/blue/organizations/jenkins/pull-requests-projects%2Felife-xpub/detail/PR-1251/5/pipeline has a similar output:

test/helpers/setup.js::startServer
test/helpers/setup.js::startServer await start
test/helpers/setup.js::startServer
test/helpers/setup.js::startServer
test/helpers/setup.js::startServer
test/helpers/setup.js::startServer started

Multiple startServer shouldn't really happen.

@giorgiosironi
Copy link
Contributor Author

The actual hanging is happening after

test/helpers/setup.js::setup await startS3Server

so logs are needed after that line.

@giorgiosironi
Copy link
Contributor Author

More recent runs:

 Submission
test/helpers/setup.js::startServer start
test/helpers/setup.js::startServer !server
test/helpers/setup.js::startServer await start
test/helpers/setup.js::startServer start
test/helpers/setup.js::startServer !server
test/helpers/setup.js::startServer start
test/helpers/setup.js::startServer !server
test/helpers/setup.js::startServer start
test/helpers/setup.js::startServer !server
test/helpers/setup.js::startServer started
test/helpers/setup.js::startServer end
test/helpers/setup.js::setup start
test/helpers/setup.js::setup createTables
test/helpers/setup.js::setup replaySetup
test/helpers/setup.js::setup await startS3Server
test/helpers/setup.js::setup end

Yes, testcafe is calling startServer() multiple times after the first attempt is still going on. That attempt eventually hangs after setup() so it may not be related, but it shouldn't happen.

@giorgiosironi
Copy link
Contributor Author

https://alfred.elifesciences.org/blue/organizations/jenkins/pull-requests-projects%2Felife-xpub/detail/PR-1251/41/pipeline got stuck like this

[Tue Jan 08 2019 10:12:50 GMT+0000 (UTC)][4710935] test/helpers/setup.js::startServer start
[Tue Jan 08 2019 10:12:50 GMT+0000 (UTC)][4710935] test/helpers/setup.js::startServer !server
[Tue Jan 08 2019 10:12:50 GMT+0000 (UTC)][4710935] test/helpers/setup.js::startServer await start
[Tue Jan 08 2019 10:14:51 GMT+0000 (UTC)][4710935] test/helpers/setup.js::startServer started
[Tue Jan 08 2019 10:14:51 GMT+0000 (UTC)][4710935] test/helpers/setup.js::startServer end
[Tue Jan 08 2019 10:14:51 GMT+0000 (UTC)][9830361] test/helpers/setup.js::setup start
[Tue Jan 08 2019 10:14:51 GMT+0000 (UTC)][9830361] test/helpers/setup.js::setup createTables
[Tue Jan 08 2019 10:14:51 GMT+0000 (UTC)][9830361] test/helpers/setup.js::setup replaySetup
[Tue Jan 08 2019 10:14:51 GMT+0000 (UTC)][9830361] test/helpers/setup.js::setup await startS3Server
[Tue Jan 08 2019 10:14:51 GMT+0000 (UTC)][9830361] test/helpers/setup.js::setup end

which should be enough to think that even if there are other calls to startServer, they are not necessary for the problem to happen.

@giorgiosironi
Copy link
Contributor Author

https://alfred.elifesciences.org/blue/organizations/jenkins/pull-requests-projects%2Felife-xpub/detail/PR-1251/48/pipeline/39/ seems to get to the start of the test, will need to collect more data in case different runs differ on where they get stuck.

@giorgiosironi
Copy link
Contributor Author

@giorgiosironi
Copy link
Contributor Author

Note: at least until 4587185 we are able to reproduce the hanging behavior.

@giorgiosironi
Copy link
Contributor Author

@giorgiosironi
Copy link
Contributor Author

Debug options do not tell us much more. Afraid we need to patch testcafe to understand what's going on in there as the control is not in our code.
Any Node.js debugger we could use to understand the flow without having to instrument code with patches?

@giorgiosironi
Copy link
Contributor Author

giorgiosironi commented Jan 9, 2019

Theory: too long fixtures can cause the test suite to hang (>2 minutes or similar).
https://alfred.elifesciences.org/blue/organizations/jenkins/pull-requests-projects%2Felife-xpub/detail/PR-1251/130/pipeline/39/ seems to contradict this theory as the fixtures took 16:47:46 - 16:45:35 = 131 and the test completed correctly. However, this was with only 1 test remaining in the test suite so we may need 2 tests to reproduce the bug.

@giorgiosironi
Copy link
Contributor Author

giorgiosironi commented Jan 9, 2019

Last 10 builds all hanging, this is now reproducible, I think. I also reproduced it locally by changing the sleep to 121000 (since starting the server takes less time locally), followed by:

ln -sf .env.ci .env # same env as Jenkins
docker-compose -f docker-compose.yml -f docker-compose.ci.yml build
docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d postgres
NODE_ENV=production NODE_CONFIG_ENV=test PGDATABASE=test_browser docker-compose -f docker-compose.yml -f docker-compose.ci.yml run -p 10081:10081 --rm --name elife-xpub_app_test_browser app bash -c 'socat -d tcp-listen:10081,reuseaddr,fork tcp:localhost:10080 & npm run test:browser -- --screenshots /tmp/screenshots --screenshots-on-fails'

Jenkinsfile Outdated
@@ -79,6 +70,14 @@ elifePipeline {
}
}

stage 'Browser Tests', {
actions['test:browser'] = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

actions is a dictionary of functions to be executed by parallel, so if you want to execute the browser tests here you have to remove this assignment and just use the contents of the { withCommitStatus(...) } 0-argument function

actions['test:browser'] = {
withCommitStatus({
sh "IMAGE_TAG=${commit} NODE_ENV=production NODE_CONFIG_ENV=test PGDATABASE=test_browser docker-compose -f docker-compose.yml -f docker-compose.ci.yml run -p 10081:10081 --rm --name elife-xpub_app_test_browser app bash -c 'socat -d tcp-listen:10081,reuseaddr,fork tcp:localhost:10080 & npm run test:browser -- --screenshots /tmp/screenshots --screenshots-on-fails'"
}, 'test:browser', commit)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

you also need the setup around it, since this command assumes a database started and ready:

            try {
                sh "IMAGE_TAG=${commit} docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d postgres"
                sh "IMAGE_TAG=${commit} docker-compose -f docker-compose.yml -f docker-compose.ci.yml run --rm --name elife-xpub_wait_postgres app bash -c './scripts/wait-for-it.sh postgres:5432'"
                // do things
            } finally {
                sh "IMAGE_TAG=${commit} docker-compose -f docker-compose.yml -f docker-compose.ci.yml down -v"
            }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also, the archiveArtifacts in finally is missing, which publishes the screenshots on the Jenkins UI

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah we removed that ... @damnhipster says they don't work anyway :)

@hem-brahmbhatt hem-brahmbhatt mentioned this pull request Jan 9, 2019
5 tasks
@hem-brahmbhatt
Copy link
Contributor

Closing as fix has been implemented in #1273

@hem-brahmbhatt hem-brahmbhatt deleted the reenable_browser_tests branch January 10, 2019 10:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants