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

With Travis - Behat fails, selenium not running. #70

Open
roperto opened this issue Nov 23, 2017 · 24 comments
Open

With Travis - Behat fails, selenium not running. #70

roperto opened this issue Nov 23, 2017 · 24 comments

Comments

@roperto
Copy link

roperto commented Nov 23, 2017

It seems like a Java problem (surprise surprise)

Workaround: add sudo: required to .travis.yml

roperto added a commit to catalyst/moodle-local_envbar that referenced this issue Nov 29, 2017
dionysius added a commit to studentquiz/moodle-mod_studentquiz that referenced this issue Jan 10, 2018
stronk7 added a commit to stronk7/moodle-local_codechecker that referenced this issue Jan 19, 2018
Also moving to plugin-ci 2.x.

And disabling behat tests:

- They don't work with sudo: false
- They work with sudo: required but that adds inestability
  to results in general. Multiple random failures installing stuff.

So disabling seems to be the best option for now, the problem is
being traced @ open-lms-open-source/moodle-plugin-ci#70
@stronk7
Copy link

stronk7 commented Jan 19, 2018

As commented @ 4f97e21, I've tried with sudo: required and it helped with behat executions but, at the same time, introduced a really annoying behavior with random failures all over the place. See:

So, particularly, I'm back to sudo: false + disabled behat (it's not critical in my plugin). And at least that way I get more consistent results. See:

Just sharing, not really sure which the selenium / java problem is. Annoying. Ciao :-)

@roperto
Copy link
Author

roperto commented Jan 19, 2018

Hi @stronk7

I am also getting inconsistent problems updating packages and such.

I disable while developing, but when merging I still want the peace of mind of behat tests passing

Please let us know if you find a workaround, Eloy ...

Thanks

@mackensen
Copy link

I'm seeing the same issues with my plugins. Behat's important to me, so I'm setting sudo: true and re-running failures. This is with version 2 of the plugin.

stronk7 added a commit to stronk7/moodle-local_codechecker that referenced this issue Jan 20, 2018
Also moving to plugin-ci 2.x.

And disabling behat tests:

- They don't work with sudo: false
- They work with sudo: required but that adds inestability
  to results in general. Multiple random failures installing stuff.

So disabling seems to be the best option for now, the problem is
being traced @ open-lms-open-source/moodle-plugin-ci#70
stronk7 added a commit to stronk7/moodle-local_codechecker that referenced this issue Jan 20, 2018
Also moving to plugin-ci 2.x.

And disabling behat tests:

- They don't work with sudo: false
- They work with sudo: required but that adds inestability
  to results in general. Multiple random failures installing stuff.

So disabling seems to be the best option for now, the problem is
being traced @ open-lms-open-source/moodle-plugin-ci#70
stronk7 added a commit to moodlehq/moodle-local_codechecker that referenced this issue Jan 20, 2018
Also moving to plugin-ci 2.x.

And disabling behat tests:

- They don't work with sudo: false
- They work with sudo: required but that adds inestability
  to results in general. Multiple random failures installing stuff.

So disabling seems to be the best option for now, the problem is
being traced @ open-lms-open-source/moodle-plugin-ci#70
@polothy
Copy link
Contributor

polothy commented Jan 22, 2018

Do you guys have more example of build failures? Eloy's failure has nothing to do with Behat, it's failing to install Java8 (oracle-java8-installer, oracle-java8-set-default) because for whatever reason, some of the builds didn't find oracle-java8-set-default package, while others did. This is only needed for the mustache linting IIRC. You could try Java9, but betting that wont work.

@roperto
Copy link
Author

roperto commented Jan 23, 2018

hi @mrmark .. I have more examples but that's exactly the same problem.

We currently have a custom docker image to run moodle-plugin-ci to be used in our GitLab, but it has a lot of custom code.

If we make it more flexible do you think it would be a approach to running it Travis? Hopefully would speedup part of initialisation (it would only pull changes in Moodle since the image was built, composer init, npms, etc) and less prone to Travis infrastructure changes. The initialisation process would still run as phpunit/behat init is required after the plugin is added.

