当前位置: 首页>>代码示例>>Python>>正文


Python LineBufferFilter.scan_log_buffer方法代码示例

本文整理汇总了Python中util.LineBufferFilter.scan_log_buffer方法的典型用法代码示例。如果您正苦于以下问题:Python LineBufferFilter.scan_log_buffer方法的具体用法?Python LineBufferFilter.scan_log_buffer怎么用?Python LineBufferFilter.scan_log_buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util.LineBufferFilter的用法示例。


在下文中一共展示了LineBufferFilter.scan_log_buffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_if_missing_mesos_leader_entry_is_handled

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_missing_mesos_leader_entry_is_handled(
            self, nginx_class, valid_user_header, dns_server_mock):
        filter_regexp = {
            'Failed to instantiate the resolver': SearchCriteria(0, True),
            'DNS server returned error code': SearchCriteria(1, True),
            '`Mesos Leader` state cache has been successfully updated':
                SearchCriteria(0, True),
        }

        ar = nginx_class()

        with GuardedSubprocess(ar):
            lbf = LineBufferFilter(filter_regexp,
                                   line_buffer=ar.stderr_line_buffer)
            # Unfortunatelly there are upstreams that use `leader.mesos` and
            # removing this entry too early will result in Nginx failing to start.
            # So we need to do it right after nginx starts, but before first
            # cache update.
            time.sleep(1)
            dns_server_mock.remove_dns_entry('leader.mesos.')

            # Now let's trigger the cache update:
            ping_mesos_agent(ar, valid_user_header)

            lbf.scan_log_buffer()

            assert lbf.extra_matches == {}
开发者ID:mjkam,项目名称:dcos,代码行数:29,代码来源:test_cache.py

示例2: test_if_broken_marathon_does_not_break_mesos_cache

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_broken_marathon_does_not_break_mesos_cache(
            self, nginx_class, mocker, superuser_user_header):
        filter_regexp = {
            'Marathon app request failed: invalid response status: 500':
                SearchCriteria(1, True),
            'Mesos state cache has been successfully updated':
                SearchCriteria(1, True),
        }

        # Break marathon
        mocker.send_command(endpoint_id='http://127.0.0.1:8080',
                            func_name='always_bork',
                            aux_data=True)

        ar = nginx_class()

        with GuardedSubprocess(ar):
            lbf = LineBufferFilter(filter_regexp,
                                   timeout=(CACHE_FIRST_POLL_DELAY + 1),
                                   line_buffer=ar.stderr_line_buffer)

            ping_mesos_agent(ar, superuser_user_header)
            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:malnick,项目名称:dcos,代码行数:27,代码来源:test_cache.py

示例3: test_if_default_scheme_is_honoured_by_agent_endpoint

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_default_scheme_is_honoured_by_agent_endpoint(
            self, nginx_class, mocker, valid_user_header):
        filter_regexp = {'Default scheme: https://': SearchCriteria(1, False)}

        ar = nginx_class(default_scheme="https://")
        agent_id = AGENT3_ID
        url_good = ar.make_url_from_path('/agent/{}/blah/blah'.format(agent_id))
        agent_id = AGENT1_ID
        url_bad = ar.make_url_from_path('/agent/{}/blah/blah'.format(agent_id))

        with GuardedSubprocess(ar):
            lbf = LineBufferFilter(filter_regexp,
                                   line_buffer=ar.stderr_line_buffer)

            resp = requests.get(url_bad,
                                allow_redirects=False,
                                headers=valid_user_header)

            assert resp.status_code == 502

            resp = requests.get(url_good,
                                allow_redirects=False,
                                headers=valid_user_header)

            assert resp.status_code == 200
            req_data = resp.json()
            assert req_data['endpoint_id'] == 'https://127.0.0.1:15401'

            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:dcos,项目名称:dcos,代码行数:33,代码来源:test_boot_envvars.py

