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

bump performance results parser version #118

Merged
merged 1 commit into from
Feb 7, 2023
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
15 changes: 12 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"async-retry": "^1.3.3",
"dotenv": "^14.3.2",
"influxdb-v1": "^1.0.4",
"performance-results-parser": "0.0.5",
"performance-results-parser": "latest",
"phin-retry": "^1.0.3",
"pretty-ms": "^7.0.1",
"rosters": "0.0.1",
Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export interface InfluxDBTargetInputs {
measurement_test_suite?: string;
measurement_test_case?: string;
tags?: object;
fields?: object;
}

export interface CustomTargetFunctionContext {
Expand Down
24 changes: 20 additions & 4 deletions src/targets/influx.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ function getTransactionInfluxMetric(transaction, target) {
tags.Name = transaction.name;
tags.Status = transaction.status;

const fields = {};
const fields = Object.assign({}, target.inputs.fields);
for (const key in fields) {
if (Object.hasOwnProperty.call(fields, key)) {
fields[key] = parseInt(fields[key]);
}
}
fields.status = transaction.status === 'PASS' ? 0 : 1;

for (const metric of transaction.metrics) {
Expand All @@ -139,7 +144,12 @@ function getTestInfluxMetric({ result, target }, measurement) {
tags.Name = result.name;
tags.Status = result.status;

const fields = {};
const fields = Object.assign({}, target.inputs.fields);
for (const key in fields) {
if (Object.hasOwnProperty.call(fields, key)) {
fields[key] = parseInt(fields[key]);
}
}
fields.status = result.status === 'PASS' ? 0 : 1;
fields.total = result.total;
fields.passed = result.passed;
Expand All @@ -164,7 +174,12 @@ function getTestCaseInfluxMetric({ result, target }) {
tags.Name = result.name;
tags.Status = result.status;

const fields = {};
const fields = Object.assign({}, target.inputs.fields);
for (const key in fields) {
if (Object.hasOwnProperty.call(fields, key)) {
fields[key] = parseInt(fields[key]);
}
}
fields.status = result.status === 'PASS' ? 0 : 1;
fields.duration = result.duration;

Expand All @@ -186,7 +201,8 @@ const default_inputs = {
measurement_test_run: 'TestRun',
measurement_test_suite: 'TestSuite',
measurement_test_case: 'TestCase',
tags: {}
tags: {},
fields: {}
}

const default_options = {
Expand Down
8 changes: 4 additions & 4 deletions test/mocks/influx.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ addInteractionHandler('save perf results', () => {
}
});

addInteractionHandler('save perf results with custom tags', () => {
addInteractionHandler('save perf results with custom tags and fields', () => {
return {
request: {
method: 'POST',
Expand All @@ -30,7 +30,7 @@ addInteractionHandler('save perf results with custom tags', () => {
queryParams: {
"db": "TestResults"
},
body: "PerfRun,Team=QA,App=PactumJS,Name=TOTAL,Status=PASS status=0,transactions=2,transactions_passed=2,transactions_failed=0,samples_sum=39,samples_rate=0.55535,duration_avg=4660,duration_med=3318,duration_max=15513,duration_min=1135,duration_p90=11354,duration_p95=11446,duration_p99=15513,errors_sum=0,errors_rate=0,data_sent_sum=0,data_sent_rate=38.87,data_received_sum=0,data_received_rate=5166.44\nPerfTransaction,Team=QA,App=PactumJS,Name=S01_T01_Application_Launch,Status=PASS status=0,samples_sum=10,samples_rate=0.14422,duration_avg=3086,duration_med=2832,duration_max=3797,duration_min=2119,duration_p90=3795,duration_p95=3795,duration_p99=3797,errors_sum=0,errors_rate=0.001,data_sent_sum=0,data_sent_rate=5.36,data_received_sum=0,data_received_rate=2662.79\nPerfTransaction,Team=QA,App=PactumJS,Name=S01_T02_Application_Login,Status=PASS status=0,samples_sum=9,samples_rate=0.1461,duration_avg=4355,duration_med=3273,duration_max=10786,duration_min=3042,duration_p90=4416,duration_p95=10786,duration_p99=10786,errors_sum=0,errors_rate=0,data_sent_sum=0,data_sent_rate=12.94,data_received_sum=0,data_received_rate=2754.9"
body: "PerfRun,Team=QA,App=PactumJS,Name=TOTAL,Status=PASS status=0,transactions=2,transactions_passed=2,transactions_failed=0,samples_sum=39,samples_rate=0.55535,duration_avg=4660,duration_med=3318,duration_max=15513,duration_min=1135,duration_p90=11354,duration_p95=11446,duration_p99=15513,errors_sum=0,errors_rate=0,data_sent_sum=0,data_sent_rate=38.87,data_received_sum=0,data_received_rate=5166.44\nPerfTransaction,Team=QA,App=PactumJS,Name=S01_T01_Application_Launch,Status=PASS id=123,status=0,samples_sum=10,samples_rate=0.14422,duration_avg=3086,duration_med=2832,duration_max=3797,duration_min=2119,duration_p90=3795,duration_p95=3795,duration_p99=3797,errors_sum=0,errors_rate=0.001,data_sent_sum=0,data_sent_rate=5.36,data_received_sum=0,data_received_rate=2662.79\nPerfTransaction,Team=QA,App=PactumJS,Name=S01_T02_Application_Login,Status=PASS id=123,status=0,samples_sum=9,samples_rate=0.1461,duration_avg=4355,duration_med=3273,duration_max=10786,duration_min=3042,duration_p90=4416,duration_p95=10786,duration_p99=10786,errors_sum=0,errors_rate=0,data_sent_sum=0,data_sent_rate=12.94,data_received_sum=0,data_received_rate=2754.9"
},
response: {
status: 200
Expand All @@ -57,7 +57,7 @@ addInteractionHandler('save test results', () => {
}
});

addInteractionHandler('save test results with custom tags', () => {
addInteractionHandler('save test results with custom tags and fields', () => {
return {
request: {
method: 'POST',
Expand All @@ -68,7 +68,7 @@ addInteractionHandler('save test results with custom tags', () => {
queryParams: {
"db": "TestResults"
},
body: "TestRun,Team=QA,App=PactumJS,Name=Staging\\ -\\ UI\\ Smoke\\ Test\\ Run,Status=FAIL status=1,total=2,passed=1,failed=1,duration=1883597\nTestSuite,Team=QA,App=PactumJS,Name=desktop-chrome,Status=PASS status=0,total=1,passed=1,failed=0,duration=1164451\nTestCase,Team=QA,App=PactumJS,Name=GU,Status=PASS status=0,duration=243789\nTestSuite,Team=QA,App=PactumJS,Name=mobile-andoid,Status=FAIL status=1,total=1,passed=0,failed=1,duration=714100\nTestCase,Team=QA,App=PactumJS,Name=GU,Status=FAIL status=1,duration=156900"
body: "TestRun,Team=QA,App=PactumJS,Name=Staging\\ -\\ UI\\ Smoke\\ Test\\ Run,Status=FAIL id=123,status=1,total=2,passed=1,failed=1,duration=1883597\nTestSuite,Team=QA,App=PactumJS,Name=desktop-chrome,Status=PASS id=123,status=0,total=1,passed=1,failed=0,duration=1164451\nTestCase,Team=QA,App=PactumJS,Name=GU,Status=PASS id=123,status=0,duration=243789\nTestSuite,Team=QA,App=PactumJS,Name=mobile-andoid,Status=FAIL id=123,status=1,total=1,passed=0,failed=1,duration=714100\nTestCase,Team=QA,App=PactumJS,Name=GU,Status=FAIL id=123,status=1,duration=156900"
},
response: {
status: 200
Expand Down
12 changes: 9 additions & 3 deletions test/targets.influx.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('targets - influx - performance', () => {
});

it('should save results with custom tags', async () => {
const id = mock.addInteraction('save perf results with custom tags');
const id = mock.addInteraction('save perf results with custom tags and fields');
await publish({
config: {
"reports": [
Expand All @@ -53,6 +53,9 @@ describe('targets - influx - performance', () => {
"tags": {
"Team": "QA",
"App": "PactumJS"
},
"fields": {
"id": "123",
}
}
}
Expand Down Expand Up @@ -112,8 +115,8 @@ describe('targets - influx - functional', () => {
assert.equal(mock.getInteraction(id).exercised, true);
});

it('should save results with custom tags', async () => {
const id = mock.addInteraction('save test results with custom tags');
it('should save results with custom tags and fields', async () => {
const id = mock.addInteraction('save test results with custom tags and fields');
await publish({
config: {
"reports": [
Expand All @@ -129,6 +132,9 @@ describe('targets - influx - functional', () => {
"tags": {
"Team": "QA",
"App": "PactumJS"
},
"fields": {
"id": "123",
}
}
}
Expand Down