Exemplo n.º 1
0
    def test__update_quotas_fn(self):
        tenant_id = "fake_tenant"
        quotas = {
            "metadata_items": 10,
            "key_pairs": 10,
            "injected_file_content_bytes": 1024,
            "injected_file_path_bytes": 1024,
            "ram": 5120,
            "instances": 10,
            "injected_files": 10,
            "cores": 10,
        }
        fake_nova = fakes.FakeNovaClient()
        fake_nova.quotas.update = mock.MagicMock(return_value=quotas)
        fake_clients = fakes.FakeClients()
        fake_clients._nova = fake_nova
        scenario = utils.QuotasScenario(admin_clients=fake_clients)
        scenario._generate_quota_values = mock.MagicMock(return_value=quotas)

        mock_quota = mock.Mock(return_value=quotas)

        result = scenario._update_quotas("nova",
                                         tenant_id,
                                         quota_update_fn=mock_quota)

        self.assertEqual(quotas, result)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "quotas.update_quotas")
Exemplo n.º 2
0
    def test__update_quotas(self):
        tenant_id = 'fake_tenant'
        quotas = {
                'metadata_items': 10,
                'key_pairs': 10,
                'injected_file_content_bytes': 1024,
                'injected_file_path_bytes': 1024,
                'ram': 5120,
                'instances': 10,
                'injected_files': 10,
                'cores': 10,
        }
        fake_nova = fakes.FakeNovaClient()
        fake_nova.quotas.update = mock.MagicMock(return_value=quotas)
        fake_clients = fakes.FakeClients()
        fake_clients._nova = fake_nova
        scenario = utils.QuotasScenario(admin_clients=fake_clients)
        scenario._generate_quota_values = mock.MagicMock(return_value=quotas)

        result = scenario._update_quotas('nova', tenant_id)

        self.assertEqual(quotas, result)
        fake_nova.quotas.update.assert_called_once_with(tenant_id, **quotas)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       'quotas.update_quotas')
Exemplo n.º 3
0
 def test__generate_quota_values_neutron(self):
     max_quota = 1024
     scenario = utils.QuotasScenario(admin_clients=fakes.FakeClients())
     quotas = scenario._generate_quota_values(max_quota, "neutron")
     for v in six.itervalues(quotas):
         for v1 in six.itervalues(v):
             for v2 in six.itervalues(v1):
                 self.assertTrue(-1 <= v2 <= max_quota)
Exemplo n.º 4
0
    def test__delete_quotas(self):
        tenant_id = "fake_tenant"
        fake_nova = fakes.FakeNovaClient()
        fake_nova.quotas.delete = mock.MagicMock()
        fake_clients = fakes.FakeClients()
        fake_clients._nova = fake_nova
        scenario = utils.QuotasScenario(admin_clients=fake_clients)

        scenario._delete_quotas("nova", tenant_id)

        fake_nova.quotas.delete.assert_called_once_with(tenant_id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "quotas.delete_quotas")
Exemplo n.º 5
0
 def test__generate_quota_values_cinder(self):
     max_quota = 1024
     scenario = utils.QuotasScenario(admin_clients=fakes.FakeClients())
     quotas = scenario._generate_quota_values(max_quota, "cinder")
     for k, v in six.iteritems(quotas):
         self.assertTrue(-1 <= v <= max_quota)