Browse Source

Allow to specify MySQL port for test environment

In case for whatever reason there is already another
MySQL server running on the standard port developers
may want to run the MySQL test-server on a different
port. This can be done by specifying an environment
variable "ZUUL_MYSQL_PORT":

export ZUUL_MYSQL_PORT=3307
tools/test-setup-docker.sh
tox -e py3

Change-Id: Id32bac1a87619803d973b066762d525bd9a4f913
changes/49/823349/2
djager 5 months ago
parent
commit
1419356ed8
  1. 12
      tests/base.py
  2. 2
      tools/docker-compose.yaml
  3. 1
      tox.ini

12
tests/base.py

@ -4023,7 +4023,9 @@ class MySQLSchemaFixture(fixtures.Fixture):
self.name = '%s_%s' % (random_bits, os.getpid())
self.passwd = uuid.uuid4().hex
self.host = os.environ.get('ZUUL_MYSQL_HOST', '127.0.0.1')
self.port = int(os.environ.get('ZUUL_MYSQL_PORT', 3306))
db = pymysql.connect(host=self.host,
port=self.port,
user="openstack_citest",
passwd="openstack_citest",
db="openstack_citest")
@ -4039,13 +4041,19 @@ class MySQLSchemaFixture(fixtures.Fixture):
finally:
db.close()
self.dburi = 'mysql+pymysql://{name}:{passwd}@{host}/{name}'.format(
name=self.name, passwd=self.passwd, host=self.host)
self.dburi = 'mysql+pymysql://{name}:{passwd}@{host}:{port}/{name}'\
.format(
name=self.name,
passwd=self.passwd,
host=self.host,
port=self.port
)
self.addDetail('dburi', testtools.content.text_content(self.dburi))
self.addCleanup(self.cleanup)
def cleanup(self):
db = pymysql.connect(host=self.host,
port=self.port,
user="openstack_citest",
passwd="openstack_citest",
db="openstack_citest")

2
tools/docker-compose.yaml

@ -7,7 +7,7 @@ services:
environment:
- MYSQL_ROOT_PASSWORD=insecure_worker
ports:
- "3306:3306"
- "${ZUUL_MYSQL_PORT:-3306}:3306"
tmpfs:
- /var/lib/mysql
volumes:

1
tox.ini

@ -27,6 +27,7 @@ passenv =
OS_STDOUT_CAPTURE
YARN_REGISTRY
ZUUL_MYSQL_HOST
ZUUL_MYSQL_PORT
ZUUL_POSTGRES_HOST
ZUUL_SCHEDULER_COUNT
ZUUL_TEST_ROOT

Loading…
Cancel
Save