Esempio n. 1
0
    def test_create_incomplete_consumers(self):
        """Test the online data migration that creates incomplete consumer
        records along with the incomplete consumer project/user records.
        """
        self._create_incomplete_allocations(self.ctx)
        # We do a "really online" online data migration for incomplete
        # consumers when calling alloc_obj.get_all_by_consumer_id() and
        # alloc_obj.get_all_by_resource_provider() and there are still
        # incomplete consumer records. So, to simulate a situation where the
        # operator has yet to run the nova-manage online_data_migration CLI
        # tool completely, we first call
        # consumer_obj.create_incomplete_consumers() with a batch size of 1.
        # This should mean there will be two allocation records still remaining
        # with a missing consumer record (since we create 3 total to begin
        # with). We then query the allocations table directly to grab that
        # consumer UUID in the allocations table that doesn't refer to a
        # consumer table record and call
        # alloc_obj.get_all_by_consumer_id() with that consumer UUID. This
        # should create the remaining missing consumer record "inline" in the
        # alloc_obj.get_all_by_consumer_id() method.
        # After that happens, there should still be a single allocation record
        # that is missing a relation to the consumers table. We call the
        # alloc_obj.get_all_by_resource_provider() method and verify that
        # method cleans up the remaining incomplete consumers relationship.
        res = consumer_obj.create_incomplete_consumers(self.ctx, 1)
        self.assertEqual((1, 1), res)

        # Grab the consumer UUID for the allocation record with a
        # still-incomplete consumer record.
        res = _get_allocs_with_no_consumer_relationship(self.ctx)
        self.assertEqual(2, len(res))
        still_missing = res[0][0]
        alloc_obj.get_all_by_consumer_id(self.ctx, still_missing)

        # There should still be a single missing consumer relationship. Let's
        # grab that and call alloc_obj.get_all_by_resource_provider()
        # which should clean that last one up for us.
        res = _get_allocs_with_no_consumer_relationship(self.ctx)
        self.assertEqual(1, len(res))
        still_missing = res[0][0]
        rp1 = rp_obj.ResourceProvider(self.ctx, id=1)
        alloc_obj.get_all_by_resource_provider(self.ctx, rp1)

        # get_all_by_resource_provider() should have auto-completed the still
        # missing consumer record and _check_incomplete_consumers() should
        # assert correctly that there are no more incomplete consumer records.
        self._check_incomplete_consumers(self.ctx)
        res = consumer_obj.create_incomplete_consumers(self.ctx, 10)
        self.assertEqual((0, 0), res)
Esempio n. 2
0
 def test_check_incomplete_consumers(self):
     # Create some allocations with 3 missing consumers.
     self._create_incomplete_allocations(self.context,
                                         num_of_consumer_allocs=2)
     result = self.checks._check_incomplete_consumers()
     # Since there are incomplete consumers, there should be a warning.
     self.assertEqual(upgradecheck.Code.WARNING, result.code)
     # Check the details for the consumer count.
     self.assertIn(
         'There are 3 incomplete consumers table records for '
         'existing allocations', result.details)
     # Run the online data migration (as recommended from the check output).
     consumer.create_incomplete_consumers(self.context, batch_size=50)
     # Run the check again and it should be successful.
     result = self.checks._check_incomplete_consumers()
     self.assertEqual(upgradecheck.Code.SUCCESS, result.code)
Esempio n. 3
0
 def test_create_incomplete_consumers_multiple_allocs_per_consumer(self):
     """Tests that missing consumer records are created when listing
     allocations against a resource provider or running the online data
     migration routine when the consumers have multiple allocations on the
     same provider.
     """
     self._create_incomplete_allocations(self.ctx, num_of_consumer_allocs=2)
     # Run the online data migration to migrate one consumer. The batch size
     # needs to be large enough to hit more than one consumer for this test
     # where each consumer has two allocations.
     res = consumer_obj.create_incomplete_consumers(self.ctx, 2)
     self.assertEqual((2, 2), res)
     # Migrate the rest by listing allocations on the resource provider.
     rp1 = rp_obj.ResourceProvider(self.ctx, id=1)
     alloc_obj.get_all_by_resource_provider(self.ctx, rp1)
     self._check_incomplete_consumers(self.ctx)
     res = consumer_obj.create_incomplete_consumers(self.ctx, 10)
     self.assertEqual((0, 0), res)
Esempio n. 4
0
    def test_create_incomplete_consumers(self):
        """Test the online data migration that creates incomplete consumer
        records along with the incomplete consumer project/user records.
        """
        self._create_incomplete_allocations(self.ctx)
        # We do a "really online" online data migration for incomplete
        # consumers when calling alloc_obj.get_all_by_consumer_id() and
        # alloc_obj.get_all_by_resource_provider() and there are still
        # incomplete consumer records. So, to simulate a situation where the
        # operator has yet to run the nova-manage online_data_migration CLI
        # tool completely, we first call
        # consumer_obj.create_incomplete_consumers() with a batch size of 1.
        # This should mean there will be two allocation records still remaining
        # with a missing consumer record (since we create 3 total to begin
        # with).
        res = consumer_obj.create_incomplete_consumers(self.ctx, 1)
        self.assertEqual((1, 1), res)

        # Confirm there are still 2 incomplete allocations after one
        # interation of the migration.
        res = _get_allocs_with_no_consumer_relationship(self.ctx)
        self.assertEqual(2, len(res))