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

Support version notation for selenium browsers #60

Closed
wants to merge 2 commits into from

Conversation

danpoltawski
Copy link
Contributor

With this patch, you can set MOODLE_DOCKER_BROWSER to options like the
existing options:
firefox
chrome
But also you can specify a tag/version for each, such as:
firefox:2.53.1
chrome:3.5.2

Fixes #20

With this patch, you can set MOODLE_DOCKER_BROWSER to options like the
existing options:

firefox
chrome

But also you can specify a tag/version for each, such as:

firefox:2.53.1
chrome:3.5.2

Fixes #20
@danpoltawski
Copy link
Contributor Author

This is completely untested on windows - any testers welcome!

@scara
Copy link
Contributor

scara commented Sep 19, 2017

This is completely untested on windows - any testers welcome!

I still have a win env used at the time of #34 (comment): could you provide one/two "package" to be tested or do you want all the behat tests to be run?

@danpoltawski
Copy link
Contributor Author

danpoltawski commented Sep 19, 2017

could you provide one/two "package" to be tested or do you want all the behat tests to be run?

Thanks Matteo, I'm only concerned about testing the bin/moodle-docker-compose.cmd part of it, so perhaps you could try running webserver php admin/tool/behat/cli/run.php --tags=@auth_manual with various combinations of MOODLE_DOCKER_BROWSER (i.e. with and without tag) and verify it uses the right selenium images?

@scara
Copy link
Contributor

scara commented Sep 19, 2017

Here is the result of the tests done about setting up the env (before running the test):

>systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Locale" /C:"Input Locale"
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.15063 N/A Build 15063
System Locale:             en-us;English (United States)
Input Locale:              it;Italian (Italy)
>set MOODLE_DOCKER_WWWROOT=C:\Projects\Moodle\moodle-master
>set MOODLE_DOCKER_DB=mysql
>cd C:\Projects\Moodle\moodle-docker
>git checkout selenium-versions
>copy config.docker-template.php %MOODLE_DOCKER_WWWROOT%\config.php
>bin\moodle-docker-compose.cmd pull
WARNING: The MOODLE_DOCKER_BROWSER_TAG variable is not set. Defaulting to a blank string.
Pulling selenium (selenium/standalone-firefox"":latest)...
...
Pulling webserver (moodlehq/moodle-php-apache:"7.1")...
ERROR: invalid tag format

Will comment on your PR.

REM Split MOODLE_DOCKER_BROWSER by : to get selenium tag if sepecified
FOR /f "tokens=1,2 delims=:" %%i in ("%MOODLE_DOCKER_BROWSER%") do (
SET MOODLE_DOCKER_BROWSER_NAME=%%i
SET MOODLE_DOCKER_BROWER_TAG=%%j
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: BROWER instead of BROWSER

SET MOODLE_DOCKER_BROWER_TAG=%%j
)

IF "%MOODLE_DOCKER_BROWER_NAME%"=="" (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: BROWER instead of BROWSER

SET MOODLE_DOCKER_BROWER_NAME="firefox"
)

IF "%MOODLE_DOCKER_BROWER_TAG%"=="" (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: BROWER instead of BROWSER

)

