moodlehq / bigbluebutton_mock

0 stars 11 forks source link

Document a little bit how to use the Docker image from Moodle #13

Open stronk7 opened 3 years ago

stronk7 commented 3 years ago

When looking to some problems @ MDL-70658 related to this image... it was not straightforward to know what is needed to get it working in a local environment.

So I had to look to both this and moodle-ci-runner (that already supports it) to see how to configure my local testing environment.

It would be great to get that minimally documented, maybe in the README.

For the records, this is what I did here to get the image working with both phpunit and behat. Tricky that we use that dynamic hash (not sure why), but it works. Added to config.php:

// Also keep the BBB docker mock server at hand if we are running tests.
// docker run -d -p 8080:80 moodlehq/bigbluebutton_mock:latest
$mockhash = sha1($CFG->wwwroot);
if (defined('BEHAT_TESTS') || defined('BEHAT_SITE_RUNNING')) {
    $mockhash = sha1($CFG->behat_wwwroot);
}
define("TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER", 'http://127.0.0.1:8080/hash' . $mockhash);
stronk7 commented 3 years ago

It seems that it's really hard to get the image working for local environments where the web server is not dockerized but running in the host and without any dns, but generic 127.0.0.1 or localhost. All sort of things have been tried (network=host, only for linux, host.docker.internal for mac/win, hacking the tests to connect there, also --add-host=hostdns:hostip...).

So surely, the best (easiest, quickest and working) solution for local testing is to just run the symfony app locally and done. Updated mine, this is how my config.php looks now:

// Also keep the BBB docker mock server at hand if we are running tests.
// docker run -d -p 8001:80 moodlehq/bigbluebutton_mock:latest
// !!! Cannot use the container locally because it's not able to callback to the host, so using server instead:
//   cd /Users/stronk7/git_moodle/bigbluebutton_mock/application
//   symfony server:start --port=8001 --no-tls --allow-http
//   If it's not started, follow the instructions @ https://github.com/moodlehq/bigbluebutton_mock
$mockhash = sha1($CFG->wwwroot);
if (defined('BEHAT_TESTS') || defined('BEHAT_SITE_RUNNING')) {
    $mockhash = sha1($CFG->behat_wwwroot);
}
define("TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER", 'http://127.0.0.1:8001/hash' . $mockhash);
paulholden commented 2 years ago

Just saw this issue, semi-related but I always wanted to document how to use the mock server in conjunction with moodle-docker so created https://github.com/moodlehq/bigbluebutton_mock/pull/29