rhevm-qe-automation / pytest_jira

py.test plugin to integrate with JIRA
GNU General Public License v2.0
29 stars 25 forks source link

Internal server error when trying to connect #65

Closed liiight closed 7 years ago

liiight commented 7 years ago

I've setup jira.cfg like the documentation described but I cannot seem to connect:

(stronghold-py) ip-192-168-0-8:stronghold-py orcarmi$ pytest --jira
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/_pytest/main.py", line 94, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/_pytest/config.py", line 902, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 750, in call_historic
INTERNALERROR>     self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/pytest_jira.py", line 384, in pytest_configure
INTERNALERROR>     config.getvalue('jira_verify'),
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/pytest_jira.py", line 168, in __init__
INTERNALERROR>     max_retries=1
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/jira/client.py", line 307, in __init__
INTERNALERROR>     user = self.session()
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/jira/client.py", line 2082, in session
INTERNALERROR>     r = self._session.post(url, data=json.dumps(authentication_data))
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/jira/resilientsession.py", line 153, in post
INTERNALERROR>     return self.__verb('POST', url, **kwargs)
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/jira/resilientsession.py", line 146, in __verb
INTERNALERROR>     raise_on_error(response, verb=verb, **kwargs)
INTERNALERROR>   File "/Users/orcarmi/stronghold-py/lib/python3.6/site-packages/jira/resilientsession.py", line 56, in raise_on_error
INTERNALERROR>     r.status_code, error, r.url, request=request, response=r, **kwargs)
INTERNALERROR> jira.exceptions.JIRAError: JiraError HTTP 500 url: https://REDACTED.jira.com/rest/auth/1/session
INTERNALERROR>  text: Internal server error
INTERNALERROR>  
INTERNALERROR>  response headers = {'Server': 'nginx', 'Date': 'Tue, 09 May 2017 09:55:20 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'X-AREQUESTID': '775x2085x1', 'X-AUSERNAME': 'test-agent', 'X-ATENANT-ID': 'REDACTED.jira.com', 'X-Seraph-LoginReason': 'OK', 'Cache-Control': 'no-cache, no-store, no-transform', 'X-Content-Type-Options': 'nosniff', 'Set-Cookie': 'JSESSIONID=6A24CD47D020312444192706B837D326; Path=/; Secure; HttpOnly, atlassian.xsrf.token=AG87-S37R-QM8W-6VWE|77ab169ca0173175b9d8654b07be1c2d5d4af311|lin; Path=/; Secure, studio.crowd.tokenkey=""; Domain=.REDACTED.jira.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly, studio.crowd.tokenkey=xQmVO1gW2eGOmNY3udKlng00; Domain=.REDACTED.jira.com; Path=/; Secure; HttpOnly'}
INTERNALERROR>  response text = {"errorMessages":["Internal server error"],"errors":{}}

When trying to connect using basic auth directly via the jira module it works:

from jira import JIRA

jira = JIRA('https://REDACTED.jira.com', basic_auth=('REDACTED', 'REDACTED'))

Any assistance would be appreciated

lukas-bednar commented 7 years ago

Hi @liiight , thanks for report, could you please provide your jira.cfg file ?

liiight commented 7 years ago

I really don't want to expose my credentials as they are for my work. I used just the url, username and password.

Also, I just tried using running using --jira-url, --jira-user and --jira-password and it worked, or at the very least didn't crash. Not sure it actually skipped a test I marked it to skip.

If this is any help:

[DEFAULT]
url = https://REDACTED.jira.com
username = REDACTED
password = REDACTED
lukas-bednar commented 7 years ago

@liiight good this is enough. I will try to reproduce it, and let you know!

lukas-bednar commented 7 years ago

Hi @liiight ,

I was trying to reproduce your issue, but I wasn't able to do that. I was able to run py.test with Jira plugin enabled, all parameters are stored in jira.cfg. I supplied url, username & password for my internal Jira instance, and all went as expected.

You can find my test environment bellow:

test_pytest_jira.tar.gz

===================================================================================== test session starts =====================================================================================
platform linux2 -- Python 2.7.13, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /tmp/test_pytest_jira, inifile:
plugins: jira-0.3.1
collected 1 items 

x

================================================================================== 1 xfailed in 0.23 seconds ==================================================================================

In case you have other information which could help me to reproduce issue, please share ;-) I am sorry that I couldn't really help you ...

liiight commented 7 years ago

The most obvious difference I can think if is that I'm using python 3.6.

Also, I'm unfamiliar with Jira API but could there a server setting that need to set or something?

Push comes to shove, I'll clone the repo and try to debug it.
Any tips on how to test this locally?

lukas-bednar commented 7 years ago

I just tried same for py3.6 with same result

===================================================================================== test session starts =====================================================================================
platform linux -- Python 3.6.0, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /tmp/test_pytest_jira, inifile:
plugins: jira-0.3.1
collected 1 items 

x

================================================================================== 1 xfailed in 0.16 seconds ==================================================================================
lukas-bednar commented 7 years ago

Hi @liiight ,

is there anything new? were you able to move on with this issue ?

Here I am adding list of packages which I have installed in virtualenv for 3.6 just in case you can see some difference:

py36 installed:
appdirs==1.4.3
defusedxml==0.5.0
jira==1.0.10
oauthlib==2.0.2
packaging==16.8
pbr==3.0.0
py==1.4.33
pyparsing==2.2.0
pytest==3.0.7
pytest-jira==0.3.1
requests==2.13.0
requests-oauthlib==0.8.0
requests-toolbelt==0.7.1
six==1.10.0
liiight commented 7 years ago

No, I didn't get a chance to test this yet. Could you elaborate on exactly how to test this locally? I haven't dabbled at all with pytest plugins development yet, maybe you could save me some time

lukas-bednar commented 7 years ago

Hi, I don't have any specific method, but you can start with this sandbox environment. test_pytest_jira.tar.gz

I changed previous archive to use tox tool in order to allow you run over more python versions out of box.

I run that simple test for py27, py35 and py35, against server JIRA v6.4.11.

Please try to reproduce your problem with my simple test:

I included also tox.out file, where you can see my execution, you can find there versions of all used python packages.

I hope it will help you to start with debugging that issue.

liiight commented 7 years ago

Weirdly enough, the problem seemed to resolve itself... It all works now. I have no idea why. Thanks anyway!