As a followup to #3029816: Convert screenshot automation to WebDriverTestBase, in this issue I need to:
Set up for running tests on the DrupalCI test bot. I will need to figure out how to tell the test bot to download MAYO and Admin Toolbar. Plus there are still two core patches that have to be applied to get nice screenshots. All of this is possible -- there is help at
https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-tes...
As a note, I think that patches to the testing YAML file don't actually come through and affect tests on DrupalCI, because it's a catch 22 -- that file is used to set up the environment. So, I think I'll need to commit changes to that YAML file rather than using patch testing.
Current status as of comment #21:
- The tests are not running because the screenshots are coming up blank. See comment #18 for a discussion of that.
- If I am able to get the tests running, I need to check on whether the Drupal Core, Mayo theme, and Admin toolbar versions are showing up correctly in screenshots. If not, may need to run a shell command to fix some info.yml files.
- If I am able to get the tests running, I should update the README.txt at the top level of this project and explain where to find the backups and screenshots in the test output.
- Also if I am able to get the tests running, I should update the backups -- see #3035960: Export new database and file backups for all languages
Comment | File | Size | Author |
---|---|---|---|
#2 | 2905295-work-around.patch | 523 bytes | jhodgdon |
Comments
Comment #2
jhodgdonAs part of this setup, we will need to apply a patch that gets around issue #2905295: Configuration language being overwritten during module install. Here is the necessary patch (see also the README.txt file in the auto_screenshots directory, which explains this patch).
Comment #8
jhodgdonComment #12
jhodgdonIt looks like what I actually need to do here is move the tests and auto screenshots code to a separate project. DrupalCI seems to have a problem dealing with the User Guide repo, because it is VERY large (with all the images for all the languages). So... I'll be setting that up shortly, and then once that is done, deleting this part of the code from the existing User Guide project and adding a note to the README and to the project page about the separate project just for testing.
Comment #13
jhodgdonMoving to the new project...
Comment #18
jhodgdonWell, I finally got the environment set up on DrupalCI. But the tests are failing the first time they come to a screenshot. It looks like the image from the chromedriver browser is empty, because when I try to auto-crop it down with
http://us1.php.net/manual/en/function.imagecropauto.php
the return value is a Boolean (false I would assume).
It looks like this is because Chrome is being set up to run in "headless" mode (no UI). And it looks like when it's in headless mode, screenshot images come up blank:
https://stackoverflow.com/questions/52416069/how-to-get-screenshots-from...
https://serverfault.com/questions/856748/selenium-chromedriver-makes-bla...
https://bugs.chromium.org/p/chromium/issues/detail?id=714058
It seems to be a bug in Chrome and/or Chromedriver, because it is supposed to work. And it looks like the bug has been fixed in the dev versions of Chromium, but the fix may not be in the version of Chrome/Chromium that DrupalCI is running.
Someone posted a work-around to unset the "TZ" environment variable before running Chrome, via
unset TZ
, so I am going to try adding that in.Comment #20
jhodgdonThat TZ setting didn't help. I'll have to talk to infra next week.
Comment #22
jhodgdonUpdating summary with remaining To Dos if I get the tests running.
Comment #23
jhodgdonI created (temporarily) a Drupal Core test to verify that screenshots were not all blank on this related issue. The test passed. So, I am trying to recreate the problem in a new test file in this project...
Comment #25
tacituseu CreditAttribution: tacituseu commentedTried testing with the same environment that passed on 8.7.x core ? maybe the problem is specific to PHP 7.1 environment ?
Comment #26
jhodgdonGood point, I will check on that shortly! Adding a bit to a new test here too... It looks like it is specifically the cropping that is failing. When I test pixels, that works in this environment.
Comment #28
jhodgdonTo clarify:
The test I patched in the drupal core issue took a screenshot and verified it had at least 2 colors in it.
The test I am trying here (in commits on this issue) goes one step further and uses the imagecropauto GD function to crop it down, which is what is currently failing in my (much larger) tests (the ones that work on my home system but not on DrupalCI).
The fail I am seeing here in my latest tests on drupal CI is in the crop step. The part that verifies the colors is working. So, I have added some to the test so that it will also save the uncropped image so I can look at it manually.
Comment #29
jhodgdonI should check on PHP 7.2 though, that's a good point. My home system where the tests were working is running PHP 7.2.15.
Comment #31
jhodgdonSigh. I really don't know what is going on.
In my latest test, I saved the image to a file before it was cropped. The image looks fine:
https://dispatcher.drupalci.org/job/drupal_contrib/339932/artifact/jenki...
Then just after saving that image, I do in my test
That fails. However, I tried these commands at home in php -- interactive:
This prints out "full image" and a 650 pixels width. So, imagecropauto is working fine on my local system, at least after importing the saved image file, but it is failing on the bot.
I have now also tested this in both PHP 7.1 and 7.2, and it behaves the same.
Comment #32
tacituseu CreditAttribution: tacituseu commentedimagecropauto
bug then ? Tried this suggestion ?Edit: Environments are a bit stale (PHP 7.2.8), checking changelog.
Comment #33
tacituseu CreditAttribution: tacituseu commentedPossibly:
- https://bugs.php.net/77198 auto cropping has insufficient precision
- https://bugs.php.net/77200 imagecropauto(…, GD_CROP_SIDES) crops left but not right
the PHP 7.2.x-dev & MySQL 5.5 environment looks fresh (
PHP 7.2.17-dev (cli) (built: Mar 2 2019 18:17:12) ( NTS )
), maybe worth giving it a try ?Comment #34
jhodgdonI am trying to do IMAGE_CROP_SIDES, and that is failing in my pared-down test... although I could try the THRESHOLD function and just crop white, which is probably what I need in 99% of the images anyway.
In the cases in #33, the problem there is that not enough of the image is cropped, not that the whole thing is cropped.
But yeah I'll try the threshold crop and see if that works. Good idea!
Comment #36
jhodgdonI played around with the threshold cropping on my local PHP install, and it looks like this line works the closest to the (working for me) IMG_CROP_SIDES:
So that last commit tries that in my DrupalScreenshotTest. Should have a result in a little while...
Thanks for the suggestions @tacituseu
Comment #39
jhodgdonSigh. The IMG_CROP_THRESHOLD change did not fix the problem either. The cropping still fails on DrupalCI.
So, I think I just have to not do the cropping. It's not terrible -- I can crop the images at the command line afterwards with a simple shell script.
Comment #41
tacituseu CreditAttribution: tacituseu commentedI tried it on old 7.0.22 I had around on the exact same .png and it failed too (returned false after the
imagecropauto
), then on 7.0.33 and it worked, tryPHP 7.2.x-dev
environment if it's available for projects as the other ones are old.The bugs show that the function has been reworked recently, so even if the bug reports weren't exactly about this issue, it might have been fixed by the changes too.
Edit: used this snippet:
Comment #44
jhodgdonI just turned on cropping again in my short test, and it even failed on PHP 7.3.x-dev. So, I think it is just too problematic.
Comment #47
jhodgdonOK, now that I am not trying to crop images, I have a new problem with some of the tests. Again, this works locally but not on DrupalCI.
The test is attempting, at several points, to submit an image file to an image file field on a node/add page.
Earlier in the test, I have verified that the file exists and is readable -- at least, it is readable by the web server user:
But the test is failing on this line later on, when trying to upload that exact same file:
with this message and call stack:
So, apparently the file or directory is not readable by the chromedriver.
Comment #50
jhodgdon@lendude helped me out in Slack with this. Apparently in WebDriverTestBase, when running on DrupalCI, you cannot post forms with images. You need to use attachFileToField() instead. So... a new commit for that.
Comment #51
tacituseu CreditAttribution: tacituseu commentedNot sure if known, but while trying to figure out what's with the cropping, noticed those in test.apache.error.log:
Comment #54
jhodgdonThanks! I doubt that is the problem but I have just fixed it. That was left over from when this test had a different directory structure.
Comment #57
jhodgdonMaking progress! The next problem I've encountered is that in one part of the test, we go to the Available Updates page to see what updates are available. When running the tests in person, the environment set up (pre-using-composer) had you download a not-quite-current version of a contrib module and a contrib theme, so that there would be something on this page.
The current setup is using Composer to download these by putting explicit versions in the composer.json file, but they are not showing up on Available Updates. Having run the same composer commands on my local system, I can see that the correct versions are being downloaded from Git anyway. Also, you can see it in the build artifacts for the test run:
However, I can see on my local system that the info.yml files for Mayo and Admin Toolbar don't have the versions in them (they would be in there if you downloaded the tar file but not via Git), and I can see from the screenshots in the test output that the Mayo theme is showing up on the Appearance page as being version 8.6.10 (the same as the version of Core I am using). It looks like when Drupal parses .info files, it will put in whatever is in core/lib/Drupal.php in the VERSION constant as a default (which is the core version).
So I think I just need to add two lines to my build to put the versions into the info.yml files for Mayo and Admin Toolbar. Should be easy enough...
Comment #60
jhodgdonThere has been a problem in some languages early in the test with the node/add/page testing. This turned out to be a Core bug:
#3037729: Duplicate filter format weights (turns off CKEditor by default in some languages)
which I patched, so adding this patch to the drupalci.yml file.
Also there is still a problem in the updates report that I cannot reproduce locally. Trying a work-around...
Comment #66
jhodgdonWoot! The tests finally all passed! I fixed the problem with the update report by adding to the info.yml files for the contrib theme/module, so they look like what you get when you download a tar.gz file of a release (i.e, added the project, version, and timestamp lines) -- this allowed the Update module to get correct update information.
So, I'm now going over to #3035960: Export new database and file backups for all languages to update the screenshots (as needed) and backups.
Thanks again to @tacituseu, @Mixologic, and @Lendude for all of your help, on this issue and in Slack!
Comment #67
tacituseu CreditAttribution: tacituseu commentedNoticed a sign of #2852605: Error on installing via Drush: Invalid data type in config mayo.settings in test.apache.error.log.
Comment #68
jhodgdonYeah, I've filed an issue in Mayo about a config problem as well -- could be a duplicate?
#2790873: Missing schema
Oh, both are by me. :)