Repository: test-results-reporter/reporter
Pull request #118 (2023-02-07 06:52:51)

bump performance results parser version


Patch:
diff --git a/package-lock.json b/package-lock.json
index be83d22..8f8dc97 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1394,6 +1394,14 @@
       "integrity": "sha512-NjvQHHaiPCxPZrhm/kKnorxOv7r/eA+tE0VW5E8iJMH9wTqFA1V0YK/7nbpxVu3JdXUxyWTKMez9lsHUtAwa0w==",
       "dev": true
     },
+    "parse-jtl": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/parse-jtl/-/parse-jtl-1.0.2.tgz",
+      "integrity": "sha512-SVYjidaVm8o76Rj6a6BGg1/nGlBCel3uprF8wPuk0ShmtbAjoNZTT5DLAjRzWb+8hMlaMENC6m//ir9lKStokw==",
+      "requires": {
+        "csvjson": "^5.1.0"
+      }
+    },
     "parse-ms": {
       "version": "2.1.0",
       "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-2.1.0.tgz",
@@ -1430,12 +1438,13 @@
       "dev": true
     },
     "performance-results-parser": {
-      "version": "0.0.5",
-      "resolved": "https://registry.npmjs.org/performance-results-parser/-/performance-results-parser-0.0.5.tgz",
-      "integrity": "sha512-HfaWRo5OCh0TDUG0DtqpwCmepxqAr0dRVzRH3GldcbJSdRZMqPmbS49fk6Yttn0FbQGpPIL+K1wVviBzSKjOig==",
+      "version": "0.0.6",
+      "resolved": "https://registry.npmjs.org/performance-results-parser/-/performance-results-parser-0.0.6.tgz",
+      "integrity": "sha512-nRlnVQjERXompTnG1+iKEybd2Q+Uc5QsRC7ZxzDsrRtBdpqCrf4ZZWKEnNnUdleoU4pLgtEv4K8bnGUy/MB+Tw==",
       "requires": {
         "csvjson": "^5.1.0",
         "globrex": "^0.1.2",
+        "parse-jtl": "^1.0.2",
         "totalist": "^3.0.0"
       }
     },
diff --git a/package.json b/package.json
index 8cfc4c5..782c81c 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/index.d.ts b/src/index.d.ts
index 2be43c8..5d5ba72 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -178,6 +178,7 @@ export interface InfluxDBTargetInputs {
   measurement_test_suite?: string;
   measurement_test_case?: string;
   tags?: object;
+  fields?: object;
 }
 
 export interface CustomTargetFunctionContext {
diff --git a/src/targets/influx.js b/src/targets/influx.js
index fdcc5b7..91b13b6 100644
--- a/src/targets/influx.js
+++ b/src/targets/influx.js
@@ -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) {
@@ -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;
@@ -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;
 
@@ -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 = {


Test patch:
diff --git a/test/mocks/influx.mock.js b/test/mocks/influx.mock.js
index d4a299d..28bb37d 100644
--- a/test/mocks/influx.mock.js
+++ b/test/mocks/influx.mock.js
@@ -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',
@@ -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
@@ -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',
@@ -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
diff --git a/test/targets.influx.spec.js b/test/targets.influx.spec.js
index 0bfbf1c..ff6b858 100644
--- a/test/targets.influx.spec.js
+++ b/test/targets.influx.spec.js
@@ -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": [
@@ -53,6 +53,9 @@ describe('targets - influx - performance', () => {
                   "tags": {
                     "Team": "QA",
                     "App": "PactumJS"
+                  },
+                  "fields": {
+                    "id": "123",
                   }
                 }
               }
@@ -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": [
@@ -129,6 +132,9 @@ describe('targets - influx - functional', () => {
                   "tags": {
                     "Team": "QA",
                     "App": "PactumJS"
+                  },
+                  "fields": {
+                    "id": "123",
                   }
                 }
               }