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) res = consumer_obj.create_incomplete_consumers(self.ctx, 10) self.assertEqual((2, 2), res) self._check_incomplete_consumers(self.ctx) res = consumer_obj.create_incomplete_consumers(self.ctx, 10) self.assertEqual((0, 0), res)
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 AllocationList.get_all_by_consumer_id() and # AllocationList.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 # AllocationList.get_all_by_consumer_id() with that consumer UUID. This # should create the remaining missing consumer record "inline" in the # AllocationList.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 # AllocationList.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] rp_obj.AllocationList.get_all_by_consumer_id(self.ctx, still_missing) # There should still be a single missing consumer relationship. Let's # grab that and call AllocationList.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) rp_obj.AllocationList.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)
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 AllocationList.get_all_by_consumer_id() and # AllocationList.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 # AllocationList.get_all_by_consumer_id() with that consumer UUID. This # should create the remaining missing consumer record "inline" in the # AllocationList.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 # AllocationList.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] rp_obj.AllocationList.get_all_by_consumer_id(self.ctx, still_missing) # There should still be a single missing consumer relationship. Let's # grab that and call AllocationList.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) rp_obj.AllocationList.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)
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) rp_obj.AllocationList.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)