reportportal/client-Python

rp_ignore_errors = True flag is not working

ajinkyapande opened this issue · 6 comments

Hello,

When report portal server is not reachable then my job is failing, even if i have added rp_ignore_errors = True in my pytest ini file .

pytest.ini

{code}
[pytest]

rp_uuid = XXXXXX
rp_endpoint = http://XXXX:8080
rp_project = XXX
rp_launch = default_launcher
rp_ignore_errors = True
rp_hierarchy_dirs = True

Error

NodeXXXXXXX::XXXXXX
 Fail to take screen-shot: Invalid response: Expecting value: line 1 column 1 (char 0): Bad Gateway
 INTERNALERROR> Traceback (most recent call last):
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 119, in _get_json
 INTERNALERROR>     return response.json()
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 898, in json
 INTERNALERROR>     return complexjson.loads(self.text, **kwargs)
 INTERNALERROR>   File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
 INTERNALERROR>     return _default_decoder.decode(s)
 INTERNALERROR>   File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
 INTERNALERROR>     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
 INTERNALERROR>   File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
 INTERNALERROR>     raise JSONDecodeError("Expecting value", s, err.value) from None
 INTERNALERROR> json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
 INTERNALERROR> 
 INTERNALERROR> During handling of the above exception, another exception occurred:
 INTERNALERROR> 
 INTERNALERROR> Traceback (most recent call last):
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/_pytest/main.py", line 197, in wrap_session
 INTERNALERROR>     session.exitstatus = doit(config, session) or 0
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/_pytest/main.py", line 247, in _main
 INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/hooks.py", line 286, in __call__
 INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/manager.py", line 93, in _hookexec
 INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/manager.py", line 87, in <lambda>
 INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 208, in _multicall
 INTERNALERROR>     return outcome.get_result()
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 80, in get_result
 INTERNALERROR>     raise ex[1].with_traceback(ex[2])
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 187, in _multicall
 INTERNALERROR>     res = hook_impl.function(*args)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/_pytest/main.py", line 271, in pytest_runtestloop
 INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/hooks.py", line 286, in __call__
 INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/manager.py", line 93, in _hookexec
 INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/manager.py", line 87, in <lambda>
 INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 203, in _multicall
 INTERNALERROR>     gen.send(outcome)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pytest_reportportal/listener.py", line 47, in pytest_runtest_protocol
 INTERNALERROR>     item, item_id, self.result or 'SKIPPED', self.issue or None)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/pytest_reportportal/service.py", line 282, in finish_pytest_item
 INTERNALERROR>     self.rp.finish_test_item(**fta_rq)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 347, in finish_test_item
 INTERNALERROR>     return _get_msg(r)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 80, in _get_msg
 INTERNALERROR>     return _get_data(response)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 93, in _get_data
 INTERNALERROR>     data = _get_json(response)
 INTERNALERROR>   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 124, in _get_json
 INTERNALERROR>     "Invalid response: {0}: {1}".format(value_error, response.text))
 INTERNALERROR> reportportal_client.errors.ResponseError: Invalid response: Expecting value: line 1 column 1 (char 0): Bad Gateway
 Traceback (most recent call last):
   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 119, in _get_json
     return response.json()
   File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 898, in json
     return complexjson.loads(self.text, **kwargs)
   File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
     return _default_decoder.decode(s)
   File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
   File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
     raise JSONDecodeError("Expecting value", s, err.value) from None
 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
 During handling of the above exception, another exception occurred:
 Traceback (most recent call last):
   File "/usr/local/bin/pytest", line 11, in <module>
     sys.exit(main())
   File "/usr/local/lib/python3.6/dist-packages/_pytest/config/__init__.py", line 93, in main
     config=config
   File "/usr/local/lib/python3.6/dist-packages/pluggy/hooks.py", line 286, in __call__
     return self._hookexec(self, self.get_hookimpls(), kwargs)
   File "/usr/local/lib/python3.6/dist-packages/pluggy/manager.py", line 93, in _hookexec
     return self._inner_hookexec(hook, methods, kwargs)
   File "/usr/local/lib/python3.6/dist-packages/pluggy/manager.py", line 87, in <lambda>
     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 208, in _multicall
     return outcome.get_result()
   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 80, in get_result
     raise ex[1].with_traceback(ex[2])
   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 187, in _multicall
     res = hook_impl.function(*args)
   File "/usr/local/lib/python3.6/dist-packages/_pytest/main.py", line 240, in pytest_cmdline_main
     return wrap_session(config, _main)
   File "/usr/local/lib/python3.6/dist-packages/_pytest/main.py", line 233, in wrap_session
     session=session, exitstatus=session.exitstatus
   File "/usr/local/lib/python3.6/dist-packages/pluggy/hooks.py", line 286, in __call__
     return self._hookexec(self, self.get_hookimpls(), kwargs)
   File "/usr/local/lib/python3.6/dist-packages/pluggy/manager.py", line 93, in _hookexec
     return self._inner_hookexec(hook, methods, kwargs)
   File "/usr/local/lib/python3.6/dist-packages/pluggy/manager.py", line 87, in <lambda>
     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 203, in _multicall
     gen.send(outcome)
   File "/app/tests/fixtures/api_fixtures.py", line 133, in pytest_sessionfinish
     return (yield).get_result()
   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 80, in get_result
     raise ex[1].with_traceback(ex[2])
   File "/usr/local/lib/python3.6/dist-packages/pluggy/callers.py", line 187, in _multicall
     res = hook_impl.function(*args)
   File "/usr/local/lib/python3.6/dist-packages/pytest_reportportal/plugin.py", line 96, in pytest_sessionfinish
     session.config.py_test_service.finish_launch()
   File "/usr/local/lib/python3.6/dist-packages/pytest_reportportal/service.py", line 310, in finish_launch
     self.rp.finish_launch(**fl_rq)
   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 241, in finish_launch
     return _get_msg(r)
   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 80, in _get_msg
     return _get_data(response)
   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 93, in _get_data
     data = _get_json(response)
   File "/usr/local/lib/python3.6/dist-packages/reportportal_client/service.py", line 124, in _get_json
     "Invalid response: {0}: {1}".format(value_error, response.text))
 reportportal_client.errors.ResponseError: Invalid response: Expecting value: line 1 column 1 (char 0): Bad Gateway
 ERROR: Job failed: exit code 1

rp_ignore_errors flag works at the beginning of the service startup. If we have any connectivity, RP availability issues, then it will skip reporting silently. If your instance of RP server becomes unavailable within the testing process, you will get all the errors visible.

@iivanou thanks for the explanation. But this should not fail my original job ?
Remaining tests are not getting executed after this exception :(

What behavior do you expect from the application side if some of the services it talks to become unavailable?

g-bon commented

Hi, I also think it's a reasonable request from @ajinkyapande. Maybe RP is not the the only reporting system used in a project.

For instance the user configures a pytest run to also produce a junit xml report of the results using --junitxml, in addition to sending the results to pytest.

In that case if rp_ignore_errors = True I think is a reasonable expectation to have any error raised by the pytest-reportportal plugin (e.g. exception due to connectivity issue) swallowed by the plugin itself, so that the test suite can continue and at least produce the junit results.

Any update on this?

Should be good in client-Python 5.2.