示例4: test_if_broken_mesos_does_not_break_marathon_cache

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_broken_mesos_does_not_break_marathon_cache(
            self, nginx_class, mocker, superuser_user_header):
        filter_regexp = {
            'Mesos state request failed: invalid response status: 500':
                SearchCriteria(1, True),
            'Marathon apps cache has been successfully updated': SearchCriteria(1, True),
        }

        # Break marathon
        mocker.send_command(endpoint_id='http://127.0.0.2:5050',
                            func_name='always_bork',
                            aux_data=True)

        mocker.send_command(endpoint_id='http://127.0.0.1:8080',
                            func_name='enable_nginx_app')

        ar = nginx_class()
        url = ar.make_url_from_path('/service/nginx-enabled/bar/baz')

        with GuardedSubprocess(ar):
            lbf = LineBufferFilter(filter_regexp,
                                   timeout=(CACHE_FIRST_POLL_DELAY + 1),
                                   line_buffer=ar.stderr_line_buffer)

            resp = requests.get(url,
                                allow_redirects=False,
                                headers=superuser_user_header)
            lbf.scan_log_buffer()

        assert resp.status_code == 200
        req_data = resp.json()
        assert req_data['endpoint_id'] == 'http://127.0.0.1:16001'

        assert lbf.extra_matches == {}
开发者ID:malnick,项目名称:dcos,代码行数:36,代码来源:test_cache.py

示例5: test_upstream_wrong_json

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_upstream_wrong_json(
            self, nginx_class, mocker, superuser_user_header):
        filter_regexp = {
            "Cannot decode Marathon apps JSON: ": SearchCriteria(1, True),
        }

        ar = nginx_class()

        # Set wrong non-json response content
        mocker.send_command(endpoint_id='http://127.0.0.1:8080',
                            func_name='set_encoded_response',
                            aux_data=b"wrong response")

        url = ar.make_url_from_path('/service/nginx-alwaysthere/foo/bar/')
        with GuardedSubprocess(ar):
            # Register Line buffer filter:
            lbf = LineBufferFilter(filter_regexp,
                                   timeout=5,  # Just to give LBF enough time
                                   line_buffer=ar.stderr_line_buffer)

            # Trigger cache update by issuing request:
            resp = requests.get(url,
                                allow_redirects=False,
                                headers=superuser_user_header)
            assert "cache state is invalid" in resp.content.decode('utf-8')
            assert resp.status_code == 503

            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:malnick,项目名称:dcos,代码行数:32,代码来源:test_cache.py

示例6: test_if_mesos_leader_locality_is_resolved

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_mesos_leader_locality_is_resolved(
            self, nginx_class, valid_user_header, dns_server_mock):
        cache_poll_period = 4
        nonlocal_leader_ip = "127.0.0.3"
        local_leader_ip = "127.0.0.2"
        filter_regexp_pre = {
            'Failed to instantiate the resolver': SearchCriteria(0, True),
            'mesos leader is non-local: `{}`'.format(nonlocal_leader_ip):
                SearchCriteria(1, True),
            'Private IP address of the host is unknown, ' +
            'aborting cache-entry creation for mesos leader':
                SearchCriteria(0, True),
            'mesos leader cache has been successfully updated':
                SearchCriteria(1, True),
        }
        filter_regexp_post = {
            'Failed to instantiate the resolver': SearchCriteria(0, True),
            'mesos leader is local': SearchCriteria(1, True),
            'Private IP address of the host is unknown, ' +
            'aborting cache-entry creation for mesos leader':
                SearchCriteria(0, True),
            'mesos leader cache has been successfully updated':
                SearchCriteria(1, True),
        }

        dns_server_mock.set_dns_entry('leader.mesos.', ip=nonlocal_leader_ip)

        ar = nginx_class(cache_poll_period=cache_poll_period, cache_expiration=3)

        with GuardedSubprocess(ar):
            lbf = LineBufferFilter(filter_regexp_pre,
                                   line_buffer=ar.stderr_line_buffer)
            # Just trigger the cache update:
            ping_mesos_agent(ar, valid_user_header)

            lbf.scan_log_buffer()

            assert lbf.extra_matches == {}

            dns_server_mock.set_dns_entry('leader.mesos.', ip=local_leader_ip)

            # First poll (2s) + normal poll interval(4s) < 2 * normal poll
            # interval(4s)
            time.sleep(cache_poll_period * 2)

            lbf = LineBufferFilter(filter_regexp_post,
                                   line_buffer=ar.stderr_line_buffer)
            # Just trigger the cache update:
            ping_mesos_agent(ar, valid_user_header)

            lbf.scan_log_buffer()

            assert lbf.extra_matches == {}
开发者ID:branden,项目名称:dcos,代码行数:55,代码来源:test_cache.py

示例7: test_if_not_defining_the_var_is_handled

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_not_defining_the_var_is_handled(self,
                                                ar_process_without_secret_key):
        # Scanning for the exact log entry is bad, but in this case - can't be
        # avoided.
        filter_regexp = 'SECRET_KEY_FILE_PATH not set.'

        lbf = LineBufferFilter(filter_regexp,
                               line_buffer=ar_process_without_secret_key.stderr_line_buffer)

        lbf.scan_log_buffer()

        assert lbf.all_found is True
