Add API tests for health & ping endpoints

Change-Id: Iebfcf16fae66ec3012734eb4ecb1a487850a13bd
This commit is contained in:
Malini Kamalambal 2014-08-25 13:56:59 -04:00
parent 0e160a42c4
commit 15539c3e09
6 changed files with 74 additions and 9 deletions

View File

@ -24,7 +24,7 @@ if "CAFE_CONFIG_FILE_PATH" not in os.environ:
"etc/api.conf")
if "CAFE_ROOT_LOG_PATH" not in os.environ:
os.environ["CAFE_ROOT_LOG_PATH"] = os.path.join(tests_dir, '/logs')
os.environ["CAFE_ROOT_LOG_PATH"] = os.path.join(tests_dir, 'logs')
if "CAFE_TEST_LOG_PATH" not in os.environ:
os.environ["CAFE_TEST_LOG_PATH"] = os.path.join(tests_dir, '/logs')
os.environ["CAFE_TEST_LOG_PATH"] = os.path.join(tests_dir, 'logs')

View File

@ -66,8 +66,8 @@ class TestBase(fixtures.BaseTestFixture):
conf = cfg.ConfigOpts()
conf(project='poppy', prog='poppy', args=[],
default_config_files=[config_file])
poppy_server = server.CDNServer()
poppy_server.start(conf)
cls.poppy_server = server.CDNServer()
cls.poppy_server.start(conf)
def assertSchema(self, response_json, expected_schema):
"""Verify response schema aligns with the expected schema."""
@ -79,4 +79,6 @@ class TestBase(fixtures.BaseTestFixture):
@classmethod
def tearDownClass(cls):
"""Deletes the added resources."""
if cls.server_config.run_server:
cls.poppy_server.stop()
super(TestBase, cls).tearDownClass()

View File

View File

@ -0,0 +1,42 @@
# Copyright (c) 2014 Rackspace, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import ddt
from tests.api import base
@ddt.ddt
class TestHealth(base.TestBase):
"""Tests for Health & Ping endpoints."""
def setUp(self):
super(TestHealth, self).setUp()
def test_health(self):
self.skipTest('Endpoint Not Implemented')
resp = self.client.check_health()
self.assertEqual(resp.status_code, 204)
def test_ping(self):
resp = self.client.ping()
self.assertEqual(resp.status_code, 204)
def tearDown(self):
super(TestHealth, self).tearDown()

View File

@ -64,7 +64,6 @@ class PoppyClient(client.AutoMarshallingHTTPClient):
self.auth_token = auth_token
self.default_headers['X-Auth-Token'] = auth_token
self.default_headers['Content-Type'] = 'application/json'
self.default_headers['Accept'] = 'application/json'
self.serialize = serialize_format
self.deserialize_format = deserialize_format
@ -79,7 +78,7 @@ class PoppyClient(client.AutoMarshallingHTTPClient):
PUT
services/{service_name}
"""
url = '{0}/services/{1}'.format(self.url, service_name)
url = '{0}/v1.0/services/{1}'.format(self.url, service_name)
request_object = requests.CreateService(domain_list=domain_list,
origin_list=origin_list,
caching_list=caching_list)
@ -96,7 +95,7 @@ class PoppyClient(client.AutoMarshallingHTTPClient):
services/{service_name}
"""
url = '{0}/services/{1}'.format(self.url, service_name)
url = '{0}/v1.0/services/{1}'.format(self.url, service_name)
return self.request('GET', url)
def delete_service(self, service_name):
@ -107,5 +106,27 @@ class PoppyClient(client.AutoMarshallingHTTPClient):
services/{service_name}
"""
url = '{0}/services/{1}'.format(self.url, service_name)
url = '{0}/v1.0/services/{1}'.format(self.url, service_name)
return self.request('DELETE', url)
def check_health(self):
"""Check Health of the application
:return: Response Object containing response code 204
GET
health
"""
url = '{0}/v1.0/health'.format(self.url)
return self.request('GET', url)
def ping(self):
"""Ping the server
:return: Response Object containing response code 204
GET
ping
"""
url = '{0}/v1.0/ping'.format(self.url)
return self.request('GET', url)

View File

@ -27,7 +27,7 @@ log_file = poppy.log
[drivers]
# Transport driver module (e.g., falcon, pecan)
transport = falcon
transport = pecan
# Manager driver module (e.g. default)
manager = default