behat install problem

behat install problem

by Xavier Brosseau -
Number of replies: 10

hello, i am running Moodle on a centos 7 server but i have problem with using behat for testing moodle.

First of all, i do not know how i can set a different behat_wwwroot then wwwroot. this is what my config.php look like  :

///////////////BEHAT CFG CONFIG///////////

$CFG->behat_dataroot = '/var/www/dataroot_Behat';

$CFG->behat_prefix   = 'behat_';

$CFG->behat_wwwroot   = "http://localhost:8000/ena-295";

////////////////////////////////////////////////////////////////////////////////

$CFG->wwwroot   = 'http://12.145.178.81/ena-295';

$CFG->dataroot  = '/var/www/enatestdata';

$CFG->admin     = 'admin';

//MathJax Local

$CFG->forced_plugin_settings = array('filter_mathjaxloader' =>

    array('httpurl' => 'http://localhost/MathJax/MathJax.js',

          'httpsurl' => 'https://localhost/MathJax/MathJax.js'),

);

$CFG->behat_extraallowedsettings = array('forced_plugin_settings');

////////////////////

$CFG->directorypermissions = 0777;


require_once(dirname(__FILE__) . '/lib/setup.php');


////////////////////////////////////////////////////////////////////////////////

I think i've tried many things but I keep getting this error - > "Behat requirement not satisfied: http://localhost:8000/ena-295 is not available, ensure you specified correct url and that the server is set up and started. More info in http://docs.moodle.org/dev/Acceptance_testing#Running_tests"

For information, i use a docker for selenium.

Sorry for my bad english and thank you for your futur help smile


Average of ratings: -
In reply to Xavier Brosseau

Re: behat install problem

by David Ligne -

Hi Xavier,

Can you try using 'http://127.0.0.1/ena-295' instead of 'http://localhost:8000/ena-295'?

In reply to David Ligne

Re: behat install problem

by Xavier Brosseau -

Yes i've tried those one:

'http://127.0.0.1/ena-295'

'http://127.0.0.1:8000/ena-295'

'http://localhost/ena-295'

"http://localhost:8000/ena-295"

and other....


This morning i finally made it to start by putting my IP adresse/ena-295 in the behat_wwwroot and putting a random IP(not used)/ena-295 in the wwwroot..

At this date the test is still running but im not sure this was the right wy to do it.

In reply to Xavier Brosseau

Re: behat install problem

by Rajesh Taneja -

Hello  Xavier,


If you get such error than first thing you should try is accessing the behat_wwwroot url using your browser and check if you are able to access the acceptance test site. 

It seems your server is configured to only access site via 'http://12.145.178.81/ena-295'


Can you please do following:

  1. Open browser on the machine you are running tests
  2. Try access http://localhost:8000/ena-295 and check if it shows proper site.
  3. If not then either check if you webserver is causing the problem or host settings are different.


Acceptance site can have any behat_wwwroot, provided you can access your website via that url.

Hope this helps.


In reply to Rajesh Taneja

Re: behat install problem

by Xavier Brosseau -

i connot check if i have acces to it because my server where moodle is installed does not have a GUI so i can't check localhost on a browser from there.

I get to have access the acceptance test site when i set the behat_wwwroot to my normal IP and put a random ip in the normal wwroot.



In reply to Xavier Brosseau

Re: behat install problem

by Rajesh Taneja -

Can you please provide more information about how you are running acceptance tests. Are you running selenium on webserver or on your local machine ?



In reply to Rajesh Taneja

Re: behat install problem

by Xavier Brosseau -

Sure! I run selenium from the Docker that is shown in this moodle Doc https://docs.moodle.org/dev/Acceptance_testing#Using_Docker_to_start_selenium_server

So it is on a webserver, not on my local machine.. that might be the problem ?

In reply to Xavier Brosseau

Re: behat install problem

by Rajesh Taneja -

Aha, docker. 


As localhost within docker means different than on the host, it will only work if you pass ip so when selenium open browser within docker it should be able to access moodle site.

Also, above will fail for scenarios with @_file_upload tag as the file doesn't exist within docker. To make @_file_upload pass you need to share moodle path within your selenium docker at same location.


FYIhttps://github.com/rajeshtaneja/docker/ might help you running your tests using docker.

Average of ratings: Useful (1)
In reply to Rajesh Taneja

Re: behat install problem

by Xavier Brosseau -

At this point you've been really helpfull an i thank you for that.

Now if you could help me about giving acces of my moodle to the docker that be very great !

Is there some sort of configuration somewhere ?

The docker i use is the one in the acceptance testing tutorial from moodle:

https://docs.moodle.org/dev/Acceptance_testing#Selenium_docker_images

"docker run -d -p 4444:4444 selenium/standalone-firefox:2.53.1-beryllium"


Thank you again smile

In reply to Xavier Brosseau

Re: behat install problem

by Rajesh Taneja -

My docker instance is rajeshtaneja/selenium:2.53.1 to execute this:

  • Set $CFG->behat_wwwroot = 'http://{IP_ADDRESS}/im';
  • docker run -ti -p 4444:4444 -v {ABSOULET_PATH_OF_MOODLE_INSTANCE}/:{ABSOULET_PATH_OF_MOODLE_INSTANCE} rajeshtaneja/selenium:2.53.1
  • Now initialize behat
  • Run behat . Test this with --tags=@_file_upload first.

NOTE:

  1. Selenium docker -v should have absolute path, as link will not work.
  2. host path should terminate with /, else mapping will not be correct.