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
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -7,7 +7,7 @@ services:
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=insecure_worker
|
||||
ports:
|
||||
- "3306:3306"
|
||||
- "${ZUUL_MYSQL_PORT:-3306}:3306"
|
||||
tmpfs:
|
||||
- /var/lib/mysql
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user