Joe H. Rahme | c54a863 | 2013-10-15 10:09:10 +0200 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright (C) 2013 eNovance SAS <licensing@enovance.com> |
| 4 | # |
| 5 | # Author: Joe H. Rahme <joe.hakim.rahme@enovance.com> |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 8 | # not use this file except in compliance with the License. You may obtain |
| 9 | # a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 16 | # License for the specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | |
| 19 | |
| 20 | from tempest.api.object_storage import base |
| 21 | from tempest import clients |
Daisuke Morita | d206d3b | 2013-12-06 15:18:04 +0900 | [diff] [blame] | 22 | from tempest.common import custom_matchers |
Joe H. Rahme | c54a863 | 2013-10-15 10:09:10 +0200 | [diff] [blame] | 23 | from tempest.test import attr |
| 24 | from tempest.test import HTTP_SUCCESS |
| 25 | |
| 26 | |
| 27 | class HealthcheckTest(base.BaseObjectTest): |
| 28 | |
| 29 | @classmethod |
| 30 | def setUpClass(cls): |
| 31 | super(HealthcheckTest, cls).setUpClass() |
| 32 | |
| 33 | # creates a test user. The test user will set its base_url to the Swift |
| 34 | # endpoint and test the healthcheck feature. |
| 35 | cls.data.setup_test_user() |
| 36 | |
| 37 | cls.os_test_user = clients.Manager( |
| 38 | cls.data.test_user, |
| 39 | cls.data.test_password, |
| 40 | cls.data.test_tenant) |
| 41 | |
| 42 | @classmethod |
| 43 | def tearDownClass(cls): |
| 44 | cls.data.teardown_all() |
| 45 | super(HealthcheckTest, cls).tearDownClass() |
| 46 | |
| 47 | def setUp(self): |
| 48 | super(HealthcheckTest, self).setUp() |
| 49 | client = self.os_test_user.account_client |
| 50 | client._set_auth() |
| 51 | |
| 52 | # Turning http://.../v1/foobar into http://.../ |
| 53 | client.base_url = "/".join(client.base_url.split("/")[:-2]) |
| 54 | |
| 55 | def tearDown(self): |
| 56 | # clear the base_url for subsequent requests |
| 57 | self.os_test_user.account_client.base_url = None |
| 58 | super(HealthcheckTest, self).tearDown() |
| 59 | |
| 60 | @attr('gate') |
| 61 | def test_get_healthcheck(self): |
| 62 | |
| 63 | resp, _ = self.os_test_user.account_client.get("healthcheck", {}) |
| 64 | |
| 65 | # The status is expected to be 200 |
| 66 | self.assertIn(int(resp['status']), HTTP_SUCCESS) |
Daisuke Morita | d206d3b | 2013-12-06 15:18:04 +0900 | [diff] [blame] | 67 | |
| 68 | # The target of the request is not any Swift resource. Therefore, the |
| 69 | # existence of response header is checked without a custom matcher. |
| 70 | self.assertIn('content-length', resp) |
| 71 | self.assertIn('content-type', resp) |
| 72 | self.assertIn('x-trans-id', resp) |
| 73 | self.assertIn('date', resp) |
| 74 | # Check only the format of common headers with custom matcher |
| 75 | self.assertThat(resp, custom_matchers.AreAllWellFormatted()) |