Commit 309ec0ac by Jeremy Bowman

PLAT-1619 karma and bok-choy Docker Devstack fixes

parent 0c72a62a
......@@ -41,6 +41,8 @@
var path = require('path');
var _ = require('underscore');
var appRoot = path.join(__dirname, '../../../../');
var webdriver = require('selenium-webdriver');
var firefox = require('selenium-webdriver/firefox');
var webpackConfig = require(path.join(appRoot, 'webpack.config.js'));
delete webpackConfig.entry;
......@@ -269,8 +271,15 @@ function getBaseConfig(config, useRequireJs) {
};
var hostname = 'localhost';
var port = 9876;
if (process.env.hasOwnProperty('BOK_CHOY_HOSTNAME')) {
hostname = process.env.BOK_CHOY_HOSTNAME;
if (hostname === 'edx.devstack.lms') {
port = 19876;
}
else {
port = 19877;
}
}
initFrameworks.$inject = ['config.files'];
......@@ -296,7 +305,7 @@ function getBaseConfig(config, useRequireJs) {
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-spec-reporter',
'karma-webdriver-launcher',
'karma-selenium-webdriver-launcher',
'karma-webpack',
'karma-sourcemap-loader',
customPlugin
......@@ -324,7 +333,7 @@ function getBaseConfig(config, useRequireJs) {
// web server hostname and port
hostname: hostname,
port: 9876,
port: port,
// enable / disable colors in the output (reporters and logs)
......@@ -354,12 +363,29 @@ function getBaseConfig(config, useRequireJs) {
'app.update.enabled': false
}
},
ChromeDocker: {
base: 'SeleniumWebdriver',
browserName: 'chrome',
getDriver: function () {
return new webdriver.Builder()
.forBrowser('chrome')
.usingServer('http://edx.devstack.chrome:4444/wd/hub')
.build();
}
},
FirefoxDocker: {
base: 'WebDriver',
base: 'SeleniumWebdriver',
browserName: 'firefox',
config: {
hostname: 'edx.devstack.firefox',
port: 4444
getDriver: function () {
var options = new firefox.Options(),
profile = new firefox.Profile();
profile.setPreference('focusmanager.testmode', true);
options.setProfile(profile);
return new webdriver.Builder()
.forBrowser('firefox')
.usingServer('http://edx.devstack.firefox:4444/wd/hub')
.setFirefoxOptions(options)
.build();
}
}
},
......
......@@ -462,7 +462,8 @@ class EventsTestMixin(TestCase):
"""
def setUp(self):
super(EventsTestMixin, self).setUp()
self.event_collection = MongoClient()["test"]["events"]
mongo_host = 'edx.devstack.mongo' if 'BOK_CHOY_HOSTNAME' in os.environ else 'localhost'
self.event_collection = MongoClient(mongo_host)["test"]["events"]
self.start_time = datetime.now()
def reset_event_tracking(self):
......@@ -735,8 +736,9 @@ class AcceptanceTest(WebAppTest):
"""
def __init__(self, *args, **kwargs):
# Hack until we upgrade Firefox and install geckodriver in devstack and Jenkins
DesiredCapabilities.FIREFOX['marionette'] = False
if 'BOK_CHOY_HOSTNAME' not in os.environ:
# Hack until we upgrade Firefox and install geckodriver in Vagrant and Jenkins
DesiredCapabilities.FIREFOX['marionette'] = False
super(AcceptanceTest, self).__init__(*args, **kwargs)
# Use long messages so that failures show actual and expected values
......
......@@ -47,11 +47,12 @@
"karma-requirejs": "^0.2.6",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.20",
"karma-webdriver-launcher": "^1.0.5",
"karma-selenium-webdriver-launcher": "^0.0.4",
"karma-webpack": "^2.0.3",
"pa11y": "4.0.1",
"pa11y-reporter-json-oldnode": "1.0.0",
"plato": "1.2.2",
"selenium-webdriver": "3.4.0",
"sinon": "2.3.5",
"squirejs": "^0.1.0"
}
......
......@@ -33,8 +33,8 @@ def repo_root():
absolute_path = file_path.abspath()
break
except OSError:
print('Attempt {}/60 to get an absolute path failed'.format(attempt))
if attempt <= 60:
print('Attempt {}/180 to get an absolute path failed'.format(attempt))
if attempt < 180:
attempt += 1
sleep(1)
else:
......@@ -169,7 +169,11 @@ class Env(object):
TEST_DIR = REPO_ROOT / ".testids"
# Configured browser to use for the js test suites
KARMA_BROWSER = 'FirefoxDocker' if USING_DOCKER else 'FirefoxNoUpdates'
SELENIUM_BROWSER = os.environ.get('SELENIUM_BROWSER', 'firefox')
if USING_DOCKER:
KARMA_BROWSER = 'ChromeDocker' if SELENIUM_BROWSER == 'chrome' else 'FirefoxDocker'
else:
KARMA_BROWSER = 'FirefoxNoUpdates'
# Files used to run each of the js test suites
# TODO: Store this as a dict. Order seems to matter for some
......
......@@ -83,9 +83,9 @@ def check_firefox_version():
# Firefox is running in a separate Docker container; get its version via Selenium
driver = browser()
capabilities = driver.capabilities
if capabilities['browserName'] == 'firefox':
if capabilities['browserName'].lower() == 'firefox':
firefox_version_regex = re.compile(r'^\d+\.\d+')
version_key = 'browserVersion' if 'browserVersion' in 'capabilities' else 'version'
version_key = 'browserVersion' if 'browserVersion' in capabilities else 'version'
try:
firefox_ver = float(firefox_version_regex.search(capabilities[version_key]).group(0))
except AttributeError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment