Moving unversioned endpoints

Healthcheck and Versions are endpoints
that are not available under either
v2.0 and v3.0. Changes includes:
- package reornigazation
- tests adjustments

Change-Id: Ib6bdd4695b5ebf57f27fc8bd311222bb216dd470
This commit is contained in:
Tomasz Trębski 2016-03-04 10:08:00 +01:00
parent 06ed858396
commit 81413d4d52
17 changed files with 41 additions and 35 deletions

View File

@ -7,10 +7,10 @@ debug=False
# Dispatchers to be loaded to serve restful APIs
[dispatcher]
logs = monasca_log_api.v2.reference.logs:Logs
logs_v3 = monasca_log_api.v3.reference.logs:Logs
versions = monasca_log_api.v2.reference.versions:Versions
healthchecks = monasca_log_api.v2.reference.healthchecks:HealthChecks
logs = monasca_log_api.reference.v2.logs:Logs
logs_v3 = monasca_log_api.reference.v3.logs:Logs
versions = monasca_log_api.reference.versions:Versions
healthchecks = monasca_log_api.reference.healthchecks:HealthChecks
[service]
max_log_size = 1048576

View File

@ -1,4 +1,4 @@
# Copyright 2015 FUJITSU LIMITED
# Copyright 2016 FUJITSU LIMITED
#
# 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

View File

@ -1,5 +1,5 @@
# Copyright 2015 kornicameister@gmail.com
# Copyright 2015 FUJITSU LIMITED
# Copyright 2016 FUJITSU LIMITED
#
# 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
@ -18,7 +18,7 @@ from monasca_common.rest import utils as rest_utils
from oslo_config import cfg
from oslo_log import log
from monasca_log_api.v2.common import service
from monasca_log_api.reference.v2.common import service
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@ -1,5 +1,5 @@
# Copyright 2015 kornicameister@gmail.com
# Copyright 2015 FUJITSU LIMITED
# Copyright 2016 FUJITSU LIMITED
#
# 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

View File

@ -1,5 +1,5 @@
# Copyright 2015 kornicameister@gmail.com
# Copyright 2015 FUJITSU LIMITED
# Copyright 2016 FUJITSU LIMITED
#
# 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
@ -17,8 +17,8 @@ import falcon
from monasca_log_api.api import headers
from monasca_log_api.api import logs_api
from monasca_log_api.v2.common import log_publisher
from monasca_log_api.v2.common import service
from monasca_log_api.reference.v2.common import log_publisher
from monasca_log_api.reference.v2.common import service
# TODO(idea) perhaps add it as pipeline call right before API, seems generic

View File

@ -22,8 +22,8 @@ from oslo_utils import timeutils
from monasca_log_api.api import exceptions
from monasca_log_api.api import headers
from monasca_log_api.api import logs_v3_api
from monasca_log_api.v2.common import service
from monasca_log_api.v3.reference import helpers
from monasca_log_api.reference.v2.common import service
from monasca_log_api.reference.v3.common import helpers
LOG = log.getLogger(__name__)

View File

@ -1,5 +1,5 @@
# Copyright 2015 kornicameister@gmail.com
# Copyright 2015 FUJITSU LIMITED
# Copyright 2016 FUJITSU LIMITED
#
# 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

View File

@ -1,4 +1,4 @@
# Copyright 2015 FUJITSU LIMITED
# Copyright 2016 FUJITSU LIMITED
#
# 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
@ -18,8 +18,8 @@ import mock
import simplejson as json
from monasca_log_api.healthcheck import kafka_check as healthcheck
from monasca_log_api.reference import healthchecks
from monasca_log_api.tests import base
from monasca_log_api.v2.reference import healthchecks
ENDPOINT = '/healthcheck'

View File

