Fix gate job for ostf repo

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: I8f93bb78cb4144f993fb55936e157b5fe153a4c1
Closes-Bug: #1516609
This commit is contained in:
Tatyana Leontovich 2015-11-16 19:44:08 +02:00 committed by Vladimir Kozhukalov
parent 9690a2de82
commit 921c86ed3a
3 changed files with 62 additions and 2 deletions

View File

@ -0,0 +1,22 @@
#!/bin/sh
echo "Preparing pgpass file ${DB_ROOTPGPASS}"
echo "*:*:*:${OSTF_DB_ROOT}:${OSTF_DB_ROOTPW}" > ${OSTF_DB_ROOTPGPASS}
chmod 600 ${OSTF_DB_ROOTPGPASS}
export PGPASSFILE=${OSTF_DB_ROOTPGPASS}
echo "Trying to find out if role ${OSTF_DB_USER} exists"
root_roles=$(psql -h 127.0.0.1 -U ${OSTF_DB_ROOT} -t -c "SELECT 'HERE' from pg_roles where rolname='${OSTF_DB_USER}'")
if [[ ${root_roles} == *HERE ]];then
echo "Role ${OSTF_DB_USER} exists. Setting password ${OSTF_DB_PW}"
psql -h 127.0.0.1 -U ${OSTF_DB_ROOT} -c "ALTER ROLE ${OSTF_DB_USER} WITH SUPERUSER LOGIN PASSWORD '${OSTF_DB_PW}'"
else
echo "Creating role ${OSTF_DB_USER} with password ${OSTF_DB_PASSWD}"
psql -h 127.0.0.1 -U ${OSTF_DB_ROOT} -c "CREATE ROLE ${OSTF_DB_USER} WITH SUPERUSER LOGIN PASSWORD '${OSTF_DB_PW}'"
fi
echo "Dropping database ${OSTF_DB} if exists"
psql -h 127.0.0.1 -U ${OSTF_DB_ROOT} -c "DROP DATABASE IF EXISTS ${OSTF_DB}"
echo "Creating database ${OSTF_DB}"
psql -h 127.0.0.1 -U ${OSTF_DB_ROOT} -c "CREATE DATABASE ${OSTF_DB} OWNER ${OSTF_DB_USER}"

View File

@ -0,0 +1,16 @@
#!/bin/sh
cat > ${OSTF_CI_CONF} <<EOL
[adapter]
server_host = 127.0.0.1
server_port = 8777
nailgun_host = 127.0.0.1
nailgun_port = 8000
log_file = ${OSTF_LOGS}"
after_init_hook = False
auth_enable = False
name: "${OSTF_DB}"
engine: "postgresql"
user: "${OSTF_DB_USER}"
passwd: "${OSTF_DB_PW}"
EOL

26
tox.ini
View File

@ -5,15 +5,34 @@
[tox]
minversion = 1.6
envlist = pep8
envlist = py26,py27,pep8
skipsdist = True
[testenv]
usedevelop = True
whitelist_externals = bash
setenv = VIRTUAL_ENV={envdir}
OSTF_CI_CONF={toxinidir}/etc/tools/ostf_ci.conf
OSTF_LOGS={toxinidir}/ostf
OSTF_DB=ostf
OSTF_DB_USER=ostf
OSTF_DB_PW=ostf
OSTF_DB_ROOT=postgres
OSTF_DB_ROOTPW=insecure_slave
OSTF_DB_ROOTPGPASS={toxinidir}/pgpass
deps = -r{toxinidir}/test-requirements.txt
commands =
nosetests {posargs:fuel_plugin/testing/tests}
/bin/bash "{toxinidir}/etc/tools/prepare_settings.sh"
/bin/bash "{toxinidir}/etc/tools/prepare_database.sh"
ostf-server --config-file {toxinidir}/etc/tools/ostf_ci.conf --after-initialization-environment-hook
nosetests {posargs:fuel_plugin/testing/tests/unit}
nosetests {posargs:fuel_plugin/testing/tests/integration}
[tox:jenkins]
downloadcache = ~/cache/pip
[testenv:cover]
setenv = NOSE_WITH_COVERAGE=1
[testenv:venv]
deps = -r{toxinidir}/requirements.txt
@ -30,3 +49,6 @@ exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,__init__.py,doc
show-pep8 = True
show-source = True
count = True
[hacking]
import_exceptions = testtools.matchers