示例#1
0
    def test_proxy_loop(self):
        skip_alert(
            r'socket.*failed',
            r'accept.*failed',
            r'new connections are not accepted',
        )
        self.conf(
            {
                "listeners": {
                    "*:7080": {"pass": "******"},
                    "*:7081": {"pass": "******"},
                    "*:7082": {"pass": "******"},
                },
                "routes": [{"action": {"proxy": "http://127.0.0.1:7082"}}],
                "applications": {
                    "mirror": {
                        "type": "python",
                        "processes": {"spare": 0},
                        "path": option.test_dir + "/python/mirror",
                        "working_directory": option.test_dir + "/python/mirror",
                        "module": "wsgi",
                    },
                },
            }
        )

        self.get_http10(no_recv=True)
        self.get_http10(read_timeout=1)
示例#2
0
    def test_asgi_application__loading_error(self):
        skip_alert(r'Python failed to import module "blah"')

        self.load('empty')

        assert 'success' in self.conf('"blah"', 'applications/empty/module')

        assert self.get()['status'] == 503, 'loading error'
示例#3
0
    def test_respawn_router(self):
        pid = self.pid_by_name(self.PATTERN_ROUTER)

        self.kill_pids(pid)
        skip_alert(r'process %s exited on signal 9' % pid)

        assert self.wait_for_process(self.PATTERN_ROUTER) is not None

        self.smoke_test()
示例#4
0
    def test_respawn_application(self):
        pid = self.pid_by_name(self.app_name)

        self.kill_pids(pid)
        skip_alert(r'process %s exited on signal 9' % pid)

        assert self.wait_for_process(self.app_name) is not None

        self.smoke_test()
示例#5
0
    def setup_method(self):
        assert 'success' in self.conf(
            {'http': {
                'websocket': {
                    'keepalive_interval': 0
                }
            }}, 'settings'), 'clear keepalive_interval'

        skip_alert(r'socket close\(\d+\) failed')
示例#6
0
    def test_ruby_application_syntax_error(self):
        skip_alert(
            r'Failed to parse rack script',
            r'syntax error',
            r'new_from_string',
            r'parse_file',
        )
        self.load('syntax_error')

        assert self.get()['status'] == 500, 'syntax error'
示例#7
0
    def test_respawn_controller(self):
        pid = self.pid_by_name(self.PATTERN_CONTROLLER)

        self.kill_pids(pid)
        skip_alert(r'process %s exited on signal 9' % pid)

        assert self.wait_for_process(self.PATTERN_CONTROLLER) is not None

        assert self.get()['status'] == 200

        self.smoke_test()
示例#8
0
    def test_python_application_callable(self):
        skip_alert(r'Python failed to get "blah" from module')
        self.load('callable')

        assert self.get()['status'] == 204, 'default application response'

        self.load('callable', callable="app")

        assert self.get()['status'] == 200, 'callable response'

        self.load('callable', callable="blah")

        assert self.get()['status'] not in [200, 204], 'callable response inv'
示例#9
0
    def test_fallback_proxy_loop(self):
        skip_alert(
            r'open.*/blah/index.html.*failed',
            r'accept.*failed',
            r'socket.*failed',
            r'new connections are not accepted',
        )

        self.action_update(
            {"share": "/blah", "fallback": {"proxy": "http://127.0.0.1:7080"}}
        )
        self.get(no_recv=True)

        assert 'success' in self.conf_delete('listeners/*:7081')
        self.get(read_timeout=1)
示例#10
0
    def test_unprivileged_user_error(self, is_su):
        skip_alert(r'cannot set user "root"', r'failed to apply new conf')
        if is_su:
            pytest.skip('unprivileged tests')

        assert 'error' in self.conf(
            {
                "app": {
                    "type": "external",
                    "processes": 1,
                    "executable": "/app",
                    "user": "******",
                }
            },
            'applications',
        ), 'setting user'
