From 8890f40e1bf0c5642bb7d59fba62bc12a530d084 Mon Sep 17 00:00:00 2001 From: Kurt Taylor Date: Fri, 8 Feb 2013 16:12:13 -0500 Subject: Add and check data functions for test_migrations 141 Before the 141 migration test is run, _prerun_141 populates the migrations table with a generated uuid. The _check_141 function checks that the uuid migrated properly down to 36 char. Partially implements: blueprint migration-testing-with-data Change-Id: I43b47f69a94720bf9487eb30576035493700ddca --- nova/tests/test_migrations.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index e71b97513..6960d0174 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -47,6 +47,7 @@ import datetime import os import sqlalchemy import urlparse +import uuid from migrate.versioning import repository @@ -440,6 +441,24 @@ class TestMigrations(BaseMigrationTestCase): self.assertEqual(data[0]['mac'], bw['mac']) + # migration 141, update migrations instance uuid + def _prerun_141(self, engine): + data = { + 'instance_uuid': str(uuid.uuid4()) + } + migrations = get_table(engine, 'migrations') + engine.execute(migrations.insert(), data) + result = migrations.insert().values(data).execute() + data['id'] = result.inserted_primary_key[0] + return data + + def _check_141(self, engine, data): + migrations = get_table(engine, 'migrations') + row = migrations.select( + migrations.c.id == data['id']).execute().first() + # Check that change to String(36) went alright + self.assertEqual(data['instance_uuid'], row['instance_uuid']) + # migration 146, availability zone transition def _prerun_146(self, engine): data = { -- cgit