@ -1,5 +1,5 @@
# Copyright 2015 kornicameister@gmail.com
# Copyright 2015 FUJITSU LIMITED
# Copyright 2016 FUJITSU LIMITED
#
# 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
@ -15,15 +15,14 @@
import datetime
import random
import ujson
import unittest
from falcon import testing
import mock
import ujson
from monasca_log_api.reference.v2.common import log_publisher
from monasca_log_api.tests import base
from monasca_log_api.v2.common import log_publisher
EPOCH_START = datetime.datetime(1970, 1, 1)
@ -108,7 +107,7 @@ class TestSendMessage(testing.TestBase):
self.conf = base.mock_config(self)
return super(TestSendMessage, self).setUp()
@mock.patch('monasca_log_api.v2.common.log_publisher.producer'
@mock.patch('monasca_log_api.reference.v2.common.log_publisher.producer'
'.KafkaProducer')
def test_should_not_send_empty_message(self, _):
instance = log_publisher.LogPublisher()
@ -168,7 +167,7 @@ class TestSendMessage(testing.TestBase):
instance.send_message,
tmp_message)
@mock.patch('monasca_log_api.v2.common.log_publisher.producer'
@mock.patch('monasca_log_api.reference.v2.common.log_publisher.producer'
'.KafkaProducer')
def test_should_send_message(self, _):
instance = log_publisher.LogPublisher()
@ -207,7 +206,7 @@ class TestSendMessage(testing.TestBase):
ujson.dumps(msg),
expected_key)
@mock.patch('monasca_log_api.v2.common.log_publisher.producer'
@mock.patch('monasca_log_api.reference.v2.common.log_publisher.producer'
'.KafkaProducer')
def test_should_send_message_multiple_topics(self, _):
topics = ['logs', 'analyzer', 'tester']

View File

@ -1,5 +1,5 @@
# Copyright 2015 kornicameister@gmail.com
# Copyright 2015 FUJITSU LIMITED
# Copyright 2016 FUJITSU LIMITED
#
# 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
@ -20,8 +20,8 @@ import mock
from monasca_log_api.api import exceptions as log_api_exceptions
from monasca_log_api.api import headers
from monasca_log_api.api import logs_api
from monasca_log_api.reference.v2 import logs
from monasca_log_api.tests import base
from monasca_log_api.v2.reference import logs
class TestLogs(testing.TestBase):
@ -44,8 +44,10 @@ class TestLogs(testing.TestBase):
)
self.assertEqual(falcon.HTTP_403, self.srmock.status)
@mock.patch('monasca_log_api.v2.common.service.LogCreator')
@mock.patch('monasca_log_api.v2.common.log_publisher.LogPublisher')
@mock.patch('monasca_log_api.reference.v2.common.service.LogCreator')
@mock.patch(
'monasca_log_api.reference.v2.common.log_publisher.LogPublisher'
)
def test_should_pass_empty_cross_tenant_id_wrong_role(self,
log_creator,
kafka_publisher):
@ -68,8 +70,10 @@ class TestLogs(testing.TestBase):
self.assertEqual(1, log_creator.new_log.call_count)
self.assertEqual(1, log_creator.new_log_envelope.call_count)
@mock.patch('monasca_log_api.v2.common.service.LogCreator')
@mock.patch('monasca_log_api.v2.common.log_publisher.LogPublisher')
@mock.patch('monasca_log_api.reference.v2.common.service.LogCreator')
@mock.patch(
'monasca_log_api.reference.v2.common.log_publisher.LogPublisher'
)
def test_should_pass_empty_cross_tenant_id_ok_role(self,
log_creator,
kafka_publisher):
@ -92,8 +96,10 @@ class TestLogs(testing.TestBase):
self.assertEqual(1, log_creator.new_log.call_count)
self.assertEqual(1, log_creator.new_log_envelope.call_count)
@mock.patch('monasca_log_api.v2.common.service.LogCreator')
@mock.patch('monasca_log_api.v2.common.log_publisher.LogPublisher')
@mock.patch('monasca_log_api.reference.v2.common.service.LogCreator')
@mock.patch(
'monasca_log_api.reference.v2.common.log_publisher.LogPublisher'
)
def test_should_pass_delegate_cross_tenant_id_ok_role(self,
log_creator,
log_publisher):
@ -117,7 +123,7 @@ class TestLogs(testing.TestBase):
self.assertEqual(1, log_creator.new_log.call_count)
self.assertEqual(1, log_creator.new_log_envelope.call_count)
@mock.patch('monasca_log_api.v2.common.service.rest_utils')
@mock.patch('monasca_common.rest.utils')
def test_should_fail_empty_dimensions_delegate(self, rest_utils):
rest_utils.read_body.return_value = True
@ -129,7 +135,8 @@ class TestLogs(testing.TestBase):
headers.X_DIMENSIONS.name: '',
'Content-Type': 'application/json',
'Content-Length': '0'
}
},
body='{"message":"test"}'
)
self.assertEqual(log_api_exceptions.HTTP_422, self.srmock.status)

View File

@ -1,5 +1,5 @@
# Copyright 2015 kornicameister@gmail.com
# Copyright 2015 FUJITSU LIMITED
# Copyright 2016 FUJITSU LIMITED
#
# 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
@ -24,8 +24,8 @@ import mock
from monasca_log_api.api import exceptions
from monasca_log_api.api import logs_api
from monasca_log_api.reference.v2.common import service as common_service
from monasca_log_api.tests import base
from monasca_log_api.v2.common import service as common_service
class IsDelegate(unittest.TestCase):