diff options
| author | Kurt Taylor <krtaylor@us.ibm.com> | 2013-02-12 11:08:19 -0500 |
|---|---|---|
| committer | Kurt Taylor <krtaylor@us.ibm.com> | 2013-02-13 12:55:08 -0500 |
| commit | bb9908c115a2179fc973ca01f932fe5e76eea4a3 (patch) | |
| tree | 8d6e6a3e5cbb5f96e9335e1ee6a19708cb5e23d9 | |
| parent | 07e0c2421adf14d01389f5d6692ac2e18b8b7134 (diff) | |
| download | nova-bb9908c115a2179fc973ca01f932fe5e76eea4a3.tar.gz nova-bb9908c115a2179fc973ca01f932fe5e76eea4a3.tar.xz nova-bb9908c115a2179fc973ca01f932fe5e76eea4a3.zip | |
Add migration with data test for migration 151
Before the 151 migration test is run, _prerun_151 populates the task_log
table with generated date and time in string format for period_beginning and
period_ending. The _check_151 function checks that the migration from string
to DateTime worked as expected.
Partially implements: blueprint migration-testing-with-data
Change-Id: I6d354741a75804bc490ffefde04c5925dd1a2a90
| -rw-r--r-- | nova/tests/test_migrations.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index a0c5db9c4..392571bbe 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -45,10 +45,10 @@ import commands import ConfigParser import datetime import os +import sqlalchemy import urlparse from migrate.versioning import repository -import sqlalchemy import nova.db.migration as migration import nova.db.sqlalchemy.migrate_repo @@ -529,6 +529,32 @@ class TestMigrations(BaseMigrationTestCase): for row in result: self.assertIn(row['cidr'], iplist) + # migration 151 - changes period_beginning and period_ending to DateTime + def _prerun_151(self, engine): + task_log = get_table(engine, 'task_log') + data = { + 'task_name': 'The name of the task', + 'state': 'The state of the task', + 'host': 'compute-host1', + 'period_beginning': str(datetime.datetime(2013, 02, 11)), + 'period_ending': str(datetime.datetime(2013, 02, 12)), + 'message': 'The task_log message', + } + result = task_log.insert().values(data).execute() + data['id'] = result.inserted_primary_key[0] + return data + + def _check_151(self, engine, data): + task_log = get_table(engine, 'task_log') + row = task_log.select(task_log.c.id == data['id']).execute().first() + self.assertTrue(isinstance(row['period_beginning'], + datetime.datetime)) + self.assertTrue(isinstance(row['period_ending'], + datetime.datetime)) + self.assertEqual( + data['period_beginning'], str(row['period_beginning'])) + self.assertEqual(data['period_ending'], str(row['period_ending'])) + # migration 152 - convert deleted from boolean to int def _prerun_152(self, engine): host1 = 'compute-host1' |
