[openstack-dev] [nova] how to unit test scripts outside of nova/nova?
Matt Riedemann
mriedem at linux.vnet.ibm.com
Tue Jul 1 20:21:06 UTC 2014
As part of the enforce-unique-instance-uuid-in-db blueprint [1] I'm
writing a script to scan the database and find any NULL instance_uuid
records that will cause the new database migration to fail so that
operators can run this before they run the migration, otherwise the
migration blocks if these types of records are found.
I have the script written [2], but wanted to also write unit tests for
it. I guess I assumed the script would go under nova/tools/db like the
schema_diff.py script, but I'm not sure how to unit test anything
outside of the nova/nova tree.
Nova's testr configuration is only discovering tests within nova/tests
[3]. But I don't think I can put the unit tests under nova/tests and
then import the module from nova/tools.
So I'm a bit stuck. I could take the easy way out and just throw the
script under nova/db/sqlalchemy/migrate_repo and put my unit tests under
nova/tests/db/, and I'd also get pep8 checking with that, but that
doesn't seem right - but I'm also possibly over-thinking this.
Anyone else have any ideas?
[1]
https://blueprints.launchpad.net/nova/+spec/enforce-unique-instance-uuid-in-db
[2] https://review.openstack.org/#/c/97946/
[3] http://git.openstack.org/cgit/openstack/nova/tree/.testr.conf#n5
--
Thanks,
Matt Riedemann
More information about the OpenStack-dev
mailing list