The unit test uses sqlite for test which closes db foreign keys
function by default. This patch enabled the sqlite foreign keys
function for unit test by default.
The "project" table is a self referencing FK table(id <-> domain_id
column). So when the FK is enabled, there must exists a root record
before insert data to this table. It's <<keystone.domain.root>>.
Usually, the <<keystone.domain.root>> recored is inserted into the
table once operators run "keystone-manage db_sync" command when
deploy Keystone. But the unit test code doesn't run this command,
it initialise the db schema by reading sqlalchemy object model, so
the <<keystone.domain.root>> record is missed. Then we can't create
any project record, it'll raise FK error.
So in this patch, before creating any projects in the test, we must
ensure the <<keystone.domain.root>> record exists first.
Reviewed: https:/ /review. openstack. org/558193 /git.openstack. org/cgit/ openstack/ keystone/ commit/ ?id=012dac29b8d d6ac77e707f916f c4c0ca57d58b14
Committed: https:/
Submitter: Zuul
Branch: master
commit 012dac29b8dd6ac 77e707f916fc4c0 ca57d58b14
Author: wangxiyuan <email address hidden>
Date: Mon Apr 2 19:28:33 2018 +0800
Enable foreign keys for unit test
The unit test uses sqlite for test which closes db foreign keys
function by default. This patch enabled the sqlite foreign keys
function for unit test by default.
The "project" table is a self referencing FK table(id <-> domain_id domain. root>>.
column). So when the FK is enabled, there must exists a root record
before insert data to this table. It's <<keystone.
Usually, the <<keystone. domain. root>> recored is inserted into the domain. root>> record is missed. Then we can't create
table once operators run "keystone-manage db_sync" command when
deploy Keystone. But the unit test code doesn't run this command,
it initialise the db schema by reading sqlalchemy object model, so
the <<keystone.
any project record, it'll raise FK error.
So in this patch, before creating any projects in the test, we must domain. root>> record exists first.
ensure the <<keystone.
Change-Id: I565d12395ca39a 58ba90faf8641a9 e02d986aeb9
Closes-Bug: #1744195