If I went ahead, would you be interested in that or do you think its a dead end?

@mackensen
Copy link

@scara
Copy link

scara commented Jan 23, 2018

@stronk7
Copy link

stronk7 commented Jan 23, 2018

Hi,

just note that only @javascript scenarios require selenium + real browser to be working, so it's normal, for people not having such a tag to get behat passing.

In fact it was working ok for my plugin, but because of a little restriction with checkboxes I needed to add the @javascript tag to one of my features.. and there is where the problem started to happen consistently.

Just to explain/clarify why tests seem to work to some people without problem. It's not magic or luck. Only @javascript scenarios are affected by selenium not working

@stronk7
Copy link

stronk7 commented Jan 23, 2018

OT: just came to my brain... could it be some problem with IPv4/IPv6 ? I've had a flash that some time ago I had to force IPv4 in some places (-Djava.net.preferIPv4Stack=true) because not all the stack was able to work with IPv6 properly (and the system insisted to use IPv6 by default).

As said... just a blind shot!

@polothy
Copy link
Contributor

polothy commented Jan 23, 2018

If we make it more flexible do you think it would be a approach to running it Travis? Hopefully would speedup part of initialisation (it would only pull changes in Moodle since the image was built, composer init, npms, etc) and less prone to Travis infrastructure changes. The initialisation process would still run as phpunit/behat init is required after the plugin is added.

That was proposed in #57 to use moodle-docker, but I was worried about performance. I'd likely only want to move to a core supported/maintained container if we ever went in that direction. I do agree though, there have been a lot of build breaks due to Travis updates, which is too bad.

Thanks everyone for all the examples, feedback!

@scara
Copy link

scara commented Jan 24, 2018

It's not magic or luck. Only @javascript scenarios are affected by selenium not working

TNX @stronk7!
My bad for not thinking at it: shame on Matteo 😊 !

@polothy
Copy link
Contributor

polothy commented Jan 30, 2018

Having lots of troubling figuring out the problem. Have a build I'm debugging here: https://travis-ci.org/moodlerooms/moodle-plugin-ci/jobs/334948327

Anyone know what's going on? Any guesses?

@roperto
Copy link
Author

roperto commented Jan 30, 2018

Hi @mrmark , as you said PHP server (behat site) looks fine.

I'd investigate towards the selenium server, I am guessing a driver/selenium problem from "UnsupportedCommandException" at https://travis-ci.org/moodlerooms/moodle-plugin-ci/jobs/334948327#L1278 -- maybe a mismatch of firefox version and selenium driver?

@scara
Copy link

scara commented Jan 30, 2018

@mrmark @roperto Bad request looks like coming from a 400 HTTP Status: what about SeleniumHQ/selenium#2074 ?

HTH,
Matteo

@polothy
Copy link
Contributor

polothy commented Jan 30, 2018

Thanks @scara, that might be the problem, I commented in travis-ci/travis-ci#8711

There is cat /etc/hosts with sudo false/true:

If it is indeed a problem with /etc/hosts then there is nothing we can do about it because in order to fix it, we would need sudo, so might as well just use sudo: true in your build file until Travis fixes the container.

@scara
Copy link

scara commented Jan 30, 2018

Great @mrmark!
At the end @stronk7 was right about IPv4: we need to force the binding to IPv4 since IPv6 support is broken which means -Djava.net.preferIPv4Stack=true on the Java command line and php -S 127.0.0.1:8080 to force the builtin-in server bind to IPv4 i.e. no localhost here.
You could try first w/ PHP and then if it won't work force IPv4 at Java side too.

For the record see another example using sudo: required - which is slower among the other cons -, read carefully the commit message: mrkn/ruby@ebffe78.

HTH,
Matteo

@polothy
Copy link
Contributor

polothy commented Jan 31, 2018

