Exemple #1
0
 def test_migration(self):
     db.aggregate_create(self.context, {'name': 'foo'})
     main_aggregates_len = len(db.aggregate_get_all(self.context))
     match, done = aggregate_obj.migrate_aggregates(self.context, 50)
     self.assertEqual(1, main_aggregates_len)
     self.assertEqual(main_aggregates_len, match)
     self.assertEqual(main_aggregates_len, done)
     self.assertEqual(0, len(db.aggregate_get_all(self.context)))
     self.assertEqual(main_aggregates_len,
                      len(aggregate_obj.AggregateList.get_all(
                                                             self.context)))
Exemple #2
0
 def test_migration(self):
     db.aggregate_create(self.context, {'name': 'foo'})
     main_aggregates_len = len(db.aggregate_get_all(self.context))
     match, done = aggregate_obj.migrate_aggregates(self.context, 50)
     self.assertEqual(1, main_aggregates_len)
     self.assertEqual(main_aggregates_len, match)
     self.assertEqual(main_aggregates_len, done)
     self.assertEqual(0, len(db.aggregate_get_all(self.context)))
     self.assertEqual(
         main_aggregates_len,
         len(aggregate_obj.AggregateList.get_all(self.context)))
Exemple #3
0
 def test_migrate_aggregates_duplicate_unicode(self, mock_log_error):
     """Tests that we handle a duplicate aggregate when migrating and that
     we handle when the exception message is in unicode.
     """
     # First create an aggregate that will be migrated from main to API DB.
     create_aggregate(self.context, 1, in_api=False)
     # Now create that same aggregate in the API DB.
     create_aggregate(self.context, 1, in_api=True)
     # Now let's run the online data migration which will fail to create
     # a duplicate aggregate in the API database and will raise
     # AggregateNameExists which we want to modify to have a unicode
     # message.
     with mock.patch.object(exception.AggregateNameExists, 'msg_fmt',
                            u'\xF0\x9F\x92\xA9'):
         match, done = aggregate_obj.migrate_aggregates(self.context, 50)
         # we found one
         self.assertEqual(1, match)
         # but we didn't migrate it
         self.assertEqual(0, done)
         # and we logged an error for the duplicate aggregate
         mock_log_error.assert_called()
Exemple #4
0
 def test_migrate_aggregates_duplicate_unicode(self, mock_log_error):
     """Tests that we handle a duplicate aggregate when migrating and that
     we handle when the exception message is in unicode.
     """
     # First create an aggregate that will be migrated from main to API DB.
     create_aggregate(self.context, 1, in_api=False)
     # Now create that same aggregate in the API DB.
     create_aggregate(self.context, 1, in_api=True)
     # Now let's run the online data migration which will fail to create
     # a duplicate aggregate in the API database and will raise
     # AggregateNameExists which we want to modify to have a unicode
     # message.
     with mock.patch.object(exception.AggregateNameExists, 'msg_fmt',
                            u'\xF0\x9F\x92\xA9'):
         match, done = aggregate_obj.migrate_aggregates(self.context, 50)
         # we found one
         self.assertEqual(1, match)
         # but we didn't migrate it
         self.assertEqual(0, done)
         # and we logged an error for the duplicate aggregate
         mock_log_error.assert_called()
Exemple #5
0
 def _seed_data(self):
     for i in range(1, 10):
         create_aggregate(self.context, i, in_api=False)
     aggregate_obj.migrate_aggregates(self.context, 50)
Exemple #6
0
 def _seed_data(self):
     for i in range(1, 10):
         create_aggregate(self.context, i, in_api=False)
     aggregate_obj.migrate_aggregates(self.context, 50)