* [PATCH 0/1] toaster: add Selenium Docker container as browser test driver option
@ 2016-12-01 3:35 brian avery
2016-12-01 3:35 ` [PATCH 1/1] toaster: browser tests - add Selenium Docker container as driver brian avery
0 siblings, 1 reply; 3+ messages in thread
From: brian avery @ 2016-12-01 3:35 UTC (permalink / raw)
To: bitbake-devel; +Cc: brian avery
So, this patch will allow you to run the standard tests using the Selenium docker container as the
driver rather than relying on host side drivers for firefox.
This is V2. It no longer overloads the TOASTER_TESTS_BROWSER with an address and now pulls the
liveserver address from the instance.
The README in lib/toaster/tests/browser has some instructions and more are located on the wiki
at https://wiki.yoctoproject.org/wiki/TipsAndTricks/TestingToasterWithContainers.
This patch assumes the firefox container. Later, if we want to, we can add an additional
env variable to override firefox or chrome containers. Initially, I just wanted to get this
approach working so that we could use it.
-Brian
an intel employee
The following changes since commit 9e63f81c78e284c9b325fe04a1b59e61c7ad8a1a:
bitbake: ast: remove BBVERSIONS support (2016-11-30 15:48:10 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib bavery/toaster/remoteContainerTestV2
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=bavery/toaster/remoteContainerTestV2
brian avery (1):
toaster: browser tests - add Selenium Docker container as driver
lib/toaster/tests/browser/README | 21 +++++++++++++++++++--
lib/toaster/tests/browser/selenium_helpers_base.py | 13 +++++++++++--
2 files changed, 30 insertions(+), 4 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 1/1] toaster: browser tests - add Selenium Docker container as driver
2016-12-01 3:35 [PATCH 0/1] toaster: add Selenium Docker container as browser test driver option brian avery
@ 2016-12-01 3:35 ` brian avery
0 siblings, 0 replies; 3+ messages in thread
From: brian avery @ 2016-12-01 3:35 UTC (permalink / raw)
To: bitbake-devel; +Cc: brian avery
Adds the ability to specify a Selenium Docker container server as
a driver. This allows for repeatable tests independent of host.
Currently we assume you are using the Firefox container. Instructions
are located in the README in tests/browser.
Signed-off-by: brian avery <brian.avery@intel.com>
---
lib/toaster/tests/browser/README | 21 +++++++++++++++++++--
lib/toaster/tests/browser/selenium_helpers_base.py | 13 +++++++++++--
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/lib/toaster/tests/browser/README b/lib/toaster/tests/browser/README
index 6b09d20..e841a3f 100644
--- a/lib/toaster/tests/browser/README
+++ b/lib/toaster/tests/browser/README
@@ -18,7 +18,7 @@ To run tests against Chrome:
* On Windows, put chromedriver.exe in the same directory as chrome.exe
To run tests against PhantomJS (headless):
-
+--NOTE - Selenium seems to be deprecating support for this mode ---
* Download and install PhantomJS:
http://phantomjs.org/download.html
* On *nix systems, put phantomjs on PATH
@@ -43,13 +43,30 @@ Marionette driver.)
The test cases will instantiate a Selenium driver set by the
TOASTER_TESTS_BROWSER environment variable, or Chrome if this is not specified.
+To run tests against the Selenium Firefox Docker container:
+More explanation is located at https://wiki.yoctoproject.org/wiki/TipsAndTricks/TestingToasterWithContainers
+* Run the Selenium container:
+ ** docker run -it --rm=true -p 5900:5900 -p 4444:4444 --name=selenium selenium/standalone-firefox-debug:2.53.0
+ *** 5900 is the default vnc port. If you are runing a vnc server on your machine map a different port e.g. -p 6900:5900 and connect vnc client to 127.0.0.1:6900
+ *** 4444 is the default selenium sever port.
+* Run the tests
+ ** TOASTER_TESTS_BROWSER=http://127.0.0.1:4444/wd/hub TOASTER_TESTS_URL=http://172.17.0.1:8000 ./bitbake/lib/toaster/manage.py test --liveserver=172.17.0.1:8000 tests.browser
+ ** TOASTER_TESTS_BROWSER=remote TOASTER_REMOTE_HUB=http://127.0.0.1:4444/wd/hub ./bitbake/lib/toaster/manage.py test --liveserver=172.17.0.1:8000 tests.browser
+ *** TOASTER_REMOTE_HUB - This is the address for the Selenium Remote Web Driver hub. Assuming you ran the contianer with -p 4444:4444 it will be http://127.0.0.1:4444/wd/hub.
+ *** --liveserver=xxx tells Django to run the test server on an interface and port reachable by both host and container.
+ **** 172.17.0.1 is the default docker bridge on linux, viewable from inside and outside the contianers. Find it with "ip -4 addr show dev docker0"
+* connect to the vnc server to see the tests if you would like
+ ** xtightvncviewer 127.0.0.1:5900
+ ** note, you need to wait for the test container to come up before this can connect.
+
Available drivers:
* chrome (default)
* firefox
* marionette (for newer Firefoxes)
* ie
-* phantomjs
+* phantomjs (deprecated)
+* remote
e.g. to run the test suite with phantomjs where you have phantomjs installed
in /home/me/apps/phantomjs:
diff --git a/lib/toaster/tests/browser/selenium_helpers_base.py b/lib/toaster/tests/browser/selenium_helpers_base.py
index 14e9c15..156d639 100644
--- a/lib/toaster/tests/browser/selenium_helpers_base.py
+++ b/lib/toaster/tests/browser/selenium_helpers_base.py
@@ -39,7 +39,7 @@ from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.common.exceptions import NoSuchElementException, \
StaleElementReferenceException, TimeoutException
-def create_selenium_driver(browser='chrome'):
+def create_selenium_driver(cls,browser='chrome'):
# set default browser string based on env (if available)
env_browser = os.environ.get('TOASTER_TESTS_BROWSER')
if env_browser:
@@ -59,6 +59,15 @@ def create_selenium_driver(browser='chrome'):
return webdriver.Ie()
elif browser == 'phantomjs':
return webdriver.PhantomJS()
+ elif browser == 'remote':
+ # if we were to add yet another env variable like TOASTER_REMOTE_BROWSER
+ # we could let people pick firefox or chrome, left for later
+ remote_hub= os.environ.get('TOASTER_REMOTE_HUB')
+ driver = webdriver.Remote(remote_hub,
+ webdriver.DesiredCapabilities.FIREFOX.copy())
+
+ driver.get("http://%s:%s"%(cls.server_thread.host,cls.server_thread.port))
+ return driver
else:
msg = 'Selenium driver for browser %s is not available' % browser
raise RuntimeError(msg)
@@ -135,7 +144,7 @@ class SeleniumTestCaseBase(unittest.TestCase):
# instantiate the Selenium webdriver once for all the test methods
# in this test case
- cls.driver = create_selenium_driver()
+ cls.driver = create_selenium_driver(cls)
cls.driver.maximize_window()
@classmethod
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 0/1] toaster: add Selenium Docker container as browser test driver option
@ 2016-11-05 22:47 brian avery
0 siblings, 0 replies; 3+ messages in thread
From: brian avery @ 2016-11-05 22:47 UTC (permalink / raw)
To: toaster; +Cc: brian avery
Once again, some random upgrade on one of my build servers prevented me from running the selenium
browser tests. Ugh!
So, this patch will allow you to run the standard tests using the Selenium docker container as the
driver rather than relying on what seem to me to be pretty brittle drivers for firefox or chrome.
The README in lib/toaster/tests/browser has some instructions and more are located on the wiki
at https://wiki.yoctoproject.org/wiki/Running_Toaster_Tests_with_Containers
This patch assumes the firefox container. Later, if we want to, we can add an additional
env variable to override firefox or chrome containers. Initially, I just wanted to get this
approach working so that we could use it.
-Brian
an intel employee
The following changes since commit edb5b524b3ee807d55a437cbab3d768c5f6f2283:
bitbake: lib/bb/cooker.py: fix for BBFILE_PATTERN = "" (2016-11-04 12:50:56 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib bavery/toaster/remoteContainerTest
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=bavery/toaster/remoteContainerTest
brian avery (1):
toaster: browser tests - add Selenium Docker container as driver
lib/toaster/tests/browser/README | 21 +++++++++++++++++++--
lib/toaster/tests/browser/selenium_helpers_base.py | 7 +++++++
2 files changed, 26 insertions(+), 2 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-01 3:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-01 3:35 [PATCH 0/1] toaster: add Selenium Docker container as browser test driver option brian avery
2016-12-01 3:35 ` [PATCH 1/1] toaster: browser tests - add Selenium Docker container as driver brian avery
-- strict thread matches above, loose matches on Subject: below --
2016-11-05 22:47 [PATCH 0/1] toaster: add Selenium Docker container as browser test driver option brian avery
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.