blob: d855a6280583af1e8941500051f12f2bf9aacec8 [file] [log] [blame]
Sergey Nikitin0cb4f222017-02-03 13:16:33 +04001# Copyright 2017 Mirantis Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import time
16
17from tempest.api.compute import base
18from tempest.lib import decorators
19
20
21class ServerDiagnosticsTest(base.BaseV2ComputeAdminTest):
zhufl27f410a2020-08-13 15:27:59 +080022 """Test server diagnostics with compute microversion less than 2.48"""
23
Sergey Nikitin0cb4f222017-02-03 13:16:33 +040024 min_microversion = None
25 max_microversion = '2.47'
26
27 @classmethod
28 def setup_clients(cls):
29 super(ServerDiagnosticsTest, cls).setup_clients()
30 cls.client = cls.os_admin.servers_client
31
32 @decorators.idempotent_id('31ff3486-b8a0-4f56-a6c0-aab460531db3')
33 def test_get_server_diagnostics(self):
zhufl27f410a2020-08-13 15:27:59 +080034 """Test getting server diagnostics"""
Sergey Nikitin0cb4f222017-02-03 13:16:33 +040035 server_id = self.create_test_server(wait_until='ACTIVE')['id']
36 diagnostics = self.client.show_server_diagnostics(server_id)
37
38 # NOTE(snikitin): Before microversion 2.48 response data from each
39 # hypervisor (libvirt, xen, vmware) was different. None of the fields
40 # were equal. As this test is common for libvirt, xen and vmware CI
41 # jobs we can't check any field in the response because all fields are
42 # different.
43 self.assertNotEmpty(diagnostics)
44
45
46class ServerDiagnosticsV248Test(base.BaseV2ComputeAdminTest):
zhufl27f410a2020-08-13 15:27:59 +080047 """Test server diagnostics with compute microversion greater than 2.47"""
48
Sergey Nikitin0cb4f222017-02-03 13:16:33 +040049 min_microversion = '2.48'
50 max_microversion = 'latest'
51
52 @classmethod
53 def setup_clients(cls):
54 super(ServerDiagnosticsV248Test, cls).setup_clients()
55 cls.client = cls.os_admin.servers_client
56
57 @decorators.idempotent_id('64d0d48c-dff1-11e6-bf01-fe55135034f3')
58 def test_get_server_diagnostics(self):
zhufl27f410a2020-08-13 15:27:59 +080059 """Test getting server diagnostics"""
Sergey Nikitin0cb4f222017-02-03 13:16:33 +040060 server_id = self.create_test_server(wait_until='ACTIVE')['id']
61 # Response status and filed types will be checked by json schema
62 self.client.show_server_diagnostics(server_id)
63
64 # NOTE(snikitin): This is a special case for Xen hypervisor. In Xen
65 # case we're getting diagnostics stats from the RRDs which are updated
66 # every 5 seconds. It means that diagnostics information may be
67 # incomplete during first 5 seconds of VM life. In such cases methods
68 # which get diagnostics stats from Xen may raise exceptions or
69 # return `NaN` values. Such behavior must be handled correctly.
70 # Response must contain all diagnostics fields (may be with `None`
71 # values) and response status must be 200. Line above checks it by
72 # json schema.
73 time.sleep(10)
74 diagnostics = self.client.show_server_diagnostics(server_id)
75
76 # NOTE(snikitin): After 10 seconds diagnostics fields must contain
77 # not None values. But we will check only "memory_details.maximum"
78 # field because only this field meets all the following conditions:
79 # 1) This field may be unset because of Xen 5 seconds timeout.
80 # 2) This field is present in responses from all three supported
81 # hypervisors (libvirt, xen, vmware).
82 self.assertIsNotNone(diagnostics['memory_details']['maximum'])