reportportal / agent-python-pytest

Framework integration with PyTest
Apache License 2.0
94 stars 102 forks source link

How do we know if connection fails on startup #293

Closed vfalco02 closed 2 years ago

vfalco02 commented 2 years ago

It is my understanding that if there is an issue connecting to RP, then it will fail silently and continue on with the tests.

My question is - how do we know if a failure occurs (obviously without checking RP)?

I want to have most of the arguments get configured by the end user, but not pushed up to our repository. So I need users to be able to easily know if they did not enter rp_uuid or something else.

HardNorth commented 2 years ago

By error in logs / output. Something like:

agent-python-pytest/venv/bin/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/_jb_pytest_runner.py --path tests -- -m "not command_skip" --reportportal
Testing started at 2:17 PM ...
Launching pytest with arguments -m not command_skip --reportportal tests --no-header --no-summary -q in examples-python/pytest

HTTPSConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /api/v1/project/default_personal (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))
Traceback (most recent call last):
  File "agent-python-pytest/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "agent-python-pytest/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "agent-python-pytest/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 976, in _validate_conn
    conn.connect()
  File "agent-python-pytest/venv/lib/python3.7/site-packages/urllib3/connection.py", line 370, in connect
    ssl_context=context,
  File "agent-python-pytest/venv/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 377, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 423, in wrap_socket
    session=session
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 870, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "agent-python-pytest/venv/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "agent-python-pytest/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "agent-python-pytest/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /api/v1/project/default_personal (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "agent-python-pytest/pytest_reportportal/plugin.py", line 39, in check_connection
    verify=aconf.rp_verify_ssl)
  File "agent-python-pytest/venv/lib/python3.7/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "agent-python-pytest/venv/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "agent-python-pytest/venv/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "agent-python-pytest/venv/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "agent-python-pytest/venv/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /api/v1/project/default_personal (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))
vfalco02 commented 2 years ago

@HardNorth I'm not seeing anything in the log. I've stopped on this line and confirm there should be a logged line https://github.com/reportportal/agent-python-pytest/blob/325f56938009ae89ae7739410adcccc0d94f2cde/pytest_reportportal/plugin.py#L170 , but nothing in my console. When investigating the log object I see level=0 and also that parent RootLogger is set to WARNING.

Apologies as I'm still wrapping my head around python logging, but what is going on?

HardNorth commented 2 years ago

This line logs it: https://github.com/reportportal/agent-python-pytest/blob/325f56938009ae89ae7739410adcccc0d94f2cde/pytest_reportportal/plugin.py#L42