kobenguyent / codeceptjs-testrail

MIT License
23 stars 14 forks source link

uploading result to testrail from Jenkins server is failling #28

Closed xgene34 closed 3 years ago

xgene34 commented 3 years ago

Hi,

I'm getting following issue when executing testrail connector from Jenkins server:

Cannnot add new test run to existing test plan due to Error: Request failed with status code 400 04:32:04 (node:4612) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'runs' of undefined 04:32:04 at EventEmitter. (e:\jb_home\jobs\Payment_Automation_Framework\workspace\node_modules\codeceptjs-testrail\index.js:308:18) 04:32:04 at runMicrotasks () 04:32:04 at processTicksAndRejections (internal/process/task_queues.js:97:5) 04:32:04 (node:4612) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 99)

But when I run from my local machine it works fine. Do you know what could be the issue? Thanks.

kobenguyent commented 3 years ago

Hey @xgene34 there is possibility that the test are running in slave and you trigger the tests from Jenkins master machine. That results the test execution doesn't send results in real time from slave to master Jenkins.

dtran31 commented 3 years ago

Hi,

I'm getting similar too. I get

Cannnot update run due to Error: Request failed with status code 400 Cannnot add result for case due to Error: Request failed with status code 400

It all of a sudden start happening about a week or so ago, I didn't change anything. It still works locally though. Tests are running on AWS, using codebuild.

kobenguyent commented 3 years ago

I just tried with codefresh, seems okay so far. Tests are executed and results are pushed to testrail

Screen Shot 2021-02-19 at 12 28 07 PM Screen Shot 2021-02-19 at 12 28 21 PM
kobenguyent commented 3 years ago

I also noticed Cannnot add new test run to existing test plan due to Error: Request failed with status code 400 04:32:04 (node:4612) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'runs' of undefined 04:32:04 at EventEmitter. (e:\jb_home\jobs\Payment_Automation_Framework\workspace\node_modules\codeceptjs-testrail\index.js:308:18) so you were running tests with test plan option. I gave it a try. And working too.

Screen Shot 2021-02-19 at 12 45 34 PM
xgene34 commented 3 years ago

you are running on local instance? I'm running tests on selenium grid maybe that could be the issue...hmmm

kobenguyent commented 3 years ago

I'm running with codefresh a cloud CI/CD.

xgene34 commented 3 years ago

I'll check a bit more...for now it looks like it can't create the test run...when running from my machine all works fine :-) thinking maybe something with access rights from Jenkins server to testrail server :-)

dtran31 commented 3 years ago

Interesting. For me the test run is created, but the results aren't pushing. Very strange. Tests complete and everything too.

OK | 26 passed, 116 skipped // 47m 990 | [mochawesome] Report HTML saved to /codebuild/output/src259724161/src/github.com/momenthouse/automated-testing/output/reports/2021-02-17_browserstack_momenthouse.html 991 |   992 | Cannnot update run due to Error: Request failed with status code 400 993 | Cannnot add result for case due to Error: Request failed with status code 400 994 | Done in 2834.68s. 995 |   996 | [Container] 2021/02/17 17:48:42 Phase complete: BUILD State: SUCCEEDED 997 | [Container] 2021/02/17 17:48:42 Phase context status code: Message: 998 | [Container] 2021/02/17 17:48:42 Entering phase POST_BUILD 999 | [Container] 2021/02/17 17:48:42 Phase complete: POST_BUILD State: SUCCEEDED 1000 | [Container] 2021/02/17 17:48:42 Phase context status code: Message:

kobenguyent commented 3 years ago

Could you perhaps show your testrail config? Ofc with obfuscation the sensitive info and a test case title?

dtran31 commented 3 years ago

Nothing to fancy, same as I have for my local which works, only difference is the runName: Local Test Run ${currentTime}

testrail: { require: 'codeceptjs-testrail', host: 'https://momenthouse.testrail.io', user: 'david@momenthouse.com', password: '*****', suiteId: 1, projectId: 1, runName: Smoke Test Run ${currentTime}, enabled: true }

One of our test cases: Scenario("A Fan can buy a ticket for an ongoing event that does not need an access code @C28", async (I) => {

Use to work not long ago: testrailcomplete

kobenguyent commented 3 years ago

Oh is it normal c or capitalized C in @c28? Also I noticed you're not using codeceptjs 3.x right?

dtran31 commented 3 years ago

It's capitalized C in the code, not sure why it pasted lowercase c. We're still using codeceptjs 2.x for the web automation atm, would that be the issue? I would think that would break the test run creation portion too.

manasiLatch commented 3 years ago

I am running into the same issue where tests pass on Jenkins but testrail results are not updated anymore. It shows 0% passed in the test run that gets created.

OK | 64 passed // 35m Cannnot update run due to Error: Request failed with status code 400 Cannnot add result for case due to Error: Request failed with status code 400

The Testrail configuration I have has not changed but this started happening a week ago.

testrail: { require: 'codeceptjs-testrail', host: 'url', user: 'user, password: 'pwd', suiteId: 123, projectId: 1, runName: process.env.TESTRAIL_RUN || 'Automated Test Run', enabled: process.env.TESTRAIL || false },

I also tried installing the exact package 1.7.0 on which it used to work before but no luck. Another thing I noticed that if I run a small subset of tests, the testrail results are updated with the same config but not on running the entire test suite.

Is anyone else having the same issue? I would appreciate any ideas!

ZloyByryndyk commented 3 years ago

I have the same problem, while there were a few tests (less than 10), the results of the run were sent to TestRail, as soon as there were more of them, the results of the run are not created:

(Cannot add new test run to existing test plan due to Error: Request failed with status code 400 (node:30581) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'runs' of undefined)

My config: testrail: { require: 'codeceptjs-testrail', host: 'https://fhm.testrail.io', users: 'rinat@flowhealth.com', password: '*****', siteid: 1, project Id: 1, runId: 20, plan: { existingPlanId: 14, }, configuration: { groupName: 'smoke', config Name: 'smoke' }, enabled: true, debugLog: true }

I would be grateful for your help

kobenguyent commented 3 years ago

Hey @Georgegriff do you happen to encounter this issue cause iirc, you shared your tcs are around 800+? 😊

Georgegriff commented 3 years ago

Unfortunately I don't, I dont provide a plan I just provided a predefined runId with no plan information at all. We have separate process for generating our test plans (with runs).

This means I go down a different code path

If people are having issues and they have a runId already and don't need one created try not specifying a plan at all remove the object entirely

ZloyByryndyk commented 3 years ago

I solved this problem Cannnot update run due to Error: Request failed with status code 400 for myself, it turns out that several of my tests had the same test case ID, as soon as I set a unique id for each test , everything worked and reports are sent to TestRail

maybe this will help someone)

kobenguyent commented 3 years ago

https://github.com/PeterNgTr/codeceptjs-testrail/pull/44

Hopefully this PR solves the issue.