Skip to content

Commit

Permalink
Merge pull request #138 from test-results-reporter/25-support-influxd…
Browse files Browse the repository at this point in the history
…b-v2-as-target

feat: use influxdb-lite to support v2
  • Loading branch information
ASaiAnudeep authored Oct 23, 2023
2 parents ba65102 + b19c377 commit 6957ba1
Show file tree
Hide file tree
Showing 8 changed files with 1,950 additions and 810 deletions.
2,499 changes: 1,919 additions & 580 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "test-results-reporter",
"version": "1.0.17",
"version": "1.0.18",
"description": "Publish test results to Microsoft Teams, Google Chat, Slack and InfluxDB",
"main": "src/index.js",
"types": "./src/index.d.ts",
Expand Down Expand Up @@ -48,8 +48,7 @@
"dependencies": {
"async-retry": "^1.3.3",
"dotenv": "^14.3.2",
"influxdb-v1": "^1.0.4",
"influxdb-v2": "^1.0.0",
"influxdb-lite": "^1.0.0",
"performance-results-parser": "latest",
"phin-retry": "^1.0.3",
"pretty-ms": "^7.0.1",
Expand Down
1 change: 0 additions & 1 deletion src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const TARGET = Object.freeze({
CUSTOM: 'custom',
DELAY: 'delay',
INFLUX: 'influx',
INFLUX2: 'influx2'
});

const EXTENSION = Object.freeze({
Expand Down
5 changes: 5 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,14 @@ export interface ChatInputs extends TargetInputs { }

export interface InfluxDBTargetInputs {
url: string;
version?: string;
db: string;
username?: string;
password?: string;
org?: string;
bucket?: string;
precision?: string;
token?: string;
measurement_perf_run?: string;
measurement_perf_transaction?: string;
measurement_test_run?: string;
Expand Down
3 changes: 0 additions & 3 deletions src/targets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const chat = require('./chat');
const custom = require('./custom');
const delay = require('./delay');
const influx = require('./influx');
const influx2 = require('./influx2');
const { TARGET } = require('../helpers/constants');
const { checkCondition } = require('../helpers/helper');

Expand All @@ -22,8 +21,6 @@ function getTargetRunner(target) {
return delay;
case TARGET.INFLUX:
return influx;
case TARGET.INFLUX2:
return influx2;
default:
return require(target.name);
}
Expand Down
12 changes: 10 additions & 2 deletions src/targets/influx.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const influx_v1 = require('influxdb-v1');
const influx = require('influxdb-lite');
const Metric = require('performance-results-parser/src/models/Metric');
const PerformanceTestResult = require('performance-results-parser/src/models/PerformanceTestResult');
const Transaction = require('performance-results-parser/src/models/Transaction');
Expand All @@ -18,12 +18,16 @@ const { STATUS } = require('../helpers/constants');
async function run({ result, target }) {
target.inputs = Object.assign({}, default_inputs, target.inputs);
const metrics = getMetrics({ result, target });
await influx_v1.write(
await influx.write(
{
url: target.inputs.url,
version: target.inputs.version,
db: target.inputs.db,
username: target.inputs.username,
password: target.inputs.password,
org: target.inputs.org,
bucket: target.inputs.bucket,
token: target.inputs.token,
},
metrics
);
Expand Down Expand Up @@ -178,9 +182,13 @@ function getTestCaseInfluxMetric({ result, target }) {

const default_inputs = {
url: '',
version: 'v1',
db: '',
username: '',
password: '',
org: '',
bucket: '',
token: '',
measurement_perf_run: 'PerfRun',
measurement_perf_transaction: 'PerfTransaction',
measurement_test_run: 'TestRun',
Expand Down
203 changes: 0 additions & 203 deletions src/targets/influx2.js

This file was deleted.

32 changes: 14 additions & 18 deletions test/targets.influx2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ describe('targets - influx2 - performance', () => {
{
"targets": [
{
"name": "influx2",
"name": "influx",
"inputs": {
"host": "localhost",
"port": 9393,
"protocol": "http",
"url": "http://localhost:9393",
"version": "v2",
"token": "testtoken",
"org": "testorg",
"bucket": "testbucket",
"precision": "ns"
"precision": "ns",
}
}
],
Expand All @@ -47,11 +46,10 @@ describe('targets - influx2 - performance', () => {
{
"targets": [
{
"name": "influx2",
"name": "influx",
"inputs": {
"host": "localhost",
"port": 9393,
"protocol": "http",
"url": "http://localhost:9393",
"version": "v2",
"token": "testtoken",
"org": "testorg",
"bucket": "testbucket",
Expand Down Expand Up @@ -98,15 +96,14 @@ describe('targets - influx2 - functional', () => {
{
"targets": [
{
"name": "influx2",
"name": "influx",
"inputs": {
"host": "localhost",
"port": 9393,
"protocol": "http",
"url": "http://localhost:9393",
"version": "v2",
"token": "testtoken",
"org": "testorg",
"bucket": "testbucket",
"precision": "ns"
"precision": "ns",
}
}
],
Expand All @@ -133,11 +130,10 @@ describe('targets - influx2 - functional', () => {
{
"targets": [
{
"name": "influx2",
"name": "influx",
"inputs": {
"host": "localhost",
"port": 9393,
"protocol": "http",
"url": "http://localhost:9393",
"version": "v2",
"token": "testtoken",
"org": "testorg",
"bucket": "testbucket",
Expand Down

0 comments on commit 6957ba1

Please sign in to comment.