Resource optimization service for OpenStack.
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.

test_service.py 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # -*- encoding: utf-8 -*-
  2. # Copyright (c) 2016 Servionica
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain 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,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  13. # implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. from __future__ import unicode_literals
  17. from tempest.lib import decorators
  18. from watcher_tempest_plugin.tests.api.admin import base
  19. class TestShowListService(base.BaseInfraOptimTest):
  20. """Tests for services"""
  21. DECISION_ENGINE = "watcher-decision-engine"
  22. APPLIER = "watcher-applier"
  23. @classmethod
  24. def resource_setup(cls):
  25. super(TestShowListService, cls).resource_setup()
  26. def assert_expected(self, expected, actual,
  27. keys=('created_at', 'updated_at', 'deleted_at')):
  28. super(TestShowListService, self).assert_expected(
  29. expected, actual, keys)
  30. @decorators.attr(type='smoke')
  31. def test_show_service(self):
  32. _, body = self.client.list_services()
  33. self.assertIn('services', body)
  34. services = body['services']
  35. self.assertIn(self.DECISION_ENGINE,
  36. [i['name'] for i in body['services']])
  37. service_id = filter(lambda x: self.DECISION_ENGINE == x['name'],
  38. services)[0]['id']
  39. _, service = self.client.show_service(service_id)
  40. self.assertEqual(self.DECISION_ENGINE, service['name'])
  41. self.assertIn("host", service.keys())
  42. self.assertIn("last_seen_up", service.keys())
  43. self.assertIn("status", service.keys())
  44. @decorators.attr(type='smoke')
  45. def test_show_service_with_links(self):
  46. _, body = self.client.list_services()
  47. self.assertIn('services', body)
  48. services = body['services']
  49. self.assertIn(self.DECISION_ENGINE,
  50. [i['name'] for i in body['services']])
  51. service_id = filter(lambda x: self.DECISION_ENGINE == x['name'],
  52. services)[0]['id']
  53. _, service = self.client.show_service(service_id)
  54. self.assertIn('links', service.keys())
  55. self.assertEqual(2, len(service['links']))
  56. self.assertIn(str(service['id']),
  57. service['links'][0]['href'])
  58. @decorators.attr(type="smoke")
  59. def test_list_services(self):
  60. _, body = self.client.list_services()
  61. self.assertIn('services', body)
  62. services = body['services']
  63. self.assertIn(self.DECISION_ENGINE,
  64. [i['name'] for i in body['services']])
  65. for service in services:
  66. self.assertTrue(
  67. all(val is not None for key, val in service.items()
  68. if key in ['id', 'name', 'host', 'status',
  69. 'last_seen_up']))
  70. # Verify self links.
  71. for service in body['services']:
  72. self.validate_self_link('services', service['id'],
  73. service['links'][0]['href'])