From 3e5c88d2f71f66f3594099bcc216a0eb14c92631 Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Sun, 12 May 2013 18:04:28 +0400 Subject: Add db test that checks that shadow tables are up-to-date This is finally patch for bp db-improve-archiving. It add new test that checks that: 1) there is no extra shadow tables 2) for each table we have shadow table 3) Tables and shadow tables have the same columns. blueprint db-improve-archiving Change-Id: If037ccbb80a880777e8bc2224b0847ccf9413ea2 --- nova/tests/test_db_api.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 4f3773e48..6d6241332 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -28,6 +28,7 @@ import mox from oslo.config import cfg from sqlalchemy.dialects import sqlite from sqlalchemy.exc import IntegrityError +from sqlalchemy import MetaData from sqlalchemy.sql.expression import select from nova import context @@ -4054,6 +4055,16 @@ class ArchiveTestCase(test.TestCase): del_statement = table.delete(table.c.domain.in_(self.uuidstrs)) self.conn.execute(del_statement) + def test_shadow_tables(self): + metadata = MetaData(bind=self.engine) + metadata.reflect() + for table_name in metadata.tables: + if table_name.startswith("shadow_"): + self.assertIn(table_name[7:], metadata.tables) + continue + self.assertTrue(db_utils.check_shadow_table(self.engine, + table_name)) + def test_archive_deleted_rows(self): # Add 6 rows to table for uuidstr in self.uuidstrs: -- cgit