Thanks for the continued feedback, but doesn't appear to work unfortunately, https://travis-ci.org/moodlerooms/moodle-plugin-ci/builds/335718087

@scara
Copy link

scara commented Jan 31, 2018

Hi @mrmark,
to recap, the failure is now related to the new settings towards a "pure IPv4 net env":

Before leaving this path, what about give -Djava.net.preferIPv4Addresses=true also a try?
That could exclude any IPv6 attempt since from your logs it's pretty clear that the (first) failure happens in opening a session against Selenium
.

After more digging the web I found SeleniumHQ/selenium-google-code-issue-archive#3280 and SeleniumHQ/selenium@1ada6dd: it looks like there's no need to force IPv4 but IIUC to force the hosts preference to localhost.
Guessing that Bad Request here is coming from a mismatching between the Host HTTP header coming with the request and the info taken by the Firefox built-in web server.
If that is true, I'm not sure how to test it since we need to inject a value for the (new) pref webdriver_firefox_allowed_hosts.

HTH,
Matteo

@scara
Copy link

scara commented Feb 1, 2018

FYI yesterday I've also filed travis-ci/travis-ci#9167 which could solve our issue here if the Bad Request is actually due to the archived issue I've found.

At the moment I'm not sure if we'd need some IPv4 tuning after that fix: will see.

@polothy
Copy link
Contributor

polothy commented Feb 1, 2018

Thanks @scara for your help, I think I'll wait for the Travis issue to get some traction before I try anything else on this.

@polothy
Copy link
Contributor

polothy commented Feb 6, 2018

With travis-ci/travis-ci#9167 fixed, still doesn't work :(

Re-ran my master branch with no luck and same for the debugging one. /etc/hosts now looks like this:

::1	 ip6-localhost ip6-loopback
fe00::0	ip6-localnet
ff00::0	ip6-mcastprefix
ff02::1	ip6-allnodes
ff02::2	ip6-allrouters
172.17.0.4	travis-job-moodlerooms-moodle-plugin-335718089.travisci.net travis-job-moodlerooms-moodle-plugin-335718089
127.0.0.1 localhost localhost 

@scara
Copy link

scara commented Feb 6, 2018

Hi @mrmark,
I'm out of smart ideas than trying to revert fe9db9a#diff-0 to let Selenium be accessed via localhost and not via 127.0.0.1, since we found that this didn't helped in the attempt of forcing IPv4 and maybe this revert together with the recent change in /etc/hosts could help the resolution of the host in the Firefox built-in web server.

sarjona added a commit to sarjona/moodle-tool_policy that referenced this issue Mar 21, 2018
As explained in open-lms-open-source/moodle-plugin-ci#70,
selenium server is not running due to some issue when "sudo: false" and,
therefore, @javascript behat tests are not working.
sarjona added a commit to sarjona/moodle-tool_policy that referenced this issue Mar 21, 2018
As explained in open-lms-open-source/moodle-plugin-ci#70,
selenium server is not running due to some issue when "sudo: false" and,
therefore, @javascript behat tests are not working.
@polothy
Copy link
Contributor

polothy commented May 14, 2018

Minor update:

First, as of 2.3.0, recommending sudo: true for builds that run Behat, which I think most of you are already doing.

Second, think I sort of verified that the problem in the container build system is with /etc/hosts, in particular, this line: ::1 ip6-localhost ip6-loopback. My funky reproduction was to do this:

  1. I switched my Travis file to use sudo: true, build passes.
  2. I edited the /etc/hosts to add ::1 ip6-localhost ip6-loopback, build fails.
  3. I edited the /etc/hosts to add ::1 localhost ip6-localhost ip6-loopback, build passes.

From what I can tell, ::1 localhost was removed in travis-ci/travis-ci#8780. Unsure if we will be able to get it back.

@mudrd8mz
Copy link

Thanks @mrmark for the update. I am affected by this too (e.g. https://travis-ci.org/mudrd8mz/moodle-block_course_contents/jobs/336000695).

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

No branches or pull requests

6 participants