Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 5.3.0 #216

Merged
merged 10 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ on:
branches:
- develop
- master
paths-ignore:
- README.md
- CHANGELOG.md

jobs:
test:
Expand All @@ -41,7 +44,7 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Install of node dependencies
- name: Install dependencies
run: npm install

- name: Build the source code
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install of node dependencies
- name: Install dependencies
run: npm install
- name: Run lint
run: npm run lint
- name: Run tests
run: npm test
- name: Check coverage
- name: Run tests and check coverage
run: npm run test:coverage

publish-to-npm-and-gpr:
Expand All @@ -47,7 +45,7 @@ jobs:
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Install of node dependencies
- name: Install dependencies
run: npm install
- name: Publish to NPM
run: |
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### Changed
- The client now expects reporting the time for launches, test items and logs with microsecond precision in the ISO string format.
Thus, the `helpers.now` function is adjusted accordingly. Details about [supported](./README.md#time-format) formats.
For logs, microsecond precision is available on the UI from ReportPortal version 24.2.
### Security
- Updated versions of vulnerable packages (micromatch).

## [5.2.0] - 2024-09-17
### Changed
Expand Down
46 changes: 28 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ console.log(launchObj.tempId);
The method takes one argument:
* launch data object:

| Option | Necessity | Default | Description |
|-------------|-----------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| startTime | Optional | rpClient.helpers.now() | Start time of the launch (unix time). |
| name | Optional | parameter 'launch' specified when creating the client instance | Name of the launch. |
| mode | Optional | 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
| description | Optional | '' | Description of the launch (supports markdown syntax). |
| attributes | Optional | [] | Array of launch attributes (tags). |
| Option | Necessity | Default | Description |
|-------------|-----------|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| startTime | Optional | rpClient.helpers.now() | Start time of the launch (Unix Epoch time, see [time format](#time-format)). |
| name | Optional | parameter 'launch' specified when creating the client instance | Name of the launch. |
| mode | Optional | 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
| description | Optional | '' | Description of the launch (supports markdown syntax). |
| attributes | Optional | [] | Array of launch attributes (tags). |
| id | Optional | Not set | `ID` of the existing launch in which tests data would be sent, without this param new launch instance will be created. |

To get the real launch `ID` (also known as launch `UUID` from database) wait for the returned promise to finish.
Expand Down Expand Up @@ -180,9 +180,9 @@ The method takes two arguments:
* launch `tempId` (returned by the method `startLaunch`)
* data object:

|Option | Necessity | Default | Description |
|--------- |-----------|---------|---------------------------------------------------------------------------------------------------|
|endTime | Optional | rpClient.helpers.now() | End time of the launch. |
|Option | Necessity | Default | Description |
|--------- |-----------|---------|----------------------------------------------------------------------------------------------------|
|endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
|status | Optional | '' | Status of launch, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |

### getPromiseFinishAllItems
Expand Down Expand Up @@ -265,7 +265,7 @@ The method takes three arguments:
|type | Required | | Test item type, one of 'SUITE', 'STORY', 'TEST', 'SCENARIO', 'STEP', 'BEFORE_CLASS', 'BEFORE_GROUPS','BEFORE_METHOD', 'BEFORE_SUITE', 'BEFORE_TEST', 'AFTER_CLASS', 'AFTER_GROUPS', 'AFTER_METHOD', 'AFTER_SUITE', 'AFTER_TEST' |
|hasStats | Optional | true | Changes behavior for test item of type 'STEP'. When set to `true`, step is treaten as a test case (entity containig statistics). When false, step becomes a nested step. |
|description | Optional | '' | Description of the test item (supports markdown syntax). |
|startTime | Optional | rpClient.helpers.now() | Start time of the test item (unix time). |
|startTime | Optional | rpClient.helpers.now() | Start time of the test item (Unix Epoch time, see [time format](#time-format)). |
|attributes | Optional | [] | Array of the test item attributes. |

* launch `tempId` (returned by the method `startLaunch`)
Expand All @@ -289,8 +289,8 @@ The method takes two arguments:
| Option | Necessity | Default | Description |
|---------|-----------|------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
| issue | Optional | true | Test item issue object. `issueType` is required, allowable values: 'pb***', 'ab***', 'si***', 'ti***', 'nd001'. Where `***` is locator id |
| status | Optional | 'PASSED' | Test item status, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
| endTime | Optional | rpClient.helpers.now() | End time of the launch (unix time). |
| status | Optional | 'PASSED' | Test item status, one of '', 'PASSED', 'FAILED', 'STOPPED', 'SKIPPED', 'INTERRUPTED', 'CANCELLED'. |
| endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |

Example issue object:
```
Expand Down Expand Up @@ -325,11 +325,11 @@ The method takes three arguments:
* test item `tempId` (returned by method `startTestItem`)
* data object:

| Option | Necessity | Default | Description |
|---------|-----------|------------------------|----------------------------------------------------------------------|
| message | Optional | '' | The log message. |
| Option | Necessity | Default | Description |
|---------|-----------|------------------------|---------------------------------------------------------------------|
| message | Optional | '' | The log message. |
| level | Optional | '' | The log level, one of 'trace', 'debug', 'info', 'warn', 'error', ''. |
| time | Optional | rpClient.helpers.now() | The time of the log. |
| time | Optional | rpClient.helpers.now() | The time of the log (Unix Epoch time, see [time format](#time-format)). |

* file object (optional):

Expand Down Expand Up @@ -370,13 +370,23 @@ The method takes one argument:
|-------------------------|-----------|-----------------------------------------|------------------------------------------------------------------------------------------------------------|
| description | Optional | config.description or 'Merged launch' | Description of the launch (supports markdown syntax). |
| attributes | Optional | config.attributes or [] | Array of launch attributes (tags). |
| endTime | Optional | rpClient.helpers.now() | End time of the launch (unix time) |
| endTime | Optional | rpClient.helpers.now() | End time of the launch (Unix Epoch time, see [time format](#time-format)). |
| extendSuitesDescription | Optional | true | Whether to extend suites description or not. |
| launches | Optional | ids of the launches saved to filesystem | The array of the real launch ids, not UUIDs |
| mergeType | Optional | 'BASIC' | The type of the merge operation. Possible values are 'BASIC' or 'DEEP'. |
| mode | Optional | config.mode or 'DEFAULT' | 'DEFAULT' - results will be submitted to Launches page, 'DEBUG' - results will be submitted to Debug page. |
| name | Optional | config.launch or 'Test launch name' | Name of the launch after merge. |

## Time format

The unix Epoch time ISO string.

The [ReportPortal since product version 24.2]() (Service API version 5.12.0) supports the time with microsecond precision in the ISO string format (`2024-09-23T11:10:46.793546Z`).
Thus, it is recommended to report time in this format to have more accurate logs and test items order on the ReportPortal UI.
**Note:** Reporting the time in ISO string format with millisecond precision (`2024-09-23T11:10:46.793Z`) or as a number of milliseconds (`1727089846793`) is also acceptable with microseconds automatically added as zeros for backward compatibility.

The client use time with microsecond precision in the ISO string format by default since [version 5.3.0]().

# Copyright Notice

Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.0
5.2.1-SNAPSHOT
34 changes: 32 additions & 2 deletions __tests__/helpers.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const os = require('os');
const fs = require('fs');
const glob = require('glob');
const microtime = require('microtime');
const helpers = require('../lib/helpers');
const pjson = require('../package.json');

Expand All @@ -20,9 +21,38 @@ describe('Helpers', () => {
});
});

describe('formatMicrosecondsToISOString', () => {
test('converts microseconds to ISO string with microseconds precision', () => {
const input = 1726842755304456;
const expected = '2024-09-20T14:32:35.304456Z';
const result = helpers.formatMicrosecondsToISOString(input);
expect(result).toBe(expected);
});

test('handles microseconds at the start of the epoch', () => {
const input = 654321;
const expected = '1970-01-01T00:00:00.654321Z';
const result = helpers.formatMicrosecondsToISOString(input);
expect(result).toBe(expected);
});

test('handles rounding down of microseconds correctly', () => {
const input = 1000001;
const expected = '1970-01-01T00:00:01.000001Z';
const result = helpers.formatMicrosecondsToISOString(input);
expect(result).toBe(expected);
});
});

describe('now', () => {
it('returns milliseconds from unix time', () => {
expect(new Date() - helpers.now()).toBeLessThan(100); // less than 100 miliseconds difference
it('should return the current timestamp with microseconds precision in ISO string format', () => {
const spyMicrotime = jest.spyOn(microtime, 'now').mockReturnValue(1726842755304456);
const expectedISOString = '2024-09-20T14:32:35.304456Z';

const result = helpers.now();

expect(spyMicrotime).toHaveBeenCalled();
expect(result).toBe(expectedISOString);
});
});

Expand Down
Loading
Loading