Sergey Nikitin | 0cb4f22 | 2017-02-03 13:16:33 +0400 | [diff] [blame^] | 1 | # 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 | |
| 15 | import time |
| 16 | |
| 17 | from tempest.api.compute import base |
| 18 | from tempest.lib import decorators |
| 19 | |
| 20 | |
| 21 | class ServerDiagnosticsTest(base.BaseV2ComputeAdminTest): |
| 22 | min_microversion = None |
| 23 | max_microversion = '2.47' |
| 24 | |
| 25 | @classmethod |
| 26 | def setup_clients(cls): |
| 27 | super(ServerDiagnosticsTest, cls).setup_clients() |
| 28 | cls.client = cls.os_admin.servers_client |
| 29 | |
| 30 | @decorators.idempotent_id('31ff3486-b8a0-4f56-a6c0-aab460531db3') |
| 31 | def test_get_server_diagnostics(self): |
| 32 | server_id = self.create_test_server(wait_until='ACTIVE')['id'] |
| 33 | diagnostics = self.client.show_server_diagnostics(server_id) |
| 34 | |
| 35 | # NOTE(snikitin): Before microversion 2.48 response data from each |
| 36 | # hypervisor (libvirt, xen, vmware) was different. None of the fields |
| 37 | # were equal. As this test is common for libvirt, xen and vmware CI |
| 38 | # jobs we can't check any field in the response because all fields are |
| 39 | # different. |
| 40 | self.assertNotEmpty(diagnostics) |
| 41 | |
| 42 | |
| 43 | class ServerDiagnosticsV248Test(base.BaseV2ComputeAdminTest): |
| 44 | min_microversion = '2.48' |
| 45 | max_microversion = 'latest' |
| 46 | |
| 47 | @classmethod |
| 48 | def setup_clients(cls): |
| 49 | super(ServerDiagnosticsV248Test, cls).setup_clients() |
| 50 | cls.client = cls.os_admin.servers_client |
| 51 | |
| 52 | @decorators.idempotent_id('64d0d48c-dff1-11e6-bf01-fe55135034f3') |
| 53 | def test_get_server_diagnostics(self): |
| 54 | server_id = self.create_test_server(wait_until='ACTIVE')['id'] |
| 55 | # Response status and filed types will be checked by json schema |
| 56 | self.client.show_server_diagnostics(server_id) |
| 57 | |
| 58 | # NOTE(snikitin): This is a special case for Xen hypervisor. In Xen |
| 59 | # case we're getting diagnostics stats from the RRDs which are updated |
| 60 | # every 5 seconds. It means that diagnostics information may be |
| 61 | # incomplete during first 5 seconds of VM life. In such cases methods |
| 62 | # which get diagnostics stats from Xen may raise exceptions or |
| 63 | # return `NaN` values. Such behavior must be handled correctly. |
| 64 | # Response must contain all diagnostics fields (may be with `None` |
| 65 | # values) and response status must be 200. Line above checks it by |
| 66 | # json schema. |
| 67 | time.sleep(10) |
| 68 | diagnostics = self.client.show_server_diagnostics(server_id) |
| 69 | |
| 70 | # NOTE(snikitin): After 10 seconds diagnostics fields must contain |
| 71 | # not None values. But we will check only "memory_details.maximum" |
| 72 | # field because only this field meets all the following conditions: |
| 73 | # 1) This field may be unset because of Xen 5 seconds timeout. |
| 74 | # 2) This field is present in responses from all three supported |
| 75 | # hypervisors (libvirt, xen, vmware). |
| 76 | self.assertIsNotNone(diagnostics['memory_details']['maximum']) |