示例#11
0
    def test_tls_application_respawn(self):
        self.load('mirror')

        self.certificate()

        self.conf('1', 'applications/mirror/processes')

        self.add_tls(application='mirror')

        (_, sock) = self.post_ssl(
            headers={
                'Host': 'localhost',
                'Connection': 'keep-alive',
                'Content-Type': 'text/html',
            },
            start=True,
            body='0123456789',
            read_timeout=1,
        )

        app_id = self.findall(r'(\d+)#\d+ "mirror" application started')[0]

        subprocess.call(['kill', '-9', app_id])

        skip_alert(r'process %s exited on signal 9' % app_id)

        self.wait_for_record(
            re.compile(
                r' (?!' + app_id + r'#)(\d+)#\d+ "mirror" application started'
            )
        )

        resp = self.post_ssl(
            headers={
                'Host': 'localhost',
                'Connection': 'close',
                'Content-Type': 'text/html',
            },
            sock=sock,
            body='0123456789',
        )

        assert resp['status'] == 200, 'application respawn status'
        assert resp['body'] == '0123456789', 'application respawn body'
示例#12
0
 def test_java_conf_error(self, temp_dir):
     skip_alert(
         r'realpath.*failed',
         r'failed to apply new conf',
         r'application setup failed',
     )
     assert 'error' in self.conf(
         {
             "listeners": {"*:7080": {"pass": "******"}},
             "applications": {
                 "app": {
                     "type": "java",
                     "processes": 1,
                     "working_directory": option.test_dir + "/java/empty",
                     "webapp": temp_dir + "/java",
                     "unit_jars": temp_dir + "/no_such_dir",
                 }
             },
         }
     ), 'conf error'
示例#13
0
    def test_python_application_callable(self):
        skip_alert(r'Python failed to get "blah" from module')
        self.load('callable')

        assert self.get()['status'] == 204, 'default application response'

        assert 'success' in self.conf('"app"',
                                      'applications/callable/callable')

        assert self.get()['status'] == 200, 'callable response'

        assert 'success' in self.conf('"blah"',
                                      'applications/callable/callable')

        assert self.get()['status'] not in [200, 204], 'callable response inv'

        assert 'success' in self.conf('"app"',
                                      'applications/callable/callable')

        assert self.get()['status'] == 200, 'callable response 2'

        assert 'success' in self.conf_delete('applications/callable/callable')

        assert self.get()['status'] == 204, 'default response 2'
示例#14
0
    def test_perl_application_syntax_error(self):
        skip_alert(r'PSGI: Failed to parse script')
        self.load('syntax_error')

        assert self.get()['status'] == 500, 'syntax error'
示例#15
0
    def test_asgi_keepalive_reconfigure(self):
        skip_alert(
            r'pthread_mutex.+failed',
            r'failed to apply',
            r'process \d+ exited on signal',
        )
        self.load('mirror')

        assert self.get()['status'] == 200, 'init'

        body = '0123456789'
        conns = 3
        socks = []

        for i in range(conns):
            (resp, sock) = self.post(
                headers={
                    'Host': 'localhost',
                    'Connection': 'keep-alive',
                    'Content-Type': 'text/html',
                },
                start=True,
                body=body,
                read_timeout=1,
            )

            assert resp['body'] == body, 'keep-alive open'
            assert 'success' in self.conf(
                str(i + 1), 'applications/mirror/processes'), 'reconfigure'

            socks.append(sock)

        for i in range(conns):
            (resp, sock) = self.post(
                headers={
                    'Host': 'localhost',
                    'Connection': 'keep-alive',
                    'Content-Type': 'text/html',
                },
                start=True,
                sock=socks[i],
                body=body,
                read_timeout=1,
            )

            assert resp['body'] == body, 'keep-alive request'
            assert 'success' in self.conf(
                str(i + 1), 'applications/mirror/processes'), 'reconfigure 2'

        for i in range(conns):
            resp = self.post(
                headers={
                    'Host': 'localhost',
                    'Connection': 'close',
                    'Content-Type': 'text/html',
                },
                sock=socks[i],
                body=body,
            )

            assert resp['body'] == body, 'keep-alive close'
            assert 'success' in self.conf(
                str(i + 1), 'applications/mirror/processes'), 'reconfigure 3'
示例#16
0
    def test_python_application_syntax_error(self):
        skip_alert(r'Python failed to import module "wsgi"')
        self.load('syntax_error')

        assert self.get()['status'] == 500, 'syntax error'
示例#17
0
    def test_asgi_application_loading_error(self):
        skip_alert(r'Python failed to import module "blah"')

        self.load('empty', module="blah")

        assert self.get()['status'] == 503, 'loading error'