예제 #1
0
    def start_server(self, url):
        """
        :param url: tested server
        :return:
        """
        port = pickup_port()
        self._process = Popen([
            'python', 'zerotest/cli.py', 'server', '-p',
            str(port), '-f', self.data_file, url
        ])
        self.port = port
        test_count = 10
        while test_count > 0:
            try:
                if self.running:
                    r = requests.get(urljoin(self.url, '/count'))
                    if r.status_code == 200:
                        return
            except requests.exceptions.ConnectionError:
                pass

            print("wait proxy start,", test_count)
            time.sleep(1)
            test_count -= 1
        else:
            self.shutdown()
            raise RuntimeError("start zerotest proxy timeout")
예제 #2
0
    def start_mock_server(self):
        port = pickup_port()
        self.start_daemon('127.0.0.1', port)
        test_count = 10
        while test_count > 0:
            try:
                if self.running:
                    r = requests.get(urljoin(self.url, '/count'))
                    if r.status_code == 200:
                        return

                    print("wait server start, response", r.status_code, r.text)
            except requests.exceptions.ConnectionError:
                pass

            time.sleep(1)
            test_count -= 1
        else:
            self.shutdown()
            raise RuntimeError("start mock server timeout")
예제 #3
0
    def start_mock_server(self):
        port = pickup_port()
        self.start_daemon('127.0.0.1', port)
        test_count = 10
        while test_count > 0:
            try:
                if self.running:
                    r = requests.get(urljoin(self.url, '/count'))
                    if r.status_code == 200:
                        return

                    print("wait server start, response", r.status_code, r.text)
            except requests.exceptions.ConnectionError:
                pass

            time.sleep(1)
            test_count -= 1
        else:
            self.shutdown()
            raise RuntimeError("start mock server timeout")
예제 #4
0
    def start_server(self, url):
        """
        :param url: tested server
        :return:
        """
        port = pickup_port()
        self._process = Popen(['python', 'zerotest/cli.py', 'server', '-p', str(port), '-f', self.data_file, url])
        self.port = port
        test_count = 10
        while test_count > 0:
            try:
                if self.running:
                    r = requests.get(urljoin(self.url, '/count'))
                    if r.status_code == 200:
                        return
            except requests.exceptions.ConnectionError:
                pass

            print("wait proxy start,", test_count)
            time.sleep(1)
            test_count -= 1
        else:
            self.shutdown()
            raise RuntimeError("start zerotest proxy timeout")