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 |
| 22 | from tempest.test import attr |
| 23 | from tempest.test import HTTP_SUCCESS |
| 24 | |
| 25 | |
| 26 | class HealthcheckTest(base.BaseObjectTest): |
| 27 | |
| 28 | @classmethod |
| 29 | def setUpClass(cls): |
| 30 | super(HealthcheckTest, cls).setUpClass() |
| 31 | |
| 32 | # creates a test user. The test user will set its base_url to the Swift |
| 33 | # endpoint and test the healthcheck feature. |
| 34 | cls.data.setup_test_user() |
| 35 | |
| 36 | cls.os_test_user = clients.Manager( |
| 37 | cls.data.test_user, |
| 38 | cls.data.test_password, |
| 39 | cls.data.test_tenant) |
| 40 | |
| 41 | @classmethod |
| 42 | def tearDownClass(cls): |
| 43 | cls.data.teardown_all() |
| 44 | super(HealthcheckTest, cls).tearDownClass() |
| 45 | |
| 46 | def setUp(self): |
| 47 | super(HealthcheckTest, self).setUp() |
| 48 | client = self.os_test_user.account_client |
| 49 | client._set_auth() |
| 50 | |
| 51 | # Turning http://.../v1/foobar into http://.../ |
| 52 | client.base_url = "/".join(client.base_url.split("/")[:-2]) |
| 53 | |
| 54 | def tearDown(self): |
| 55 | # clear the base_url for subsequent requests |
| 56 | self.os_test_user.account_client.base_url = None |
| 57 | super(HealthcheckTest, self).tearDown() |
| 58 | |
| 59 | @attr('gate') |
| 60 | def test_get_healthcheck(self): |
| 61 | |
| 62 | resp, _ = self.os_test_user.account_client.get("healthcheck", {}) |
| 63 | |
| 64 | # The status is expected to be 200 |
| 65 | self.assertIn(int(resp['status']), HTTP_SUCCESS) |