Beispiel #1
0
 def test_concurrent_request_server_group_members_over_quota(self):
     """Recreate scenario for the bug where we create 3 servers in the
     same group but in separate requests. The NoopConductorFixture is used
     to ensure the instances are not created in the nova cell database which
     means the quota check will have to rely on counting group members using
     build requests from the API DB.
     """
     # These aren't really concurrent requests, but we can simulate that
     # by using NoopConductorFixture.
     self.useFixture(nova_fixtures.NoopConductorFixture())
     for x in range(3):
         server_req = self._build_server(networks='none')
         hints = {'group': self.created_group['id']}
         # This should result in a 403 response on the 3rd server.
         if x == 2:
             self.api.api_post(
                 '/servers',
                 {'server': server_req, 'os:scheduler_hints': hints},
                 check_response_status=[403])
         else:
             self.api.post_server(
                 {'server': server_req, 'os:scheduler_hints': hints})
     # There should only be two servers created which are both members of
     # the same group.
     servers = self.api.get_servers(detail=False)
     self.assertEqual(2, len(servers))
     group = self.api.api_get(
         '/os-server-groups/%s' %
         self.created_group['id']).body['server_group']
     self.assertEqual(2, len(group['members']))
Beispiel #2
0
    def setUp(self):
        super(ServersPreSchedulingTestCase, self).setUp()
        fake_image.stub_out_image_service(self)
        self.useFixture(policy_fixture.RealPolicyFixture())
        self.useFixture(nova_fixtures.NoopConductorFixture())
        api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
            api_version='v2.1'))

        self.api = api_fixture.api
        self.api.microversion = 'latest'
Beispiel #3
0
    def setUp(self):
        super(ServersPreSchedulingTestCase, self).setUp()
        fake_image.stub_out_image_service(self)
        self.useFixture(policy_fixture.RealPolicyFixture())
        self.useFixture(nova_fixtures.NoopConductorFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))

        self.api = api_fixture.api
        self.api.microversion = 'latest'
        self.useFixture(
            nova_fixtures.SingleCellSimple(instances_created=False))
    def setUp(self):
        super(ServersPreSchedulingTestCase, self).setUp()
        self.useFixture(policy_fixture.RealPolicyFixture())
        self.useFixture(nova_fixtures.NoopConductorFixture())
        self.glance = self.useFixture(nova_fixtures.GlanceFixture(self))
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(func_fixtures.PlacementFixture())
        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))

        self.api = api_fixture.api
        self.api.microversion = 'latest'
        self.useFixture(
            nova_fixtures.SingleCellSimple(instances_created=False))
Beispiel #5
0
    def setUp(self):
        super(TestServerUpdate, self).setUp()
        self.useFixture(nova_fixtures.RealPolicyFixture())
        self.useFixture(nova_fixtures.NeutronFixture(self))
        self.useFixture(nova_fixtures.GlanceFixture(self))
        # Simulate requests coming in before the instance is scheduled by
        # using a no-op for conductor build_instances
        self.useFixture(nova_fixtures.NoopConductorFixture())
        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))

        self.api = api_fixture.api

        self.useFixture(nova_fixtures.CastAsCallFixture(self))

        self.image_id = self.api.get_images()[0]['id']
        self.flavor_id = self.api.get_flavors()[0]['id']
Beispiel #6
0
    def test_boot_from_volume_10_servers_255_volumes_2_images(self):
        """Create 10 servers with 255 BDMs each using the same image for 200
        of the BDMs and another image for 55 other BDMs. This is a bit silly
        but it just shows that it's possible and there is no rate limiting
        involved in this type of very heavy request.
        """
        # We only care about API performance in this test case so stub out
        # conductor to not do anything.
        self.useFixture(nova_fixtures.NoopConductorFixture())
        # NOTE(gibi): Do not use 'c905cedb-7281-47e4-8a62-f26bc5fc4c77' image
        # as that is defined with a separate kernel image, leading to one extra
        # call to nova.image.api.API.get from compute.api
        # _handle_kernel_and_ramdisk()
        image1 = 'a2459075-d96c-40d5-893e-577ff92e721c'
        image2 = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
        server = self._build_minimal_create_server_request(
            self.api, 'test_boot_from_volume_10_servers_255_volumes_2_images')
        server.pop('imageRef')
        server['min_count'] = 10
        bdms = []
        # Create 200 BDMs using image1 and 55 using image2.
        for boot_index in range(255):
            image_uuid = image2 if boot_index >= 200 else image1
            bdms.append({
                'source_type': 'image',
                'destination_type': 'volume',
                'delete_on_termination': True,
                'volume_size': 1,
                'boot_index': boot_index,
                'uuid': image_uuid
            })
        server['block_device_mapping_v2'] = bdms

        # Wrap the image service get method to check how many times it was
        # called.
        with mock.patch('nova.image.api.API.get',
                        wraps=self.image_service.show) as mock_image_get:
            self.api.post_server({'server': server})
            # Assert that there was caching of the GET /v2/images/{image_id}
            # calls. The expected total in this case is 3: one for validating
            # the root BDM image, one for image1 and one for image2 during bdm
            # validation - only the latter two cases use a cache.
            self.assertEqual(3, mock_image_get.call_count)
Beispiel #7
0
    def setUp(self):
        super(TestServerUpdate, self).setUp()
        self.useFixture(policy_fixture.RealPolicyFixture())
        # Simulate requests coming in before the instance is scheduled by
        # using a no-op for conductor build_instances
        self.useFixture(nova_fixtures.NoopConductorFixture())
        api_fixture = self.useFixture(
            nova_fixtures.OSAPIFixture(api_version='v2.1'))

        self.api = api_fixture.api

        # the image fake backend needed for image discovery
        nova.tests.unit.image.fake.stub_out_image_service(self)

        self.useFixture(cast_as_call.CastAsCall(self.stubs))
        self.addCleanup(nova.tests.unit.image.fake.FakeImageService_reset)

        self.image_id = self.api.get_images()[0]['id']
        self.flavor_id = self.api.get_flavors()[0]['id']
Beispiel #8
0
 def test_api_not_called(self, mock_wait):
     self.useFixture(fixtures.NoopConductorFixture())
     conductor.API().wait_until_ready()
     self.assertFalse(mock_wait.called)
Beispiel #9
0
 def test_task_api_not_called(self, mock_resize):
     self.useFixture(fixtures.NoopConductorFixture())
     conductor.ComputeTaskAPI().resize_instance()
     self.assertFalse(mock_resize.called)