Exemple #1
0
    def south_fixture(self, mocker):
        def cat_get():
            config = _TEST_CONFIG
            config['plugin']['value'] = config['plugin']['default']
            return config

        mocker.patch.object(FoglampMicroservice, "__init__", return_value=None)

        south_server = Server()
        south_server._storage = MagicMock(spec=StorageClient)

        attrs = {
            'create_configuration_category.return_value': None,
            'get_configuration_category.return_value': cat_get(),
            'register_interest.return_value': {
                'id': 1234,
                'message': 'all ok'
            }
        }
        south_server._core_microservice_management_client = Mock()
        south_server._core_microservice_management_client.configure_mock(
            **attrs)

        mocker.patch.object(south_server, '_name', 'test')

        ingest_start = mocker.patch.object(Ingest,
                                           'start',
                                           return_value=mock_coro())
        log_exception = mocker.patch.object(South._LOGGER, "exception")
        log_info = mocker.patch.object(South._LOGGER, "info")

        return cat_get, south_server, ingest_start, log_exception, log_info
Exemple #2
0
    async def test_change_filter(self, loop, mocker):
        # GIVEN
        _FILTER_TEST_CONFIG = {
            'plugin': {
                'description': 'Python module name of the plugin to load',
                'type': 'string',
                'default': 'test',
                'value': 'test'
            },
            "filter": {
                "type": "JSON",
                "default": "{\"pipeline\": [\"scale\"]}",
                "value": "{\"pipeline\": [\"scale\"]}",
                "description": "Filter pipeline",
            },
        }
        mocker.patch.object(FoglampMicroservice, "__init__", return_value=None)

        south_server = Server()
        south_server._storage = MagicMock(spec=StorageClientAsync)

        attrs = {
            'create_configuration_category.return_value': None,
            'get_configuration_category.return_value': _FILTER_TEST_CONFIG,
            'register_interest.return_value': {
                'id': 1234,
                'message': 'all ok'
            }
        }
        south_server._core_microservice_management_client = Mock()
        south_server._core_microservice_management_client.configure_mock(
            **attrs)

        mocker.patch.object(south_server, '_name', 'test')

        ingest_start = mocker.patch.object(Ingest,
                                           'start',
                                           return_value=mock_coro())
        log_warning = mocker.patch.object(South._LOGGER, "warning")

        mock_plugin = MagicMock()
        attrs = copy.deepcopy(plugin_attrs)
        attrs['plugin_info.return_value']['mode'] = 'async'
        mock_plugin.configure_mock(**attrs)
        sys.modules['foglamp.plugins.south.test.test'] = mock_plugin

        # WHEN
        await south_server._start(loop)
        await asyncio.sleep(.5)
        await south_server.change(request=None)

        # THEN
        assert 1 == log_warning.call_count
        calls = [
            call(
                'South Service [%s] does not support the use of a filter pipeline.',
                'test')
        ]
        log_warning.assert_has_calls(calls, any_order=True)
    async def test__start_async_plugin_bad_plugin_value(self, mocker, loop):
        # GIVEN
        mocker.patch.object(FoglampMicroservice, "__init__", return_value=None)

        south_server = Server()
        south_server._storage = MagicMock(spec=StorageClientAsync)

        mocker.patch.object(south_server, '_name', 'test')
        mocker.patch.object(south_server, '_stop', return_value=mock_coro())

        log_exception = mocker.patch.object(South._LOGGER, "exception")

        # WHEN
        await south_server._start(loop)
        await asyncio.sleep(.5)

        # THEN
        log_exception.assert_called_with('Failed to initialize plugin {}'.format(south_server._name))
Exemple #4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# FOGLAMP_BEGIN
# See: http://foglamp.readthedocs.io/
# FOGLAMP_END
"""South Service starter"""

from foglamp.services.south.server import Server
from foglamp.common import logger

__author__ = "Terris Linenbach, Vaibhav Singhal"
__copyright__ = "Copyright (c) 2017 OSIsoft, LLC"
__license__ = "Apache 2.0"
__version__ = "${VERSION}"

if __name__ == '__main__':
    _logger = logger.setup("South")
    south_server = Server()
    south_server.run()