问题遇到的现象和发生背景
本人在学习django+vue搭建测试平台,现在遇到一个问题就是在本地所有功能都ok,但是部署在华为云耀云服务器上后,在调用httprunner运行时一直超时,说下我的部署过程详细在这边文章写过:https://blog.csdn.net/qq_45499910/article/details/125403870,主要包括django+vue+gunicorn+supervisord+nginx+docker,
问题相关代码,请勿粘贴截图
yaml文件是ok的,已经验证过了
hrunner = HttpRunner(log_level="DEBUG")
hrunner.run(test_case.yaml)
运行结果及报错内容
报错日志
2022-07-01 09:30:39,250 - [INFO] - [msg]开始执行用例...
INFO HttpRunner version: 2.5.7
INFO Start to run testcase: test_case
test_case
INFO POST http://***************:8080/api/test/
DEBUG request kwargs(raw): {'json': {'email': 'xiaoli@gmail.com', 'ip': '127.0.0.1'}, 'verify': True}
DEBUG processed request:
> POST http://***************:8080/api/test/
> kwargs: {'json': {'email': 'xiaoli@gmail.com', 'ip': '127.0.0.1'}, 'verify': True, 'timeout': 120}
E
======================================================================
ERROR: test_0000_000 (httprunner.api.TestSequense)
test_case
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/httprunner/api.py", line 63, in test
test_runner.run_test(test_dict)
File "/usr/local/lib/python3.7/site-packages/httprunner/runner.py", line 379, in run_test
self._run_test(test_dict)
File "/usr/local/lib/python3.7/site-packages/httprunner/runner.py", line 242, in _run_test
**parsed_test_request
File "/usr/local/lib/python3.7/site-packages/httprunner/client.py", line 191, in request
response = self._send_request_safe_mode(method, url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/httprunner/client.py", line 240, in _send_request_safe_mode
return requests.Session.request(self, method, url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 450, in send
timeout=timeout
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 710, in urlopen
chunked=chunked,
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 398, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.7/http/client.py", line 1281, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.7/http/client.py", line 1327, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.7/http/client.py", line 1276, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.7/http/client.py", line 1036, in _send_output
self.send(msg)
File "/usr/local/lib/python3.7/http/client.py", line 976, in send
self.connect()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 205, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 175, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 203, in handle_abort
sys.exit(1)
SystemExit: 1
----------------------------------------------------------------------
Ran 1 test in 30.538s
FAILED (errors=1)
我的解答思路和尝试过的方法
1、服务器配置问题:在容器内直接通过命令行htrun执行yaml时是ok的,所以大概率是调用链中的问题
2、httprunner的1.5.8和2.5.7两个版本都试过了 都存在这个问题;
3、hrun命令行执行和HttpRunner(log_level="DEBUG")类调用run方法,也都试过了,都不行
我想要达到的结果
希望大家帮分析下原因,本人对gunicorn和supervisord不太熟悉,不知道是不是某些配置问题导致