138ac174c4
Passing any CLI arguments to log-api is not possible for the case where it runs under gunicorn server. Gunicorn's argument parsing processes clashes with oslo's. Effectivelly that means that either of them cannot understand the arguments of another. However log-api is capable of being launched under, for example, apache_mod-wsgi. That permits passing oslo CLI arguments. Added simple method that detect the executable that was used to run log-api. If that is not gunicorn, CLI opts will be enabled. Otherwise log-api will print out warning and proceed as it was. Extra: * reworked to use fixtures Change-Id: I6b2fc386aeb823ab735270ffc1d3f7e15985830f
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
# Copyright 2016-2017 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
|
|
# 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 mock
|
|
|
|
from monasca_log_api.monitoring import client
|
|
from monasca_log_api.tests import base
|
|
|
|
|
|
class TestMonitoring(base.BaseTestCase):
|
|
|
|
@mock.patch('monasca_log_api.monitoring.client.monascastatsd')
|
|
def test_should_use_default_dimensions_if_none_specified(self,
|
|
monascastatsd):
|
|
client.get_client()
|
|
|
|
statsd_client = monascastatsd.Client
|
|
|
|
expected_dimensions = client._DEFAULT_DIMENSIONS
|
|
actual_dimensions = statsd_client.call_args[1]['dimensions']
|
|
|
|
self.assertEqual(1, statsd_client.call_count)
|
|
self.assertEqual(expected_dimensions, actual_dimensions)
|
|
|
|
@mock.patch('monasca_log_api.monitoring.client.monascastatsd')
|
|
def test_should_not_override_fixed_dimensions(self,
|
|
monascastatsd):
|
|
dims = {
|
|
'service': 'foo',
|
|
'component': 'bar'
|
|
}
|
|
|
|
client.get_client(dims)
|
|
|
|
statsd_client = monascastatsd.Client
|
|
|
|
expected_dimensions = client._DEFAULT_DIMENSIONS
|
|
actual_dimensions = statsd_client.call_args[1]['dimensions']
|
|
|
|
self.assertEqual(1, statsd_client.call_count)
|
|
self.assertEqual(expected_dimensions, actual_dimensions)
|