timeouterror:[errno 110]连接定时超出API测试
我正在尝试在Python中运行Python进行API测试。该代码在Pycharm中正常工作,但在Gitlab CI中不正常。它显示
给定的设置获取路由API端点为/api/tourist/26#step/stepimplementation.py:15 当我们将获取http状态请求发送到API#步骤/stepimplementation.py:21 Trackback(最近的最新电话): 文件“/usr/local/lib/python3.10/site-packages/urllib3/connection.py”,第174行,in _new_conn conn = connection.create_connection( 文件“/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py”,第95行,在create_connection中 提高错误 文件“/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py”,第85行,在create_connection中 袜子。连接(SA) TimeOuterRor:[ERRNO 110]连接时机
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 358, in connect
self.sock = conn = self._new_conn()
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 179, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f9936df5150>, 'Connection to kyc.api.prev.validatis.de timed out. (connect timeout=None)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 440, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='kyc.api.prev.validatis.de', port=443): Max retries exceeded with url: /validatis/v1.16.0 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f9936df5150>, 'Connection to ---------- timed out. (connect timeout=None)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/behave/model.py", line 1329, in run
match.run(runner.context)
File "/usr/local/lib/python3.10/site-packages/behave/matchers.py", line 98, in run
self.func(context, *args, **kwargs)
File "steps/stepImplementation.py", line 23, in step_impl
context.response = requests.get(context.url)
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 507, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='kyc.api.prev.validatis.de', port=443): Max retries exceeded with url: ------ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f9936df5150>, 'Connection to ----------- timed out. (connect timeout=None)'))
Then The valid response of status code be 200 # None
gitlab yml文件
映像:“ python:3.10”
tre fres_script:
- python -version
- pip install -r install -r unigess.txt
阶段: - 测试
python_behave_tests:
stage: test
script:
- cd features
- behave TestApi.feature --no-capture
- behave GetApiOperationModeStatus.feature --no-capture
是我的代码还是YML文件或Gitlab CI的问题。但是我的代码在当地环境中起作用。
I am trying to run python behave feature file in python for API testing. The code works fine in Pycharm but not in Gitlab CI. It shows
Given Set Get Route api endpoint as /api/Tourist/26 # steps/stepImplementation.py:15
When we send GET HTTP Status request to api # steps/stepImplementation.py:21
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 358, in connect
self.sock = conn = self._new_conn()
File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 179, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f9936df5150>, 'Connection to kyc.api.prev.validatis.de timed out. (connect timeout=None)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 440, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='kyc.api.prev.validatis.de', port=443): Max retries exceeded with url: /validatis/v1.16.0 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f9936df5150>, 'Connection to ---------- timed out. (connect timeout=None)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/behave/model.py", line 1329, in run
match.run(runner.context)
File "/usr/local/lib/python3.10/site-packages/behave/matchers.py", line 98, in run
self.func(context, *args, **kwargs)
File "steps/stepImplementation.py", line 23, in step_impl
context.response = requests.get(context.url)
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 507, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='kyc.api.prev.validatis.de', port=443): Max retries exceeded with url: ------ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f9936df5150>, 'Connection to ----------- timed out. (connect timeout=None)'))
Then The valid response of status code be 200 # None
Gitlab yml file
image: "python:3.10"
before_script:
- python --version
- pip install -r requirements.txt
stages:
- test
python_behave_tests:
stage: test
script:
- cd features
- behave TestApi.feature --no-capture
- behave GetApiOperationModeStatus.feature --no-capture
Is it the problem with my code or with the yml file or gitlab CI. But my code works in local environment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论