IF "%MOODLE_DOCKER_BROWER_NAME%"=="" (
SET MOODLE_DOCKER_BROWER_NAME="firefox"
Copy link
Contributor

@scara scara Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: BROWER instead of BROWSER
Error: do not use double quotes when setting a variable otherwise it will contain the quotes too


IF "%MOODLE_DOCKER_BROWER_TAG%"=="" (
IF "%MOODLE_DOCKER_BROWSER_NAME%"=="firefox" (
SET MOODLE_DOCKER_BROWER_TAG="2.53.1"
Copy link
Contributor

@scara scara Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error: do not use double quotes when setting a variable otherwise it will contain the quotes too

SET MOODLE_DOCKER_BROWER_TAG="2.53.1"
)
IF "%MOODLE_DOCKER_BROWSER_NAME%"=="chrome" (
SET MOODLE_DOCKER_BROWER_TAG="3.5.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error: do not use double quotes when setting a variable otherwise it will contain the quotes too

@scara
Copy link
Contributor

scara commented Sep 19, 2017

Too late this night, here is the first diff - we have a regression here for host (mine) and vnc port (yours) too:

$ git diff
diff --git a/bin/moodle-docker-compose.cmd b/bin/moodle-docker-compose.cmd
index d3c6e24..41171d0 100755
--- a/bin/moodle-docker-compose.cmd
+++ b/bin/moodle-docker-compose.cmd
@@ -22,7 +22,7 @@ SET DOCKERCOMPOSE=docker-compose -f "%BASEDIR%\base.yml"
 SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\service.mail.yml"

 IF "%MOODLE_DOCKER_PHP_VERSION%"=="" (
-    SET MOODLE_DOCKER_PHP_VERSION="7.1"
+    SET MOODLE_DOCKER_PHP_VERSION=7.1
 )

 IF NOT "%MOODLE_DOCKER_DB%"=="pgsql" (
@@ -38,19 +38,19 @@ IF NOT "%MOODLE_DOCKER_BROWSER%"=="" (
     REM Split MOODLE_DOCKER_BROWSER by : to get selenium tag if sepecified
     FOR /f "tokens=1,2 delims=:" %%i in ("%MOODLE_DOCKER_BROWSER%") do (
         SET MOODLE_DOCKER_BROWSER_NAME=%%i
-        SET MOODLE_DOCKER_BROWER_TAG=%%j
+        SET MOODLE_DOCKER_BROWSER_TAG=%%j
     )

-    IF "%MOODLE_DOCKER_BROWER_NAME%"=="" (
-        SET MOODLE_DOCKER_BROWER_NAME="firefox"
+    IF "%MOODLE_DOCKER_BROWSER_NAME%"=="" (
+        SET MOODLE_DOCKER_BROWSER_NAME=firefox
     )

-    IF "%MOODLE_DOCKER_BROWER_TAG%"=="" (
+    IF "%MOODLE_DOCKER_BROWSER_TAG%"=="" (
         IF "%MOODLE_DOCKER_BROWSER_NAME%"=="firefox" (
-            SET MOODLE_DOCKER_BROWER_TAG="2.53.1"
+            SET MOODLE_DOCKER_BROWSER_TAG=2.53.1
         )
         IF "%MOODLE_DOCKER_BROWSER_NAME%"=="chrome" (
-            SET MOODLE_DOCKER_BROWER_TAG="3.5.2"
+            SET MOODLE_DOCKER_BROWSER_TAG=3.5.2
         )
     )

@@ -64,7 +64,7 @@ IF NOT "%MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES%"=="" (
 )

 IF "%MOODLE_DOCKER_WEB_HOST%"=="" (
-    SET MOODLE_DOCKER_WEB_HOST="localhost"
+    SET MOODLE_DOCKER_WEB_HOST=localhost
 )

 IF "%MOODLE_DOCKER_WEB_PORT%"=="" (
@@ -76,9 +76,9 @@ IF NOT "%MOODLE_DOCKER_WEB_PORT%"=="0" (
 )

 IF "%MOODLE_DOCKER_SELENIUM_VNC_PORT%"=="" (
-    SET MOODLE_DOCKER_SELENIUM_SUFFIX=""
+    SET MOODLE_DOCKER_SELENIUM_SUFFIX=
 ) ELSE (
-    SET MOODLE_DOCKER_SELENIUM_SUFFIX="-debug"
+    SET MOODLE_DOCKER_SELENIUM_SUFFIX=-debug
     SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\selenium.debug.yml"
 )

Stopped w/ the difference between pull and up -d:

C:\Projects\Moodle\moodle-docker>bin\moodle-docker-compose.cmd pull
WARNING: The MOODLE_DOCKER_SELENIUM_SUFFIX variable is not set. Defaulting to a blank string.
WARNING: The MOODLE_DOCKER_BROWSER_TAG variable is not set. Defaulting to a blank string.
Pulling selenium (selenium/standalone-firefox:latest)...
latest: Pulling from selenium/standalone-firefox
Digest: sha256:298bfcd1697ca847421be3f555b57755e91355533e4270f0894d35382e32d5ed
Status: Image is up to date for selenium/standalone-firefox:latest
Pulling db (mysql:5)...
5: Pulling from library/mysql
Digest: sha256:0dc3dacb751ef46a6647234abdec2d47400f0dfbe77ab490b02bffdae57846ed
Status: Image is up to date for mysql:5
Pulling mailhog (mailhog/mailhog:latest)...
latest: Pulling from mailhog/mailhog
Digest: sha256:5be1ae7cf894b58fffbe48f84a0541a3595e53124d460d3fb71b3450a8d11189
Status: Image is up to date for mailhog/mailhog:latest
Pulling webserver (moodlehq/moodle-php-apache:7.1)...
7.1: Pulling from moodlehq/moodle-php-apache
Digest: sha256:0d36d54534274de9e3303da1384dd9196d28bc2aa3a1094825c683c0053b169a
Status: Image is up to date for moodlehq/moodle-php-apache:7.1

C:\Projects\Moodle\moodle-docker>bin\moodle-docker-compose.cmd up -d
WARNING: The MOODLE_DOCKER_SELENIUM_SUFFIX variable is not set. Defaulting to a blank string.
WARNING: The MOODLE_DOCKER_BROWSER_TAG variable is not set. Defaulting to a blank string.
ERROR: no such image: selenium/standalone-firefox:: invalid reference format

My proposal - to be tested - is:

diff --git a/bin/moodle-docker-compose.cmd b/bin/moodle-docker-compose.cmd
index d3c6e24..bca1da8 100755
--- a/bin/moodle-docker-compose.cmd
+++ b/bin/moodle-docker-compose.cmd
@@ -22,7 +22,7 @@ SET DOCKERCOMPOSE=docker-compose -f "%BASEDIR%\base.yml"
 SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\service.mail.yml"

 IF "%MOODLE_DOCKER_PHP_VERSION%"=="" (
-    SET MOODLE_DOCKER_PHP_VERSION="7.1"
+    SET MOODLE_DOCKER_PHP_VERSION=7.1
 )

 IF NOT "%MOODLE_DOCKER_DB%"=="pgsql" (
@@ -38,25 +38,25 @@ IF NOT "%MOODLE_DOCKER_BROWSER%"=="" (
     REM Split MOODLE_DOCKER_BROWSER by : to get selenium tag if sepecified
     FOR /f "tokens=1,2 delims=:" %%i in ("%MOODLE_DOCKER_BROWSER%") do (
         SET MOODLE_DOCKER_BROWSER_NAME=%%i
-        SET MOODLE_DOCKER_BROWER_TAG=%%j
+        SET MOODLE_DOCKER_BROWSER_TAG=%%j
     )
+)

-    IF "%MOODLE_DOCKER_BROWER_NAME%"=="" (
-        SET MOODLE_DOCKER_BROWER_NAME="firefox"
-    )
+IF "%MOODLE_DOCKER_BROWSER_NAME%"=="" (
+       SET MOODLE_DOCKER_BROWSER_NAME=firefox
+)

-    IF "%MOODLE_DOCKER_BROWER_TAG%"=="" (
-        IF "%MOODLE_DOCKER_BROWSER_NAME%"=="firefox" (
-            SET MOODLE_DOCKER_BROWER_TAG="2.53.1"
-        )
-        IF "%MOODLE_DOCKER_BROWSER_NAME%"=="chrome" (
-            SET MOODLE_DOCKER_BROWER_TAG="3.5.2"
-        )
-    )
+IF "%MOODLE_DOCKER_BROWSER_TAG%"=="" (
+       IF "%MOODLE_DOCKER_BROWSER_NAME%"=="firefox" (
+               SET MOODLE_DOCKER_BROWSER_TAG=2.53.1
+       )
+       IF "%MOODLE_DOCKER_BROWSER_NAME%"=="chrome" (
+               SET MOODLE_DOCKER_BROWSER_TAG=3.5.2
+       )
+)

-    IF NOT "%MOODLE_DOCKER_BROWSER_NAME%"=="firefox" (
-        SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\selenium.%MOODLE_DOCKER_BROWSER_NAME%.yml"
-    )
+IF NOT "%MOODLE_DOCKER_BROWSER_NAME%"=="firefox" (
+       SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\selenium.%MOODLE_DOCKER_BROWSER_NAME%.yml"
 )

 IF NOT "%MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES%"=="" (
@@ -64,7 +64,7 @@ IF NOT "%MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES%"=="" (
 )

 IF "%MOODLE_DOCKER_WEB_HOST%"=="" (
-    SET MOODLE_DOCKER_WEB_HOST="localhost"
+    SET MOODLE_DOCKER_WEB_HOST=localhost
 )

 IF "%MOODLE_DOCKER_WEB_PORT%"=="" (
@@ -76,10 +76,12 @@ IF NOT "%MOODLE_DOCKER_WEB_PORT%"=="0" (
 )

 IF "%MOODLE_DOCKER_SELENIUM_VNC_PORT%"=="" (
-    SET MOODLE_DOCKER_SELENIUM_SUFFIX=""
+    SET MOODLE_DOCKER_SELENIUM_SUFFIX=
 ) ELSE (
-    SET MOODLE_DOCKER_SELENIUM_SUFFIX="-debug"
+    SET MOODLE_DOCKER_SELENIUM_SUFFIX=-debug
     SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\selenium.debug.yml"
 )

+echo %MOODLE_DOCKER_SELENIUM_SUFFIX% %MOODLE_DOCKER_BROWSER_TAG%
+
 %DOCKERCOMPOSE% %*

@danpoltawski
Copy link
Contributor Author

I have put your fixes onto a commit on this branch

@scara
Copy link
Contributor

scara commented Sep 20, 2017

OK, will do a second session tonight on top of e4db7bf.

Not sure if the fix about localhost and VNC should be separated commits but let the branch be ready for windows too, first 😉.

@danpoltawski
Copy link
Contributor Author

danpoltawski commented Sep 20, 2017

Thanks (my problem is that my vms do not have VT support so can't run docker in them). I might see if i can work something out meanwhile

@scara
Copy link
Contributor

scara commented Sep 20, 2017

Oops... a debug echo 😊

echo %MOODLE_DOCKER_SELENIUM_SUFFIX% %MOODLE_DOCKER_BROWSER_TAG%

Will test and give you diffs, tonight.

@danpoltawski
Copy link
Contributor Author

I've finally got a windows install for this.. I came across problems with the old version setting variables which affect future runs. Perhaps we should avoid re-using variables which we expect users to set (in both windows and mac)

@scara
Copy link
Contributor

scara commented Sep 20, 2017

I've successfully run these combinations in the same DOS prompt:

>bin\moodle-docker-compose.cmd pull
>bin\moodle-docker-compose.cmd up -d
>docker ps --format "table {{.Names}}\t{{.Image}}"
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/init.php
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/run.php --tags=@auth_manual
>bin\moodle-docker-compose.cmd down

>set MOODLE_DOCKER_BROWSER=firefox
>bin\moodle-docker-compose.cmd pull
>bin\moodle-docker-compose.cmd up -d
>docker ps --format "table {{.Names}}\t{{.Image}}"
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/init.php
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/run.php --tags=@auth_manual
>bin\moodle-docker-compose.cmd down

>set MOODLE_DOCKER_BROWSER=chrome
>bin\moodle-docker-compose.cmd pull
>bin\moodle-docker-compose.cmd up -d
>docker ps --format "table {{.Names}}\t{{.Image}}"
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/init.php
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/run.php --tags=@auth_manual
>bin\moodle-docker-compose.cmd down

>set MOODLE_DOCKER_BROWSER=firefox:2.53.0
>bin\moodle-docker-compose.cmd pull
>bin\moodle-docker-compose.cmd up -d
>docker ps --format "table {{.Names}}\t{{.Image}}"
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/init.php
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/run.php --tags=@auth_manual
>bin\moodle-docker-compose.cmd down

>set MOODLE_DOCKER_BROWSER=chrome:3.5.1
>bin\moodle-docker-compose.cmd pull
>bin\moodle-docker-compose.cmd up -d
>docker ps --format "table {{.Names}}\t{{.Image}}"
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/init.php
>bin\moodle-docker-compose.cmd exec -T webserver php admin/tool/behat/cli/run.php --tags=@auth_manual
>bin\moodle-docker-compose.cmd down

given that we should remove:

echo %MOODLE_DOCKER_SELENIUM_SUFFIX% %MOODLE_DOCKER_BROWSER_TAG%

Cleaning up the way variables are used could be a separate issue, isn't it?

HTH,
Matteo

@stronk7
Copy link
Member

stronk7 commented Sep 20, 2017

Sorry for arriving late here, just saw #20 some minutes ago...

My 2 cents are just to say that I find MOODLE_DOCKER_BROWSER a bit strange name for something allowing me to control the SELENIUM version, not the BROWSER version.

I mean I'd expect the expansion proposed controls the browser version, not the selenium one. So this is a call to 1) consider if a better name can be used and/or 2) make it 100% clear that it's the selenium version (with whichever browser versions it comes with).

Just that, other than that I understand and like the idea/feature 100%. Thanks!

@NeillM
Copy link
Contributor

NeillM commented Sep 21, 2017

I tried running the selenium branch last night on Windows 10, with Docker for Windows, using cmd and it failed to compile the containers. I got a message saying it could not find the moodlehq/moodle-php-apache:"7.1" image

It works fine on Windows 7 using Docker Toolbox though. I guess the difference here is that Docker will be running on a Linux virtual machine.

I will try on Win10 again hopefully tonight, but I'm fairly certain Matteo's latest changes were included at the time.

@scara
Copy link
Contributor

scara commented Sep 21, 2017

Hi @NeillM,
give the current selenium-versions a try: when it will be merged, it will fix "your" double quotes issue too

SET MOODLE_DOCKER_PHP_VERSION=7.1

HTH,
Matteo

@scara
Copy link
Contributor

scara commented Sep 22, 2017

Hi @danpoltawski,
what do you think about merging this branch eventually w/ the changed name as requested by @stronk7 and creating a new issue to cleanup the variable names usage?

TIA,
Matteo

@danpoltawski
Copy link
Contributor Author

I have to say i'm not keen on calling it SELENIUM, mostly because we are using this mostly to control the actual browser type - I think the version is niche use. I'd perfer it makes more sense when people are using the non-version part of it i.e. MOODLE_DOCKER_BROWSER=firefox

My intention here is to avoid introducing another variable.. we've already got 8 and I see this quickly getting out of hand..

@danpoltawski
Copy link
Contributor Author

It's clear we need to sort out this windows problem sooner rather than later though. Might be worth splitting the windows fixes in a seperate pull request?

@scara
Copy link
Contributor

scara commented Sep 22, 2017

Might be worth splitting the windows fixes in a seperate pull request?

👍

scara added a commit to scara/moodle-docker that referenced this pull request Oct 1, 2017
Without this fix the compose stops with an error:
>set MOODLE_DOCKER_WWWROOT=C:\Projects\Moodle\moodle-master
>set MOODLE_DOCKER_DB=mysql
>cd C:\Projects\Moodle\moodle-docker
>copy config.docker-template.php %MOODLE_DOCKER_WWWROOT%\config.php
>bin\moodle-docker-compose.cmd up -d
ERROR: no such image: selenium/standalone-firefox"":2.53.1: invalid reference format

Already found while working at moodlehq#20 in refining moodlehq#60.
@stronk7
Copy link
Member

stronk7 commented Sep 12, 2019

As far as this will be 2y old in just one week... maybe we should try to get it done, accepting the browser:selenium format... i really don't remember that as a stopper, just a opinion (or at least that's how I see it now, 2 years later) :-)

@stronk7
Copy link
Member

stronk7 commented Jan 12, 2022

Closed by #195, just merged.

@stronk7 stronk7 closed this Jan 12, 2022
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

Successfully merging this pull request may close these issues.

Consider controlling selenium combinations per branch, or override...
4 participants