Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
In order to have javascript tests at some point for core it would be nice to have phantomjs installed.
#2469713: Step 2: Create a JavaScriptTestBase using PhantomJs Driver/Binary
Proposed resolution
Remaining tasks
- Wait for containers to be rebuilt and AMI's to be updated.
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#108 | 2580007-Add_phantomjs2_to_the_testrunners-108.patch | 15.22 KB | isntall |
#98 | 2580007-98.patch | 1.85 KB | isntall |
#97 | 2580007-97.patch | 3.14 KB | dawehner |
#91 | interdiff.txt | 2.41 KB | dawehner |
#91 | 2580007-4.patch | 5.1 KB | dawehner |
Comments
Comment #2
dawehnerSo is that something like a start?
Comment #3
dawehnerSome more work.
Comment #4
elachlan CreditAttribution: elachlan commentedComment #5
elachlan CreditAttribution: elachlan commentedComment #6
elachlan CreditAttribution: elachlan commentedIn #2575501: [PP-2] DrupalCI should return failed for poor code style - JS they need to update the container definition to include:
It would make sense to update the container definition in one issue.
jslint requires npm to install. Using the command
sudo npm install -g jslint
Comment #7
elachlan CreditAttribution: elachlan commentedSome minor changes to add the packages.
Not sure how to add the npm command. Might have to be just below the package installs.
Comment #8
elachlan CreditAttribution: elachlan commentedAdded the npm command and fixed some white space problems
Comment #9
attiks CreditAttribution: attiks at Attiks commentedIt looks like this patch is doing more then adding phantomjs, isn't it easier to just add phantomjs, eslint to the image?
There's also a job attached, but it says PHPUnit?
Why is epm needed?
We need to install eslint
Is a default of 5.5 not better?
Comment #10
elachlan CreditAttribution: elachlan commentedIts merging in changes for #2575501: [PP-2] DrupalCI should return failed for poor code style - JS as well, since they both are changing the container. How would we go about adding them to the image?
Not sure, it was in the first patch.
I was going off what was stated in https://www.drupal.org/node/2575501#comment-10441657
I epm might have been a typo?
I agree 5.5 is a better default.
Comment #11
dawehnerIf I understand things correctly than we actually don't need a new job because BrowserTestBase will already be executed via run-tests.sh and the testbot team actually wants to keep that wrapper, which is kinda sad, but yeah I'm curious whether setting up phantomjs + using run-tests.sh would be enough already.
I think we should just add what is really needed as part of this test, you know, we want to avoid changing too many things at the same time. Filing another patch is easy
Oh yeah we need to rename the class
Comment #12
dawehnerBtw. Thanks so you much for helping on this issue!!
Comment #13
nod_npm install -g jslint
we use eslint, not jshint.
Comment #14
elachlan CreditAttribution: elachlan commentedChanged to eslint and removed epm. Kept php 5.4 because all the other files have it as the default. I think if we update it then ALL of them should be updated at the same time. That can be done in another issue.
@dawehner, not sure what to call the class. Maybe PHPJSUnitJob?
Comment #15
attiks CreditAttribution: attiks at Attiks commented#14 or PHPUnitJSJob
Comment #16
elachlan CreditAttribution: elachlan commentedI like #15 better.
@attiks - simpletest has a default php 5.5, but phpunit has php 5.4. Do you want me to do up another issue to mark them all as php5.5 as a follow up issue?
Comment #17
attiks CreditAttribution: attiks at Attiks commented#16 Since it is a default it really doesn't matter that much, but would be nice to change it to 5.5
Comment #18
elachlan CreditAttribution: elachlan commentedWhat does everyone think of the class name?
PHPJSUnitJob or PHPUnitJSJob?
Comment #19
dawehner@elachlan
For now its actually enough to just keep the run-tests.sh one, as this is also running the functional tests, all we need is to have phantomjs setup for those as well.
Comment #20
elachlan CreditAttribution: elachlan commentedOk, so what needs to be done?
Comment #21
elachlan CreditAttribution: elachlan commented@dawehner Does that mean we really only need the dockerfile now?
Comment #22
dawehnerWell I think this is all we actually need is the following ...
Comment #23
elachlan CreditAttribution: elachlan commented@dawehner - What about the stuff required for #2575501: [PP-2] DrupalCI should return failed for poor code style - JS?
Did you want to do it in another issue?
Comment #24
dawehnerYeah, well, they are all technically out of scope of this issue.
Technically its not necessarily about the change, but it makes life harder for reviewers if there are unrelated changes. Rerolling a patch is easy compared to the other aspects of work on an issue.
Comment #25
elachlan CreditAttribution: elachlan commentedOK cool the patch looks ok to me then.
Comment #26
elachlan CreditAttribution: elachlan commentedAnyone else want to Review the patch? It is significantly smaller.
Comment #27
attiks CreditAttribution: attiks at Attiks commented#22 Looks good
Comment #28
elachlan CreditAttribution: elachlan commentedThe parent issue #2469713: Step 2: Create a JavaScriptTestBase using PhantomJs Driver/Binary says to use composer to install PhantomJS. Which would mean the version is consistent in the test environment. The way we have implemented it looks like it would install what ever is the latest version. Is this correct?
Comment #29
attiks CreditAttribution: attiks at Attiks commentedInstalling phantomjs for each run will slow down all tests, AFAIK the latest stable phantomjs version for linux is 1.9.8, it's been like that for a while.
Comment #30
dawehnerThis is just the issue summary IMHO
Comment #31
elachlan CreditAttribution: elachlan commentedOk, just checking we were doing the right thing. Thanks for the clarification :)
Comment #32
isntall CreditAttribution: isntall at Drupal Association commentedI have a branch with phantomjs and moved the command to call phatomjs in the drupalci.yml file for simpletest.
Comment #34
elachlan CreditAttribution: elachlan commentedLooks ok to me. Would be good to get another review other than me.
Comment #35
attiks CreditAttribution: attiks at Attiks commentedLooks ok to me as well
Comment #36
MixologicYup +1. It has to go into the job. /var/www/html/vendor wont even exist until we setup the codebase.
Comment #37
isntall CreditAttribution: isntall at Drupal Association commentedHere's a staging job i ran with code
https://dispatcher.drupalci.org/job/staging_simpletest_job/281/
(this job and output will not be here indefinitely)
Comment #38
elachlan CreditAttribution: elachlan commentedLooks like it executed ok? Doesn't look like it has broken anything.
What should we be looking for?
Comment #39
isntall CreditAttribution: isntall at Drupal Association commentedComment #40
isntall CreditAttribution: isntall at Drupal Association commentedThis has been merged into dev, production and is now live.
Comment #41
dawehnerYeah!!
Thank you @isntall!
Comment #42
Wim Leers\o/
Comment #43
isntall CreditAttribution: isntall at Drupal Association commentedphantomjs is in there, and executed, but it's not working. The phantomjs program stops running.
Comment #44
elachlan CreditAttribution: elachlan commentedCould we pipe the output to a file to get some more information? Are there any logs?
Comment #45
elachlan CreditAttribution: elachlan commentedWe need some help over at #2609560: Base DCI containers off official containers, which hopefully will simplify the containers and help get phantomJS working.
Comment #46
isntall CreditAttribution: isntall at Drupal Association commentedUnfortunately getting phantomjs to stay running in back gournd and #2609560: Base DCI containers off official containers are separate issues.
In this issue even though phantomjs is set to run in the background, it does not.
And phantomjs needs to be started after patches are applied to be sure it gets the latest changes.
Comment #47
elachlan CreditAttribution: elachlan commentedBoth of these issues suggest to use nohup.
https://code.google.com/p/phantomjs/issues/detail?id=474
https://github.com/Codegyre/Robo/issues/180
Comment #48
isntall CreditAttribution: isntall at Drupal Association commented@elachlan that might have been the missing piece.
i was trying to use the daemon command to run phantomjs and that wasn't working.
daemon -- nohup phantomjs --ssl-protocol=any --ignore-ssl-errors=true /var/www/html/vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768
seems to keep phantomjs up in the background
https://dispatcher.drupalci.org/job/staging_simpletest_job/319/
Also, could someone tell me what i'm looking for with phantomjs and run-test.sh in the console output. I have not seen it working with run-test.sh, so i don't know what to look for.
Comment #49
elachlan CreditAttribution: elachlan commentedThe thing is we don't have much until its combined with #2469713: Step 2: Create a JavaScriptTestBase using PhantomJs Driver/Binary. Which should run tests the ToolbarIntegrationTest. At least that is what I think is supposed to happen.
Comment #51
isntall CreditAttribution: isntall at Drupal Association commentedI've something very close to 4f66c90 and it seemed to keep phantomjs running. Once has been reviewed i can commit it to dev and test it again.
Comment #52
dawehnerThanks a lot isntall!
Why do we need the sleep here? Just curious
Comment #53
MixologicSo that we dont start testing before the phantomjs server has had time to initialize. The daemon nohup will return immediately and start testing if its not there.
Comment #54
isntall CreditAttribution: isntall at Drupal Association commentedI had basic review this over my shoulder, and he said it looked good. I'm going to commit it to dev.
Comment #55
elachlan CreditAttribution: elachlan commentedThanks isntall!
Comment #57
dawehnerInteresting, I would have expected that daemon doesn't continue until the daemonized process is ready to rock
Comment #58
MixologicThe container changes have been deployed to production, so we can now rebuild the containers and the AMI. Once that is done we can uncomment this and push it up as well.
Comment #59
MixologicComment #60
dawehner@Mixologic
So can we uncomment things now? Just being curious.
Comment #61
elachlan CreditAttribution: elachlan commentedWaiting on it being re-enabled to test the other issue.
Comment #62
elachlan CreditAttribution: elachlan commentedWhen testing this it failed for me because daemon wasn't installed.
Here is the fix as well as re-enabling.
It seems to pass testing locally as well when running tests from #2469713: Step 2: Create a JavaScriptTestBase using PhantomJs Driver/Binary.
Edit: ToolbarIntegrationTest didn't pass. But BrowserWithJavascriptTest did.
Comment #63
dawehnerNice! Thank you @elachlan
Comment #64
Mixologic@elachlan: I think you're working off of the wrong branch or something. You'll notice that its already added in this commit: http://cgit.drupalcode.org/drupalci_testbot/commit/?id=4f66c90
This needs work because there isnt a patch that can be submitted to move this forward, there is infrastructure deployments that need to happen. Once those do, we can uncomment and proceed.
Comment #65
dawehnerSo we basically just wait?
Comment #66
elachlan CreditAttribution: elachlan commentedYes I see it, sorry.
Comment #67
MixologicOkay, not closing until we know theres nothing else to do testbot wise, but we have this in production now. Give it a whirl.
Comment #68
dawehnerAwesome!
Comment #69
elachlan CreditAttribution: elachlan commentedApparently we need version 2 to be able to use BIND.
See #2469713: Step 2: Create a JavaScriptTestBase using PhantomJs Driver/Binary.
Comment #70
elachlan CreditAttribution: elachlan commentedThis was harder than I expected.
There is no official package. So I tried using npm/nodejs/phantomjs2. But that failed.
So then I saw the npm package phantomjs2 was just installing the binary from https://github.com/bprodoehl/phantomjs/releases/
So I ended up just using that.
Comment #71
elachlan CreditAttribution: elachlan commentedComment #72
elachlan CreditAttribution: elachlan commentedThe reason I am installing from the git repository is that PhantomJS are having issues compiling a static linux binary. Associated issue can be found at https://github.com/ariya/phantomjs/issues/12948
Once a release has been finalised, an official package will be released and we can use apt-get again.
You can track the release of phantomjs 2.0.1 at https://github.com/ariya/phantomjs/issues/12902
Comment #73
dawehnerI guess some review from the CI team would be great, but it fixes the problems, yeah!!
Comment #74
xjmAs a blocker for frontend testing, this issue is quite important.
Comment #75
elachlan CreditAttribution: elachlan commentedPhantomJS issue on github has been updated.
They are waiting until the release of phantomjs 2.1 and are using docker to build the static binaries.
https://github.com/ariya/phantomjs/issues/13822
This will mean sometime in the next few months we will have a proper package to install from.
Comment #76
dawehnerLet's ping everyone again, to get some more attention again. We have a ready patch since 1,5 months now.
Comment #78
elachlan CreditAttribution: elachlan commentedThanks for that isntall.
So phantomjs finished up on their issue, but still have sub issues and blockers for their 2.1 release. They are also trying to find a CI system reflecting their changes to use docker.
https://github.com/ariya/phantomjs/issues/13828
So if anyone could give some advice on that, it would probably be appreciated.
Comment #79
MixologicLooks to me like SemaphoreCI is stepping up to help them with their build process.
Comment #80
elachlan CreditAttribution: elachlan commentedYes, It looks that way.
I don't see a definitive list of issues for the release. So it is not clear when an official package for ubuntu/debian will be released.
Comment #81
elachlan CreditAttribution: elachlan commentedI take that back.
Here is the list:
https://github.com/ariya/phantomjs/milestones/Release%202.1
Comment #82
isntall CreditAttribution: isntall at Drupal Association commentedI d not have the time to look too deep into this, but here are the results
https://dispatcher.drupalci.org/job/staging_simpletest_job/343/
latest web-5.5:dev container
https://www.drupal.org/files/issues/2469713-jtb.102.patch
drupal commit a34dfb2
Comment #83
elachlan CreditAttribution: elachlan commentedJust to keep everyone updated. The above test failed.
Someone will have to run it locally to get the actual outputted error from the tests.
Comment #84
dawehnerI'm looking into that.
Comment #85
dawehnerOne interesting thing I observed is that there are more and more phantomjs processes started:
The next one is the following error message:
So we seem to have to forward port the 8510 port to the php/web container, currently in the process of figuring that out.
Comment #86
dawehnerSo it worked temporarily when I killed all of those 63 instances and then after a while it didn't worked anymore.
Maybe a guess: we could use
--name
and--restart
in order to ensure we just have one phantomjs instance running at a time and that one is able to use port 8510 always?Comment #87
isntall CreditAttribution: isntall at Drupal Association commentedI've pushed up the changes to phantomJS to DCI so it is baked into the production containers.
(these changes shouldn't make much of a difference, but now we don't need to install daemon before the tests run)
Comment #88
isntall CreditAttribution: isntall at Drupal Association commentedLooking at one of the updated testrunners:
which should be correct.
Comment #89
elachlan CreditAttribution: elachlan commentedPhantomJS have prepared the packages for 2.1.1 and are looking to release in the next couple of days.
https://github.com/ariya/phantomjs/issues/12970
Comment #90
elachlan CreditAttribution: elachlan commentedIts available now.
http://phantomjs.org/download.html
Comment #91
dawehnerAs described in #2469713: Step 2: Create a JavaScriptTestBase using PhantomJs Driver/Binary we want to skip using concurrency for the javascript tests.
Comment #92
elachlan CreditAttribution: elachlan commentedThe URL needs to change to use the new official static compiled binary.
https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x8...
Something along the lines of this, we also won't need unzip any more!
Comment #93
xjmIn a meeting with the core committers and DA infrastructure staff today, we learned that it will take a lot of resources or a long time to actually implement this on DrupalCI. A workaround was proposed for the short-term: #2663086: [meta] Determine whether run-tests.sh can trigger and report phantomjs and phpcs results
Comment #94
attiks CreditAttribution: attiks at Attiks commented#93
a lot of resources or a long time
What does this mean, is this hours, days, months, 100$, 1000$, 10000$, ...
If we don't add - proper - js testing, how will we test issues like: #2645250: [META] Start using reactive declarative JS programming for some new core admin UIs, #2651660: Investigate where and how a frontend framework could be used
Comment #95
dawehnerIts super confusing why we stop working on something right before we have something actually working.
Comment #96
attiks CreditAttribution: attiks at Attiks commented##9 Agree, would love to hear what the problem is why this cannot be done.
Comment #97
dawehnerNow that #2670978: Allow to run just specific types when running all tests changed its direction, we need to adapt the job types as well.
This now runs properly on my local testbot instance.
Comment #98
isntall CreditAttribution: isntall at Drupal Association commentedHere's the patch I've been working on that keeps everything in on Job Type.
Comment #100
MixologicOnly the top commit is relevant in that latest barrage of commits (apparently versioncontrol comments is going to go back through history and post every one with a matching label)
So, a couple of things were discussed in IRC.
1. We cannot currently merge this in until both:
#2670978: Allow to run just specific types when running all tests and #2680057: Allow to not override the simpletest results on a new test run land in core
Those may not land in 8.0.x because nobody wants to keep adding stuff there unless its a CVE. But we cant break 8.0.x testing until 8.0.x it utterly closed, because there might be a CVE.
So, in order to get this in we need to modify this patch/branch to detect if it is running on 8.0.x, and if so, skip running the second testcommand, and set the DCI_TestGroups back to just --all:
This will need to work with both contrib modules testing against 8.0.x as well as core 8.0.x tests. If we can build in that backwards compatibility, then we can:
1. commit #2670978: Allow to run just specific types when running all tests and #2680057: Allow to not override the simpletest results on a new test run to 8.1.x
2. commit this to drupalci prod as a hotfix.
3. Test it out using #2469713: Step 2: Create a JavaScriptTestBase using PhantomJs Driver/Binary
Comment #101
MixologicMarking this postponed until we know for sure whether the core maintainers want to allow the previous patches into 8.0.x, or whether we should build in backwards compatibility. (or until 8.0.x is completely closed - whichever comes first)
Comment #102
dawehnerBoth will be done, as it seems to be.
Comment #103
isntall CreditAttribution: isntall at Drupal Association commentedChanges to core have been committed adding the functionality for this patch to be available.
This patch has been deployed as a hotfix.
Comment #104
MixologicAn update: So despite the nohups and the daemons, phantomjs still does not like to stay running in the container. This is currently due to some magic inside of the
daemon
command, coupled with docker, that causes the daemon process that is responsible for restarting the phantomjs service to be a child of the apache process that the container is based around.Apache has this tendency to think every process that is a child of it must have been spawned by it, so therefore it also times some things out.
We're currently exploring ways to either get phantomjs to run as a restarting daemon, or perhaps we can figure out which apache setting could maybe be set to forever.
Comment #105
dawehnerThank you @Mixologic for keeping up with the work with it!
Comment #106
isntall CreditAttribution: isntall at Drupal Association commentedWe're currently working on a strategy to make a bash process the PID 1 and not apache2; all other processes children of that initial bash process.
Comment #108
isntall CreditAttribution: isntall at Drupal Association commentedHmmmm...comment 107 is not showing the commit I added to 2580007-Add_phantomjs2_to_the_testrunners branch, 3e58bac788886efbb44c9101e5fcaddda173dc22; the branch is based off of production.
Here's the diff too.
Comment #109
MixologicThis looks good to me. Lets see how we fare.
Comment #110
alexpottSo is this all deployed?
Comment #111
MixologicDocker hub is being a PITA right now.. taking a long time to rebuild the containers after the fixes, and when it does it's been having sporadic, unrelated issues. As soon as the containers rebuild, we'll be able to tag and deploy this to production.
Comment #112
dawehnerThanks again @Mixologic and @isntall for the continuing work on this issue!
Comment #113
Wim LeersYay! Thanks, @Mixologic and @isntall! :)
Comment #114
alexpottAny news on the deployment? Looking at the output from the latest test runs on core it does not look to be.
Comment #115
isntall CreditAttribution: isntall at Drupal Association commentedAfter a lot of builds and testing, the deployment was boring as I hoped it'd be.
All that to say phantomJS seems to be stable and running in the docker containers.
Comment #116
elachlan CreditAttribution: elachlan commentedLooks like #92 wasn't added. This would move us to using an official release.
It doesn't look like it will get added to apt-get any time soon. As there is a security issue with it listed on debian.
https://security-tracker.debian.org/tracker/CVE-2013-4549
From my understanding it can only move out of testing when it has no more security issues or something like that. So ubuntu won't get it until after its finalised in debian.
From what I can tell it seems that it won't get fixed until PhantomJS 2.2 is released.
https://github.com/ariya/phantomjs/issues/14102
Comment #117
MixologicRe: 116: I think we're fine using the fork for now. This current implementation shoves phantomjs in where it doesnt go, with the goal of unblocking core.
We should open another issue to introduce a standalone phantomjs container, as our current situation will for the time being, but the lack of parallelization and the fact that we have phantom running inside the php container isnt what we want.
Marking this as fixed and opened a new issue #2702849: Improve phantomjs infrastructure
Hooray for javascript testing!
Comment #118
Mixologic