Fix python-jobs
The thing is that nailgun tests require postgresql backend to be available. So, we need to prepare it before running tests. Fortunately, all unit tests are run on nodes where postgresql is installed. Change-Id: Idc14409d2b2d3473d0e3ef9d3e70bda57a331b11
This commit is contained in:
parent
1e034dfd57
commit
0eef4668ab
|
@ -123,7 +123,7 @@ def downgrade():
|
|||
vms_conf_downgrade()
|
||||
extend_segmentation_type_downgrade()
|
||||
|
||||
op.execute('UPDATE clusters SET name=LEFT(name, 50)')
|
||||
op.execute('UPDATE clusters SET name=substring(name from 1 for 50)')
|
||||
op.alter_column('clusters', 'name', type_=sa.VARCHAR(50))
|
||||
op.drop_constraint(
|
||||
'oswl_stats_cluster_id_created_date_resource_type_unique_key',
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "Preparing pgpass file ${NAILGUN_DB_ROOTPGPASS}"
|
||||
echo "*:*:*:${NAILGUN_DB_ROOT}:${NAILGUN_DB_ROOTPW}" > ${NAILGUN_DB_ROOTPGPASS}
|
||||
chmod 600 ${NAILGUN_DB_ROOTPGPASS}
|
||||
|
||||
export PGPASSFILE=${NAILGUN_DB_ROOTPGPASS}
|
||||
|
||||
echo "Trying to find out if role ${NAILGUN_DB_USER} exists"
|
||||
root_roles=$(psql -h 127.0.0.1 -U ${NAILGUN_DB_ROOT} -t -c "SELECT 'HERE' from pg_roles where rolname='${NAILGUN_DB_USER}'")
|
||||
if [[ ${root_roles} == *HERE ]];then
|
||||
echo "Role ${NAILGUN_DB_USER} exists. Setting password ${NAILGUN_DB_PW}"
|
||||
psql -h 127.0.0.1 -U ${NAILGUN_DB_ROOT} -c "ALTER ROLE ${NAILGUN_DB_USER} WITH SUPERUSER LOGIN PASSWORD '${NAILGUN_DB_PW}'"
|
||||
else
|
||||
echo "Creating role ${NAILGUN_DB_USER} with password ${NAILGUN_DB_PASSWD}"
|
||||
psql -h 127.0.0.1 -U ${NAILGUN_DB_ROOT} -c "CREATE ROLE ${NAILGUN_DB_USER} WITH SUPERUSER LOGIN PASSWORD '${NAILGUN_DB_PW}'"
|
||||
fi
|
||||
|
||||
echo "Dropping database ${NAILGUN_DB} if exists"
|
||||
psql -h 127.0.0.1 -U ${NAILGUN_DB_ROOT} -c "DROP DATABASE IF EXISTS ${NAILGUN_DB}"
|
||||
echo "Creating database ${NAILGUN_DB}"
|
||||
psql -h 127.0.0.1 -U ${NAILGUN_DB_ROOT} -c "CREATE DATABASE ${NAILGUN_DB} OWNER ${NAILGUN_DB_USER}"
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
cat > ${NAILGUN_CONFIG} <<EOL
|
||||
DEVELOPMENT: 1
|
||||
STATIC_DIR: ${NAILGUN_STATIC}
|
||||
TEMPLATE_DIR: ${NAILGUN_TEMPLATES}
|
||||
DATABASE:
|
||||
name: "${NAILGUN_DB}"
|
||||
engine: "postgresql"
|
||||
host: "localhost"
|
||||
port: "5432"
|
||||
user: "${NAILGUN_DB_USER}"
|
||||
passwd: "${NAILGUN_DB_PW}"
|
||||
API_LOG: ${NAILGUN_LOGS}/api.log
|
||||
APP_LOG: ${NAILGUN_LOGS}/app.log
|
||||
EOL
|
|
@ -0,0 +1,57 @@
|
|||
[tox]
|
||||
minversion = 1.6
|
||||
skipsdist = True
|
||||
setupdir = {toxinidir}/nailgun
|
||||
envlist = py26,py27,py34,pep8
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
install_command = pip install --allow-external -U {opts} {packages}
|
||||
whitelist_externals = bash
|
||||
changedir={toxinidir}/nailgun
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
NAILGUN_CONFIG={toxinidir}/nailgun/test.yaml
|
||||
NAILGUN_LOGS={toxinidir}/nailgun
|
||||
NAILGUN_STATIC={toxinidir}/nailgun/static
|
||||
NAILGUN_TEMPLATES={toxinidir}/nailgun/static
|
||||
NAILGUN_DB=openstack_citest
|
||||
NAILGUN_DB_USER=openstack_citest
|
||||
NAILGUN_DB_PW=openstack_citest
|
||||
NAILGUN_DB_ROOT=postgres
|
||||
NAILGUN_DB_ROOTPW=insecure_slave
|
||||
NAILGUN_DB_ROOTPGPASS={toxinidir}/nailgun/pgpass
|
||||
deps = -r{toxinidir}/nailgun/test-requirements.txt
|
||||
commands =
|
||||
bash "{toxinidir}/nailgun/tools/prepare_settings_yaml.sh"
|
||||
bash "{toxinidir}/nailgun/tools/prepare_database.sh"
|
||||
py.test -vv --cleandb --junit-xml {toxinidir}/nailgun/nailgun.xml -m 'not performance' -n 4 {posargs:nailgun/test}
|
||||
py.test -vv --junit-xml {toxinidir}/nailgun/extensions.xml {posargs:nailgun/extensions}
|
||||
|
||||
[tox:jenkins]
|
||||
downloadcache = ~/cache/pip
|
||||
|
||||
[testenv:cover]
|
||||
setenv = NOSE_WITH_COVERAGE=1
|
||||
|
||||
[testenv:venv]
|
||||
deps = -r{toxinidir}/nailgun/requirements.txt
|
||||
commands = {posargs:}
|
||||
|
||||
[testenv:pep8]
|
||||
deps = hacking==0.10
|
||||
usedevelop = False
|
||||
commands =
|
||||
flake8 {posargs:nailgun}
|
||||
|
||||
[flake8]
|
||||
# NOTE(eli): H304 is "No relative imports" error, relative
|
||||
# imports are required for extensions which can be moved
|
||||
# from nailgun directory to different place
|
||||
ignore = H234,H302,H802,H304
|
||||
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,__init__.py,docs
|
||||
show-pep8 = True
|
||||
show-source = True
|
||||
count = True
|
||||
|
||||
[hacking]
|
||||
import_exceptions = testtools.matchers
|
Loading…
Reference in New Issue