gurock / trcli

TR CLI (trcli) is a command line tool for interacting with TestRail.
Mozilla Public License 2.0
48 stars 39 forks source link

Connection error while uploading test results #225

Closed mcaballero-coding closed 2 months ago

mcaballero-coding commented 3 months ago

Hello. I am trying to use trcli to upload test results (report.xml) into TestRail but i am running into the following error: Error detected while checking a project: 'Upload to TestRail failed due to a network error. Please make sure you have a valid network connection then try again.'

Here is an explanation on my current situation and problem:

I am using the trcli command to upload my test results (ran them with pytest, which generates a report.xml file) to TestRail. To do so, I have followed every step at [tutorial], which are basically installing trcli, enabling API at TestRail and then calling trcli with appropiate parameters. I am currently doing: _trcli -y --verbose -c "trcli-config.yml" parsejunit -f "report.xml" . In trcli-config.yml I specify host, project, username, password (also tried with API key), and title. What seems to work in every video tutorial on the internet, is giving me the following error: ._.. ... Parsing JUnit report. Processed 2 test cases in section Sample Test Suite. Checking project. ** API Call method: GET url: https://[my host]/index.php?/api/v2/getprojects**

Error detected while checking a project: 'Upload to TestRail failed due to a network error. Please make sure you have a valid network connection then try again.'

I did a ping to my host and it works fine, so It does not look like a proxy error on my company's side. I also did a curl -u username:password https://[my host]/index.php?/api/v2/get_projects and it returns my projects correctly. It looks like the connection is possible, but it is not working when doing it using trcli. Note: i am using the latest trcli version (1.9.5). I tried using previous releases but none seem to work.

I would really appreciate some support on this issue, since it would be really helpful to be able to upload test results directly to TestRail. Thanks!

bitcoder commented 3 months ago

Can you try to increase the timeout using the -t argument and see if that works?

mcaballero-coding commented 3 months ago

Hi @bitcoder , thanks for your answer. I tried incrementing the timeout (_trcli -y --verbose -c "trcli-config.yml" -t 120 parsejunit -f "report.xml") but it returns the same error. The message error is printed instantly so I am guessing that this is not a timeout issue.

bitcoder commented 3 months ago

Hi @bitcoder , thanks for your answer. I tried incrementing the timeout (_trcli -y --verbose -c "trcli-config.yml" -t 120 parsejunit -f "report.xml") but it returns the same error. The message error is printed instantly so I am guessing that this is not a timeout issue.

Can you share the complete output?

mcaballero-coding commented 3 months ago

yes, this is it: TestRail CLI v1.9.5 Copyright 2024 Gurock Software GmbH - www.gurock.com Parser Results Execution Parameters

Report file: report.xml Config file: trcli-config.yml TestRail instance: https://my_host.testrail.io (user: myuser@something.com) Project: MY_PROJECT_NAME Run title: Automated Test Run Update run: No Add to milestone: No Auto-create entities: True

Parsing JUnit report. Processed 28 test cases in section pytest. Checking project. **** API Call method: GET url: https://my_host.testrail.io/index.php?/api/v2/get_projects

**** API Call method: GET url: https://my_host.testrail.io/index.php?/api/v2/get_projects

**** API Call method: GET url: https://my_host.testrail.io/index.php?/api/v2/get_projects

**** API Call method: GET url: https://my_host.testrail.io/index.php?/api/v2/get_projects

Error detected while checking a project: 'Upload to TestRail failed due to a network error. Please make sure you have a valid network connection then try again.'


NOTE: i am not showing the real host name and username for privacy reasons.

mcaballero-coding commented 3 months ago

In case it is helpful, doing some debugging i found that the error occurs at "__sendrequest()". It is a ConnectionError, which if printed (except ConnectionError as e: print(e)_) says: HTTPSConnectionPool(host='my_host.testrail.io', port=443): Max retries exceeded with url: /index.php?/api/v2/get_projects (Caused by ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 403 Forbidden')))

Any idea on why this happens?

bitcoder commented 2 months ago

what host is that one "my_host.testrail.io"?

mcaballero-coding commented 2 months ago

I am not showing my real host name and username for privacy reasons. However, i have managed to solve this issue. There was a proxy (from my company's side) that was blocking internet access to the testrail url, so there's nothing wrong with trcli. Thank you for your help

Shubham22100 commented 5 hours ago

I am same issue while uploading test results . can anyone assist here . i have started new discussion also #255

mcaballero-coding commented 4 hours ago

I am same issue while uploading test results . can anyone assist here . i have started new discussion also #255

Hello @Shubham22100, I see you have a similar issue like i did. I solved it some time ago. My recommendations are:

1) Look for more detail on the error. You can add "prints" to the trcli code so that it prints more detail. Also use the trcli command with "verbose", something like this: 'trcli -y --verbose ... ' 2) Make sure you don't have proxies that are limiting you network access. In my case this was the cause of the problem. My machine had some active proxies that my company installed that were limiting internet access to TestRail, so I basically asked them to remove them. You can do 'echo $http_proxy' and 'echo $https_proxy' in your terminal to see if you have these proxies.

Hope it helps

Shubham22100 commented 2 hours ago

I have used trcli -n --verbose -c "trcli-config.yml" parse_junit --case-matcher "property" --suite-name "Smoke Testing Suite" -f "./test-results/junit-report.xml" TestRail CLI v1.9.5 Copyright 2024 Gurock Software GmbH - www.gurock.com Parser Results Execution Parameters

Report file: ./test-results/junit-report.xml Config file: trcli-config.yml Update run: No Add to milestone: No Auto-create entities: False Parsing JUnit report. Processed 1 test cases in section smokeTests\MusicGlE2E.Test.ts. Checking project. **** API Call method: GET url: https://lovullo.testrail.net/index.php?/api/v2/get_projects

**** API Call method: GET url: https://lovullo.testrail.net/index.php?/api/v2/get_projects

**** API Call method: GET url: https://lovullo.testrail.net/index.php?/api/v2/get_projects

**** API Call method: GET url: https://lovullo.testrail.net/index.php?/api/v2/get_projects

but still getting same error Error detected while checking a project: 'Upload to TestRail failed due to a network error. Please make sure you have a valid network connection then try again.'

Shubham22100 commented 2 hours ago

Also I have try to run 'echo $http_proxy' and 'echo $https_proxy' in my terminal but nothing i am getting . it just return same http_proxy . Also checked with network team and they said u have access to test rail and i also can open manually and in browser.

mcaballero-coding commented 1 hour ago

Also I have try to run 'echo $http_proxy' and 'echo $https_proxy' in my terminal but nothing i am getting . it just return same http_proxy . Also checked with network team and they said u have access to test rail and i also can open manually and in browser.

Not really sure what could be the problem. You can do a ping and a curl (i think you need to use username and password for this) to TestRail from your machine to make sure you have access from there.

I also recommend you to read previous comments on this issue, for example those regarding the --t argument or the ProxyError that I was getting. If you puta some prints on the trcli code you could get more detail. In my case the error was ocurring at "__send_request()".

Other than that, let's hope that a person from TestRail can assist you with this. Hope you can solve it!

Shubham22100 commented 1 hour ago

How to use prints or prints the more details . Can you give me query and command?