OpenStack Compute (Nova)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.6KB

  1. # Copyright (C) 2015 Red Hat, Inc
  2. # All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. from nova.tests.functional.api import client
  16. from nova.tests.functional.libvirt import base
  17. from nova.tests.unit.virt.libvirt import fakelibvirt
  18. class RealTimeServersTest(base.ServersTestBase):
  19. ADDITIONAL_FILTERS = ['NUMATopologyFilter']
  20. def setUp(self):
  21. super(RealTimeServersTest, self).setUp()
  22. self.flags(sysinfo_serial='none', group='libvirt')
  23. def test_no_dedicated_cpu(self):
  24. flavor = self._create_flavor(extra_spec={'hw:cpu_realtime': 'yes'})
  25. server = self._build_server(flavor)
  26. # Cannot set realtime policy in a non dedicated cpu pinning policy
  27. self.assertRaises(
  28. client.OpenStackApiException,
  29. self.api.post_server, {'server': server})
  30. def test_no_realtime_mask(self):
  31. flavor = self._create_flavor(extra_spec={
  32. 'hw:cpu_realtime': 'yes', 'hw:cpu_policy': 'dedicated'})
  33. server = self._build_server(flavor)
  34. # Cannot set realtime policy if not vcpus mask defined
  35. self.assertRaises(
  36. client.OpenStackApiException,
  37. self.api.post_server, {'server': server})
  38. def test_success(self):
  39. self.flags(cpu_dedicated_set='0-7', group='compute')
  40. host_info = fakelibvirt.HostInfo(cpu_nodes=2, cpu_sockets=1,
  41. cpu_cores=2, cpu_threads=2,
  42. kB_mem=15740000)
  43. fake_connection = self._get_connection(host_info=host_info)
  44. self.mock_conn.return_value = fake_connection
  45. self.compute = self.start_service('compute', host='test_compute0')
  46. flavor = self._create_flavor(extra_spec={
  47. 'hw:cpu_realtime': 'yes',
  48. 'hw:cpu_policy': 'dedicated',
  49. 'hw:cpu_realtime_mask': '^1'})
  50. server = self._build_server(flavor)
  51. created = self.api.post_server({'server': server})
  52. instance = self._wait_for_state_change(created, 'ACTIVE')
  53. self._delete_server(instance)