From 3769633faba091711c42c8780444f9c12fb054a2 Mon Sep 17 00:00:00 2001 From: "Mauro S. M. Rodrigues" Date: Tue, 19 Feb 2013 12:18:01 -0500 Subject: Enhance IPAdresses migration tests This enhances IPAddresses tests to check if the migration goes fine with longer IPv6, and with ipv6 that can be shortened (postgresql uses shortened form, mysql and sqlite doesn't). Also enhances cidr tests to check migration of shortenables cidrs, and cidrs that postgresql suppress its prefix, like 10.0.0.0/32 cause it is pretty much the same as 10.0.0.0 Partially implements bp migration-testing-with-data Change-Id: I11dfc8fda7034a46a6bc067294ac8e88ca43b508 --- nova/tests/test_migrations.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py index fb7411cd0..8ffa0021c 100644 --- a/nova/tests/test_migrations.py +++ b/nova/tests/test_migrations.py @@ -44,6 +44,7 @@ import collections import commands import ConfigParser import datetime +import netaddr import os import sqlalchemy import urlparse @@ -515,10 +516,16 @@ class TestMigrations(BaseMigrationTestCase): 'to_port': 1234, 'cidr': "127.0.0.1/30"}, {'protocol': 'tcp', 'from_port': 1234, 'to_port': 1234, 'cidr': "128.128.128.128/16"}, + {'protocol': 'tcp', 'from_port': 1234, + 'to_port': 1234, 'cidr': "128.128.128.128/32"}, {'protocol': 'tcp', 'from_port': 1234, 'to_port': 1234, 'cidr': "2001:db8::1:2/48"}, {'protocol': 'tcp', 'from_port': 1234, - 'to_port': 1234, 'cidr': "::1/64"} + 'to_port': 1234, 'cidr': "::1/64"}, + {'protocol': 'tcp', 'from_port': 1234, 'to_port': 1234, + 'cidr': "0000:0000:0000:2013:0000:6535:abcd:ef11/64"}, + {'protocol': 'tcp', 'from_port': 1234, 'to_port': 1234, + 'cidr': "0000:1020:0000:2013:0000:6535:abcd:ef11/128"}, ], 'console_pools': [ @@ -526,6 +533,7 @@ class TestMigrations(BaseMigrationTestCase): {'address': '128.100.100.100'}, {'address': '2002:2002:2002:2002:2002:2002:2002:2002'}, {'address': '::1'}, + {'address': '0000:0000:0000:2013:0000:6535:abcd:ef11'} ] } @@ -540,18 +548,20 @@ class TestMigrations(BaseMigrationTestCase): provider_fw_rules = get_table(engine, 'provider_fw_rules') result = provider_fw_rules.select().execute() - iplist = map(lambda x: x['cidr'], data['provider_fw_rules']) + iplist = map(lambda x: str(netaddr.IPNetwork(x['cidr'])), + data['provider_fw_rules']) for row in result: - self.assertIn(row['cidr'], iplist) + self.assertIn(str(netaddr.IPNetwork(row['cidr'])), iplist) console_pools = get_table(engine, 'console_pools') result = console_pools.select().execute() - iplist = map(lambda x: x['address'], data['console_pools']) + iplist = map(lambda x: str(netaddr.IPAddress(x['address'])), + data['console_pools']) for row in result: - self.assertIn(row['address'], iplist) + self.assertIn(str(netaddr.IPAddress(row['address'])), iplist) # migration 151 - changes period_beginning and period_ending to DateTime def _prerun_151(self, engine): @@ -738,10 +748,16 @@ class TestMigrations(BaseMigrationTestCase): 'to_port': 1234, 'cidr': "127.0.0.1/30"}, {'protocol': 'tcp', 'from_port': 1234, 'to_port': 1234, 'cidr': "128.128.128.128/16"}, + {'protocol': 'tcp', 'from_port': 1234, + 'to_port': 1234, 'cidr': "128.128.128.128/32"}, {'protocol': 'tcp', 'from_port': 1234, 'to_port': 1234, 'cidr': "2001:db8::1:2/48"}, {'protocol': 'tcp', 'from_port': 1234, - 'to_port': 1234, 'cidr': "::1/64"} + 'to_port': 1234, 'cidr': "::1/64"}, + {'protocol': 'tcp', 'from_port': 1234, 'to_port': 1234, + 'cidr': "0000:0000:0000:2013:0000:6535:abcd:ef11/64"}, + {'protocol': 'tcp', 'from_port': 1234, 'to_port': 1234, + 'cidr': "0000:1020:0000:2013:0000:6535:abcd:ef11/128"}, ], 'console_pools': [ @@ -749,6 +765,7 @@ class TestMigrations(BaseMigrationTestCase): {'address': '128.100.100.100'}, {'address': '2002:2002:2002:2002:2002:2002:2002:2002'}, {'address': '::1'}, + {'address': '0000:0000:0000:2013:0000:6535:abcd:ef11'} ] } return data -- cgit