yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #75188
[Bug 1744195] Re: unit tests don't enable Foreign Key for Sqlite
Reviewed: https://review.openstack.org/558193
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=012dac29b8dd6ac77e707f916fc4c0ca57d58b14
Submitter: Zuul
Branch: master
commit 012dac29b8dd6ac77e707f916fc4c0ca57d58b14
Author: wangxiyuan <wangxiyuan@xxxxxxxxxx>
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
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.
Change-Id: I565d12395ca39a58ba90faf8641a9e02d986aeb9
Closes-Bug: #1744195
** Changed in: keystone
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Identity (keystone).
https://bugs.launchpad.net/bugs/1744195
Title:
unit tests don't enable Foreign Key for Sqlite
Status in OpenStack Identity (keystone):
Fix Released
Bug description:
Now Keystone runs unit test with sqlite backend by default. But sqlite doesn't enable Foreign Key function by default.
It means that we lost the case for all FK related test.
Even after enabled FK for the test. There still some problems:
1. We lost root domain (<<keystone.domian.root>>) when setup tests. So that a lot of tests will fail.
2. Some tests, such as test_sql_upgrade and identity.backends.test_sql, use global db engine. It means that the test will meet conflict if the FK is enabled for the global db engine.
So we should refactor our test code to satisfy sqilte FK function.
There are some steps:
1. Add FK support for the tests. Disable it by default
2. Enable FK for the test one by one.
3. Make sure the Fk is disabled for test_sql_upgrade and identity.backends.test_sql
To manage notifications about this bug go to:
https://bugs.launchpad.net/keystone/+bug/1744195/+subscriptions
References