Tempest plugin for os-win project.
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.

optional_feature.py 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Copyright 2017 Cloudbase Solutions SRL
  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. import testtools
  16. from oswin_tempest_plugin import config
  17. from oswin_tempest_plugin.tests._mixins import resize
  18. CONF = config.CONF
  19. class _OptionalFeatureMixin(resize._ResizeUtils):
  20. """Optional Feature mixin.
  21. Some features are optional, and can be turned on / off through resize
  22. with certain flavors.
  23. Examples of optional features: vNUMA, QoS, SR-IOV, PCI passthrough,
  24. RemoteFX.
  25. This mixin will add the following tests:
  26. * test_feature
  27. * test_resize_add_feature
  28. * test_resize_remove_feature
  29. The resize tests will create a new instance, resize it to a new flavor (
  30. turning on / off the optional feature), and check its network
  31. connectivity.
  32. The optional feature flavor is based on the test suite's configured
  33. _FLAVOR_REF (typically compute.flavor_ref or compute.flavor_ref_alt),
  34. with some updates. For example, if the vNUMA configuration is to be tested,
  35. the new flavor would contain the flavor extra_spec {'hw:numa_nodes="1"'}.
  36. Keep in mind that all the extra_spec keys and values have to be strings.
  37. """
  38. # NOTE(claudiub): This flavor dict contains updates to the base flavor
  39. # tempest is configured with. For example, _FEATURE_FLAVOR can be:
  40. # _BIGGER_FLAVOR = {'extra_specs': {'hw:numa_nodes': 1'}}
  41. # which means a flavor having that flavor extra_spec will be created, and
  42. # a created instance will be resize to / from it.
  43. _FEATURE_FLAVOR = {}
  44. def _get_flavor_ref(self):
  45. """Gets a new optional feature flavor ref.
  46. Creates a new flavor based on the test suite's configured _FLAVOR_REF,
  47. with some updates specific to the optional feature.
  48. :returns: nova flavor ID.
  49. """
  50. # NOTE(claudiub): Unless explicitly given another flavor,
  51. # _create_server will call this method to get the flavor reference
  52. # needed to spawn a new instance. Thus, any other test will spawn
  53. # instances with this Optional Feature.
  54. new_flavor = self._create_new_flavor(self._FLAVOR_REF,
  55. self._FEATURE_FLAVOR)
  56. return new_flavor['id']
  57. def test_feature(self):
  58. server_tuple = self._create_server()
  59. self._check_scenario(server_tuple)
  60. @testtools.skipUnless(CONF.compute_feature_enabled.resize,
  61. 'Resize is not available.')
  62. def test_resize_add_feature(self):
  63. new_flavor = self._get_flavor_ref()
  64. self._check_resize(new_flavor, self._FLAVOR_REF)
  65. @testtools.skipUnless(CONF.compute_feature_enabled.resize,
  66. 'Resize is not available.')
  67. def test_resize_remove_feature(self):
  68. new_flavor = self._get_flavor_ref()
  69. self._check_resize(self._FLAVOR_REF, new_flavor)