Support databases on other hosts during tests

In some setups (e.g. docker based) the test databases are not on
localhost. Allow overriding this like it is done for other zk hosts.

Also don't create test accounts with unencrypted passwords. This is no
longer supported in recent postgres versions.

Change-Id: I22ad29b31c7c51c117543eb05c3bfc0f5555562c
This commit is contained in:
Tobias Henkel 2018-04-10 20:43:23 +02:00
parent 83a2aa0d84
commit 3aa0d9ed8a
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
2 changed files with 18 additions and 11 deletions

View File

@ -1908,7 +1908,8 @@ class MySQLSchemaFixture(fixtures.Fixture):
for x in range(8))
self.name = '%s_%s' % (random_bits, os.getpid())
self.passwd = uuid.uuid4().hex
db = pymysql.connect(host="127.0.0.1",
self.host = os.environ.get('ZUUL_MYSQL_HOST', '127.0.0.1')
db = pymysql.connect(host=self.host,
user="openstack_citest",
passwd="openstack_citest",
db="openstack_citest")
@ -1919,14 +1920,13 @@ class MySQLSchemaFixture(fixtures.Fixture):
(self.name, self.name, self.passwd))
cur.execute("flush privileges")
self.dburi = 'mysql+pymysql://%s:%s@127.0.0.1/%s' % (self.name,
self.passwd,
self.name)
self.dburi = 'mysql+pymysql://{name}:{passwd}@{host}/{name}'.format(
name=self.name, passwd=self.passwd, host=self.host)
self.addDetail('dburi', testtools.content.text_content(self.dburi))
self.addCleanup(self.cleanup)
def cleanup(self):
db = pymysql.connect(host="127.0.0.1",
db = pymysql.connect(host=self.host,
user="openstack_citest",
passwd="openstack_citest",
db="openstack_citest")
@ -1946,7 +1946,8 @@ class PostgresqlSchemaFixture(fixtures.Fixture):
for x in range(8))
self.name = '%s_%s' % (random_bits, os.getpid())
self.passwd = uuid.uuid4().hex
db = psycopg2.connect(host="localhost",
self.host = os.environ.get('ZUUL_POSTGRES_HOST', '127.0.0.1')
db = psycopg2.connect(host=self.host,
user="openstack_citest",
password="openstack_citest",
database="openstack_citest")
@ -1957,15 +1958,14 @@ class PostgresqlSchemaFixture(fixtures.Fixture):
cur.execute("create database %s OWNER %s TEMPLATE template0 "
"ENCODING 'UTF8';" % (self.name, self.name))
self.dburi = 'postgresql://%s:%s@localhost/%s' % (self.name,
self.passwd,
self.name)
self.dburi = 'postgresql://{name}:{passwd}@{host}/{name}'.format(
name=self.name, passwd=self.passwd, host=self.host)
self.addDetail('dburi', testtools.content.text_content(self.dburi))
self.addCleanup(self.cleanup)
def cleanup(self):
db = psycopg2.connect(host="localhost",
db = psycopg2.connect(host=self.host,
user="openstack_citest",
password="openstack_citest",
database="openstack_citest")

View File

@ -11,7 +11,14 @@ setenv = VIRTUAL_ENV={envdir}
OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:1}
OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:1}
OS_LOG_DEFAULTS={env:OS_LOG_DEFAULTS:""}
passenv = ZUUL_TEST_ROOT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE OS_LOG_DEFAULTS NODEPOOL_ZK_HOST
passenv = ZUUL_TEST_ROOT
OS_STDOUT_CAPTURE
OS_STDERR_CAPTURE
OS_LOG_CAPTURE
OS_LOG_DEFAULTS
NODEPOOL_ZK_HOST
ZUUL_MYSQL_HOST
ZUUL_POSTGRES_HOST
usedevelop = True
install_command = pip install {opts} {packages}
whitelist_externals = bash