开发者ID:dcos,项目名称:adminrouter,代码行数:14,代码来源:test_boot_envvars.py

示例8: test_if_var_pointing_to_empty_file_is_handled

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_var_pointing_to_empty_file_is_handled(self,
                                                      ar_process_without_secret_key):
        # Scanning for the exact log entry is bad, but in this case - can't be
        # avoided.
        filter_regexp = 'Secret key not set or empty string.'

        lbf = LineBufferFilter(filter_regexp,
                               line_buffer=ar_process_without_secret_key.stderr_line_buffer)

        lbf.scan_log_buffer()

        assert lbf.all_found is True
开发者ID:dcos,项目名称:adminrouter,代码行数:14,代码来源:test_boot_envvars.py

示例9: test_if_broken_marathon_causes_marathon_cache_to_expire_and_requests_to_fail

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_broken_marathon_causes_marathon_cache_to_expire_and_requests_to_fail(
            self, nginx_class, mocker, superuser_user_header):
        filter_regexp = {
            'Marathon app request failed: invalid response status: 500':
                SearchCriteria(1, False),
            'Mesos state cache has been successfully updated':
                SearchCriteria(2, False),
            'Cache entry `svcapps` is too old, aborting request':
                SearchCriteria(1, True),
        }

        ar = nginx_class(cache_max_age_soft_limit=3,
                         cache_max_age_hard_limit=4,
                         cache_expiration=2,
                         cache_poll_period=3,
                         )

        mocker.send_command(endpoint_id='http://127.0.0.1:8080',
                            func_name='enable_nginx_app')
        url = ar.make_url_from_path('/service/nginx-enabled/foo/bar/')

        with GuardedSubprocess(ar):
            # Register Line buffer filter:
            lbf = LineBufferFilter(filter_regexp,
                                   timeout=5,  # Just to give LBF enough time
                                   line_buffer=ar.stderr_line_buffer)

            # Trigger cache update by issuing request:
            resp = requests.get(url,
                                allow_redirects=False,
                                headers=superuser_user_header)
            assert resp.status_code == 200

            # Break marathon
            mocker.send_command(endpoint_id='http://127.0.0.1:8080',
                                func_name='always_bork',
                                aux_data=True)

            # Wait for the cache to be old enough to be discarded by AR:
            # cache_max_age_hard_limit + 1s for good measure
            # must be more than cache_poll_period
            time.sleep(4 + 1)

            # Perform the main/test request:
            resp = requests.get(url,
                                allow_redirects=False,
                                headers=superuser_user_header)
            assert resp.status_code == 503

            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:malnick,项目名称:dcos,代码行数:54,代码来源:test_cache.py

示例10: test_if_absent_var_is_handled

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_absent_var_is_handled(self, nginx_class, mocker):
        filter_regexp = {
            'Local Mesos Master IP: unknown': SearchCriteria(1, True),
        }
        ar = nginx_class(host_ip=None)

        with GuardedSubprocess(ar):
            lbf = LineBufferFilter(filter_regexp,
                                   line_buffer=ar.stderr_line_buffer)

            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:dcos,项目名称:dcos,代码行数:15,代码来源:test_boot_envvars.py

示例11: test_if_var_is_honoured

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_var_is_honoured(self, valid_ip, nginx_class, mocker):
        filter_regexp = {
            'Local Mesos Master IP: {}'.format(valid_ip): SearchCriteria(1, True),
        }
        ar = nginx_class(host_ip=valid_ip)

        with GuardedSubprocess(ar):
            lbf = LineBufferFilter(filter_regexp,
                                   line_buffer=ar.stderr_line_buffer)

            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:dcos,项目名称:dcos,代码行数:15,代码来源:test_boot_envvars.py

