[openstack-dev] [Heat] moving sqlite migration scripts to tests

Zane Bitter zbitter at redhat.com
Fri Apr 17 17:29:51 UTC 2015


On 16/04/15 04:05, Anant Patil wrote:
> Hi,
>
> Sometime back we had a discussion on IRC regarding sqlite migration
> scripts. Since sqlite is mostly used for testing, we were thinking
> about moving the sqlite migration related code to tests folder and
> keep the migrate_repo sane (with only production code). There was
> utility class[1] added recently for helping with sqlite migrations
> and there were questions on the location of that class. The utility
> lives in heat/db/sqlalchemy folder and since it is used only for
> testing, it should probably live somewhere in the tests folder (like
> tests/migrate_repo? ) along with the sqlite migration scripts.
>
> It would be better if we have a separate path for testing code and
> depending on the configured DB back-end (for example, sqlite), we pass
> the appropriate path (something like tests/migrate_repo for sqlite) to
> oslo_migration.db_sync().
>
> If it is okay to assume that sqlite is *always* used for testing, then
> IMO, we should re-factor the migration scripts. Please help us with your
> thoughts.
>
> [1]
> https://github.com/openstack/heat/blob/master/heat/db/sqlalchemy/utils.py
>
> - Anant

You're correct that we can assume SQLite is only used for tests.

However, I'm not convinced that we need to change the migration 
scripts... it's bad enough that we have to write two different 
migrations in many cases (and totally unclear to me how this is testing 
anything useful), but having to write them in two different places seems 
even worse.

I'd be more interested in seeing a change whereby we stop doing 
pointless migrations on an empty SQLite DB prior to testing and just 
generate it from the model. I think we can rely on the migration tests 
that run against the actual mariadb/postgresql clients to test the 
migrations themselves - we effectively already are in many cases.

cheers,
Zane.



More information about the OpenStack-dev mailing list