blob: 7bbdd1ed2af7d2a606a0153d37e00bcca2661980 [file] [log] [blame]
Joe H. Rahmec54a8632013-10-15 10:09:10 +02001# 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
20from tempest.api.object_storage import base
21from tempest import clients
Daisuke Moritad206d3b2013-12-06 15:18:04 +090022from tempest.common import custom_matchers
Joe H. Rahmec54a8632013-10-15 10:09:10 +020023from tempest.test import attr
24from tempest.test import HTTP_SUCCESS
25
26
27class 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 Moritad206d3b2013-12-06 15:18:04 +090067
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())