Install Horizon from git repository in tox test

To test UI plugins, we should install recent Horizon
from master branch.

Also, fixed eslint and karma.

To run tox test easily before upload patchset,
adds eslint, karma, docs and releasenotes to envlist.

Change-Id: I82806631e7219eaa2372c2cd62b264056fbea64d
This commit is contained in:
Shu Muto 2018-04-13 10:17:07 +09:00
parent e31027a0b5
commit 7887b3f41a
4 changed files with 107 additions and 46 deletions

View File

@ -19,7 +19,9 @@ var path = require('path');
module.exports = function (config) { module.exports = function (config) {
// This tox venv is setup in the post-install npm step // This tox venv is setup in the post-install npm step
var toxPath = '../.tox/py27/lib/python2.7/site-packages/'; var toxPath = '../.tox/karma/lib/python2.7/site-packages/';
process.env.PHANTOMJS_BIN = 'node_modules/phantomjs-prebuilt/bin/phantomjs';
config.set({ config.set({
preprocessors: { preprocessors: {
@ -69,7 +71,7 @@ module.exports = function (config) {
// TODO: These should be mocked. // TODO: These should be mocked.
toxPath + '/horizon/static/horizon/js/horizon.js', toxPath + 'horizon/static/horizon/js/horizon.js',
/** /**
* Include framework source code from horizon that we need. * Include framework source code from horizon that we need.
@ -120,7 +122,8 @@ module.exports = function (config) {
frameworks: ['jasmine'], frameworks: ['jasmine'],
browsers: ['Chrome'], // browsers: ['Chrome'],
browsers: ['PhantomJS'],
browserNoActivityTimeout: 60000, browserNoActivityTimeout: 60000,
@ -128,6 +131,7 @@ module.exports = function (config) {
plugins: [ plugins: [
'karma-chrome-launcher', 'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-jasmine', 'karma-jasmine',
'karma-ng-html2js-preprocessor', 'karma-ng-html2js-preprocessor',
'karma-coverage', 'karma-coverage',

View File

@ -10,21 +10,23 @@
"license": "Apache 2.0", "license": "Apache 2.0",
"author": "Openstack <openstack-dev@lists.openstack.org>", "author": "Openstack <openstack-dev@lists.openstack.org>",
"devDependencies": { "devDependencies": {
"eslint": "^1.10.3", "eslint": "3.19.x",
"eslint-config-openstack": "^1.2.4", "eslint-config-openstack": "^4.0.1",
"eslint-plugin-angular": "1.0.1", "eslint-plugin-angular": "3.1.x",
"jasmine-core": "2.4.1", "jasmine-core": "2.8.x",
"karma": "1.1.2", "karma": "1.7.x",
"karma-chrome-launcher": "1.0.1", "karma-chrome-launcher": "^2.2.0",
"karma-cli": "1.0.1", "karma-cli": "1.0.x",
"karma-coverage": "1.1.1", "karma-coverage": "1.1.x",
"karma-jasmine": "1.0.2", "karma-jasmine": "1.1.x",
"karma-ng-html2js-preprocessor": "1.0.0", "karma-ng-html2js-preprocessor": "1.0.x",
"karma-threshold-reporter": "0.1.15" "karma-phantomjs-launcher": "1.0.x",
"karma-threshold-reporter": "0.1.x",
"phantomjs-prebuilt": "2.1.x"
}, },
"dependencies": {}, "dependencies": {},
"scripts": { "scripts": {
"postinstall": "if [ ! -d .tox ] || [ ! -d .tox/py27 ]; then tox -epy27 --notest; fi", "postinstall": "if [ ! -d .tox ] || [ ! -d .tox/karma ]; then tox -ekarma --notest; git clone https://git.openstack.org/openstack/horizon.git .tox/karma/src/horizon; pip install -U -t .tox/karma/lib/python2.7/site-packages/ .tox/karma/src/horizon; fi",
"lint": "eslint --no-color magnum_ui/static", "lint": "eslint --no-color magnum_ui/static",
"lintq": "eslint --quiet magnum_ui/static", "lintq": "eslint --quiet magnum_ui/static",
"test": "karma start magnum_ui/karma.conf.js --single-run" "test": "karma start magnum_ui/karma.conf.js --single-run"

20
tools/tox_helper.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
ENVNAME=$1
BASEPYTHON=$2
COMMAND=$3
if [ ${COMMAND} = "pre" ]; then
# crean-up
rm -fr .tox/${ENVNAME}-log/
# install horizon from git
rm -fr .tox/${ENVNAME}/src/
git clone https://git.openstack.org/openstack/horizon.git .tox/${ENVNAME}/src/horizon
pip install -U -t .tox/${ENVNAME}/lib/${BASEPYTHON}/site-packages/ .tox/${ENVNAME}/src/horizon
elif [ ${COMMAND} = "post" ]; then
# crean-up
rm -fr .tox/${ENVNAME}/src/
mv .tox/${ENVNAME}/log/ .tox/${ENVNAME}-log/
rm -fr .tox/${ENVNAME}/
fi

95
tox.ini
View File

@ -1,5 +1,5 @@
[tox] [tox]
envlist = pep8,py35,py27,py35dj20 envlist = pep8,py35,py35dj20,py27,eslint,karma,docs,releasenotes
minversion = 2.3.2 minversion = 2.3.2
skipsdist = True skipsdist = True
@ -11,16 +11,21 @@ setenv = VIRTUAL_ENV={envdir}
NOSE_OPENSTACK_RED=0.05 NOSE_OPENSTACK_RED=0.05
NOSE_OPENSTACK_YELLOW=0.025 NOSE_OPENSTACK_YELLOW=0.025
NOSE_OPENSTACK_SHOW_ELAPSED=1 NOSE_OPENSTACK_SHOW_ELAPSED=1
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -U {opts} {packages} deps =
deps = -r{toxinidir}/requirements.txt -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = python manage.py test {posargs} --settings=magnum_ui.test.settings commands = python manage.py test {posargs} --settings=magnum_ui.test.settings
[testenv:venv]
commands = {posargs}
[testenv:pep8] [testenv:pep8]
commands = flake8 {posargs} commands = flake8 {posargs}
[testenv:venv] [flake8]
commands = {posargs} exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules
max-complexity = 20
[testenv:cover] [testenv:cover]
commands = commands =
@ -29,47 +34,77 @@ commands =
coverage xml --omit '.tox/cover/*' -o 'cover/coverage.xml' coverage xml --omit '.tox/cover/*' -o 'cover/coverage.xml'
coverage html --omit '.tox/cover/*' -d 'cover/htmlcov' coverage html --omit '.tox/cover/*' -d 'cover/htmlcov'
[testenv:py27]
commands =
# Clean-up env and install horizon from git
{toxinidir}/tools/tox_helper.sh {envname} {basepython} pre
# Run test
python manage.py test {posargs}
# Clean-up env except log
{toxinidir}/tools/tox_helper.sh {envname} {basepython} post
[testenv:py35]
basepython = python3.5
commands =
# Clean-up env and install horizon from git
{toxinidir}/tools/tox_helper.sh {envname} {basepython} pre
# Run test
python manage.py test {posargs}
# Clean-up env except log
{toxinidir}/tools/tox_helper.sh {envname} {basepython} post
[testenv:py35dj20] [testenv:py35dj20]
basepython = python3.5 basepython = python3.5
whitelist_externals = git
commands = commands =
# NOTE(shu-mutow): To test this new env, need to re-install recent horizon # Clean-up env and install horizon from git
# from git master branch like CI infra does. {toxinidir}/tools/tox_helper.sh {envname} {basepython} pre
git clone https://git.openstack.org/openstack/horizon.git .tox/py35dj20/src/horizon # Run test
pip install -U -t .tox/py35dj20/lib/python3.5/site-packages/ .tox/py35dj20/src/horizon
pip install django>=2.0,<2.1 pip install django>=2.0,<2.1
python manage.py test {posargs} --settings=magnum_ui.test.settings python manage.py test {posargs}
# Clean-up env except log
{toxinidir}/tools/tox_helper.sh {envname} {basepython} post
[testenv:eslint] [testenv:eslint]
whitelist_externals = npm whitelist_externals =
npm
commands = commands =
# Clean-up env and install horizon from git
{toxinidir}/tools/tox_helper.sh {envname} {basepython} pre
# Run test
npm install npm install
npm run postinstall
npm run lint npm run lint
# Clean-up env except log
{toxinidir}/tools/tox_helper.sh {envname} {basepython} post
[testenv:karma] [testenv:karma]
# NOTE(shu-mutou): Until PhantomJS setup get reliable, we use whitelist_externals =
# Chromium for JS test. And npm can't launch Chromium via tox. npm
#whitelist_externals = npm
#commands =
# npm install
# npm run postinstall
# npm run test
whitelist_externals = echo
commands = commands =
echo "npm can't launch Chromium via tox." # Clean-up env and install horizon from git
echo "execute `npm run test`" {toxinidir}/tools/tox_helper.sh {envname} {basepython} pre
# Run test
npm install
npm run test
# Clean-up env except log
{toxinidir}/tools/tox_helper.sh {envname} {basepython} post
[testenv:docs] [testenv:docs]
commands = python setup.py build_sphinx commands =
# Clean-up env and install horizon from git
{toxinidir}/tools/tox_helper.sh {envname} {basepython} pre
# Run test
python setup.py build_sphinx
# Clean-up env except log
{toxinidir}/tools/tox_helper.sh {envname} {basepython} post
[testenv:releasenotes] [testenv:releasenotes]
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html commands =
# Clean-up env and install horizon from git
[flake8] {toxinidir}/tools/tox_helper.sh {envname} {basepython} pre
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules # Run test
max-complexity = 20 sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
# Clean-up env except log
{toxinidir}/tools/tox_helper.sh {envname} {basepython} post
[testenv:lower-constraints] [testenv:lower-constraints]
basepython = python3 basepython = python3