示例12: _assert_filter_regexp_for_invalid_app

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def _assert_filter_regexp_for_invalid_app(
            self,
            filter_regexp,
            app,
            nginx_class,
            mocker,
            auth_headers,
            ):
        """Helper method that will assert if provided regexp filter is found
        in nginx logs for given apps response from Marathon upstream endpoint.

        Arguments:
            filter_regexp (dict): Filter definition where key is the message
                looked up in logs and value is SearchCriteria definition
            app (dict): App that upstream endpoint should respond with
            nginx_class (Nginx): Nginx process fixture
            mocker (Mocker): Mocker fixture
            auth_header (dict): Headers that should be passed to Nginx in the
                request
        """
        ar = nginx_class()

        mocker.send_command(endpoint_id='http://127.0.0.1:8080',
                            func_name='set_apps_response',
                            aux_data={"apps": [app]})

        # Remove all entries for mesos frameworks and mesos_dns so that
        # we test only the information in Marathon
        mocker.send_command(endpoint_id='http://127.0.0.2:5050',
                            func_name='set_frameworks_response',
                            aux_data=[])
        mocker.send_command(endpoint_id='http://127.0.0.1:8123',
                            func_name='set_srv_response',
                            aux_data=[])

        url = ar.make_url_from_path('/service/scheduler-alwaysthere/foo/bar/')
        with GuardedSubprocess(ar):
            # Register Line buffer filter:
            lbf = LineBufferFilter(filter_regexp,
                                   timeout=5,  # Just to give LBF enough time
                                   line_buffer=ar.stderr_line_buffer)

            # Trigger cache update by issuing request:
            resp = requests.get(url,
                                allow_redirects=False,
                                headers=auth_headers)
            assert resp.status_code == 404

            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:mjkam,项目名称:dcos,代码行数:53,代码来源:test_cache.py

示例13: test_if_var_pointing_to_empty_file_is_handled

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_var_pointing_to_empty_file_is_handled(
            self, nginx_class, role, empty_file):
        # Scanning for the exact log entry is bad, but in this case - can't be
        # avoided.
        filter_regexp = {'Auth token verification key not set': SearchCriteria(1, False)}
        ar = nginx_class(role=role, auth_token_verification_key_file_path=empty_file)

        with GuardedSubprocess(ar):
            lbf = LineBufferFilter(filter_regexp,
                                   line_buffer=ar.stderr_line_buffer)

            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:dcos,项目名称:dcos,代码行数:16,代码来源:test_boot_envvars.py

示例14: test_if_temp_marathon_borkage_does_not_disrupt_caching

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_temp_marathon_borkage_does_not_disrupt_caching(
            self, nginx_class, mocker, valid_user_header):
        filter_regexp = {
            'Marathon app request failed: invalid response status: 500':
                SearchCriteria(1, False),
            'Mesos state cache has been successfully updated':
                SearchCriteria(2, False),
            'Cache entry `svcapps` is stale':
                SearchCriteria(1, True),
        }

        ar = nginx_class(cache_max_age_soft_limit=3,
                         cache_max_age_hard_limit=1200,
                         cache_expiration=2,
                         cache_poll_period=3,
                         )

        url = ar.make_url_from_path('/service/scheduler-alwaysthere/foo/bar/')

        with GuardedSubprocess(ar):
            # Register Line buffer filter:
            lbf = LineBufferFilter(filter_regexp,
                                   timeout=5,  # Just to give LBF enough time
                                   line_buffer=ar.stderr_line_buffer)

            # Trigger cache update by issuing request:
            resp = requests.get(url,
                                allow_redirects=False,
                                headers=valid_user_header)
            assert resp.status_code == 200

            # Break marathon
            mocker.send_command(endpoint_id='http://127.0.0.1:8080',
                                func_name='always_bork',
                                aux_data=True)

            # Wait for the cache to be old enough to be considered stale by AR:
            # cache_max_age_soft_limit + 1s for a good measure
            time.sleep(3 + 1)

            # Perform the main/test request:
            resp = requests.get(url,
                                allow_redirects=False,
                                headers=valid_user_header)
            assert resp.status_code == 200

            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:mjkam,项目名称:dcos,代码行数:51,代码来源:test_cache.py

示例15: test_if_var_is_verified

# 需要导入模块: from util import LineBufferFilter [as 别名]
# 或者: from util.LineBufferFilter import scan_log_buffer [as 别名]
    def test_if_var_is_verified(self, invalid_ip, nginx_class, mocker):
        filter_regexp = {
            'Local Mesos Master IP: unknown': SearchCriteria(1, True),
            'HOST_IP var is not a valid ipv4: {}'.format(invalid_ip):
                SearchCriteria(1, True),
        }
        ar = nginx_class(host_ip=invalid_ip)

        with GuardedSubprocess(ar):
            lbf = LineBufferFilter(filter_regexp,
                                   line_buffer=ar.stderr_line_buffer)

            lbf.scan_log_buffer()

        assert lbf.extra_matches == {}
开发者ID:dcos,项目名称:dcos,代码行数:17,代码来源:test_boot_envvars.py


注:本文中的util.LineBufferFilter.scan_log_buffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。