Skip to content

Running tests with the agent and sending logs sometimes fail on beforeAll  #146

@aviadhadidainx

Description

@aviadhadidainx

Hi.

We have been using the new capablity of sending attachment and also to send logs.
reportingApiInstance.attachment(null, ${message});

We are seeing an issue that sometimes when we run all tests the beforeAll try to send logs (This is related to our platform that the before all actually using method that send logs on underlying services)

Initially we tried to avoid it using this code:

      if (reportingApiInstance.reporter.tempStepId)
        await reportingApiInstance.attachment(null, `${message}`);
      } else {
        console.log(message);
      }

Because we are seeing that sometimes the tempId is still on the previous tests that was running and not cleaned we get this error:

Error: Item with tempId "16vpr4blypmr8wx" not found
12:19:02      at RPClient.sendLogWithoutFile (/automation/node_modules/@reportportal/client-javascript/lib/report-portal-client.js:709:9)
12:19:02      at RPClient.sendLog (/automation/node_modules/@reportportal/client-javascript/lib/report-portal-client.js:689:17)
12:19:02      at JestReportPortal.sendLog (/automation/node_modules/@reportportal/agent-js-jest/src/reporter.js:242:37)
12:19:02      at ReportingApi.attachment (/automation/node_modules/@reportportal/agent-js-jest/src/reportingApi.js:37:19)
12:19:02      at Function.attachment [as logApiToReports] (/automation/test/utils/LoggerUtils.js:12:36)
12:19:02      at Function.logApiToReports [as logHttpCall] (/automation/src/utils/ApiWrapperUtils.js:64:23)
12:19:02      at Function.logHttpCall (/automation/src/utils/ApiWrapperUtils.js:44:29)
12:19:02      at processTicksAndRejections (node:internal/process/task_queues:95:5)

To overcome for now we have looked into the lib and did the following:

 if (reportingApiInstance.reporter.client.map[tempStepId]) {
        await reportingApiInstance.attachment(null, `${message}`);
      } else {
        console.log(message);
      }

I think there is a bug cleaning up the tempId and if not maybe add config flag not to fail the run on this code that run at the end of the test suites
image

NOTE: We are running tests in band, and i couldn't reproduce easily.. Happens on several tests with the beforeAll API calls

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions