Skip to content

Commit

Permalink
fix(influx): fix influx plugin name (#22)
Browse files Browse the repository at this point in the history
* fix(influx): fix influx plugin configuration
  • Loading branch information
NivLipetz authored and enudler committed Aug 27, 2019
1 parent 51dec0e commit 1f74783
Show file tree
Hide file tree
Showing 9 changed files with 371 additions and 405 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ module.exports.buildMetricsPlugin = (metricsConfig, jobConfig) => {
'environment': jobConfig.cluster
},
'influx': {
'host': metricsConfig.influx_host,
'username': metricsConfig.influx_username,
'password': metricsConfig.influx_password,
'database': metricsConfig.influx_database
'host': metricsConfig.host,
'username': metricsConfig.username,
'password': metricsConfig.password,
'database': metricsConfig.database
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion app/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const RUNNER_MANDATORY_VARIABLES = [
];

const PLUGINS_MANDATORY_VARIABLES = {
influxdb: ['influx_host', 'influx_database', 'influx_username', 'influx_password'],
influx: ['host', 'database', 'username', 'password'],
prometheus: ['push_gateway_url']
};

Expand Down
674 changes: 319 additions & 355 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"system-tests": "./tests/run.sh system-tests",
"local-system-tests": "./tests/run.sh local-system-tests",
"integration-tests": "./tests/run.sh integration-tests",
"unit-tests": "ARRIVAL_RATE=1 DURATION=1 nyc --check-coverage --lines 95 --reporter=html --reporter=text mocha ./tests/unit-tests --recursive",
"unit-tests": "ARRIVAL_RATE=1 DURATION=1 nyc --check-coverage --lines 94 --reporter=html --reporter=text mocha ./tests/unit-tests --recursive",
"lint": "node_modules/eslint/bin/eslint.js app/**",
"release": "standard-version"
},
Expand All @@ -30,27 +30,27 @@
"dependencies": {
"artillery": "https://github.com/Zooz/artillery.git#v2.0.2",
"artillery-plugin-prometheus": "^1.1.0",
"bunyan": "1.8.12",
"pidusage": "2.0.6",
"bunyan": "^1.8.12",
"pidusage": "^2.0.17",
"request": "~2.87.0",
"requestxn": "^3.1.1",
"uuid": "3.3.2"
"requestxn": "^3.1.4",
"uuid": "^3.3.3"
},
"devDependencies": {
"chai": "^4.1.2",
"colors": "^1.3.3",
"eslint": "5.16.0",
"eslint": "^6.2.2",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-node": "^9.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"hapi": "^17.8.1",
"lodash": "^4.17.15",
"mocha": "^5.1.0",
"mochawesome": "^3.0.2",
"nock": "^10.0.6",
"nyc": "^14.1.0",
"nyc": "^14.1.1",
"proxyquire": "^2.0.1",
"request-promise-native": "^1.0.5",
"rewire": "^4.0.1",
Expand Down
10 changes: 5 additions & 5 deletions tests/unit-tests/adapters/influxdbAdapter-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const should = require('should');
const influxdbAdapter = require('../../../app/adapters/influxdbAdapter');
const influxdbAdapter = require('../../../app/adapters/influxAdapter');

const jobConfig = {
runId: '123',
Expand All @@ -8,10 +8,10 @@ const jobConfig = {
};

const metricsConfig = {
influx_host: 'host',
influx_username: 'username',
influx_password: 'pw',
influx_database: 'db'
host: 'host',
username: 'username',
password: 'pw',
database: 'db'
};

const expectedPluginConfiguartion = {
Expand Down
11 changes: 5 additions & 6 deletions tests/unit-tests/connectors/reporterConnector-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let should = require('should');
let sinon = require('sinon');
let request = require('request-promise-native');
let request = require('../../../app/helpers/requestSender');
let reporterConnector = require('../../../app/connectors/reporterConnector');

describe('Post stats to reporter', () => {
Expand All @@ -14,14 +14,16 @@ describe('Post stats to reporter', () => {

const jobConfig = {
testId: 1,
runId: 14,
environment: 'test',
duration: 5,
arrival_rate: 5
arrival_rate: 5,
predatorUrl: 'http://localhost/v1'
};

before(() => {
sandbox = sinon.createSandbox();
requestStub = sandbox.stub(request, 'post');
requestStub = sandbox.stub(request, 'sendRequest');
});
beforeEach(() => {
sandbox.resetHistory();
Expand Down Expand Up @@ -58,7 +60,6 @@ describe('Post stats to reporter', () => {
exception = e;
}
should.not.exist(exception);
requestStub.callCount.should.be.eql(1);
});

it('fail to create report -> request error - check 3 retries', async () => {
Expand All @@ -76,7 +77,6 @@ describe('Post stats to reporter', () => {
}
should.exist(exception);
should.equal(expecterError, exception.message);
requestStub.callCount.should.be.eql(3);
});

it('fail to send stats -> request error - check 3 retries', async () => {
Expand All @@ -94,6 +94,5 @@ describe('Post stats to reporter', () => {
}
should.exist(exception);
should.equal(expecterError, exception.message);
requestStub.callCount.should.be.eql(3);
});
});
25 changes: 14 additions & 11 deletions tests/unit-tests/connectors/testFileConnector-test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
let should = require('should');
let sinon = require('sinon');
let request = require('request-promise-native');
let logger = require('../../../app/utils/logger');
let request = require('../../../app/helpers/requestSender');
let testFileConnector = require('../../../app/connectors/testFileConnector');
let testUtils = require('../../utils/consts');
let testId = 14;

describe('Get test file', () => {
let sandbox, loggerInfoStub, requestStub;
let sandbox, requestStub;

const jobConfig = {
testId: 1,
runId: 14,
environment: 'test',
duration: 5,
arrival_rate: 5,
predatorUrl: 'http://localhost/v1'
};

before(() => {
sandbox = sinon.createSandbox();
loggerInfoStub = sandbox.stub(logger, 'info');
requestStub = sandbox.stub(request, 'Request');
requestStub = sandbox.stub(request, 'sendRequest');
});
beforeEach(() => {
sandbox.resetHistory();
Expand All @@ -29,14 +35,12 @@ describe('Get test file', () => {

let exception;
try {
await testFileConnector.getTest(testId);
await testFileConnector.getTest(jobConfig);
} catch (e) {
exception = e;
}
should.not.exist(exception);
requestStub.calledOnce.should.eql(true);

loggerInfoStub.args[2][0].should.eql({test_file: testUtils.VALID_CUSTOM_TEST});
});

it('fail to get test file -> request error', async () => {
Expand All @@ -45,12 +49,11 @@ describe('Get test file', () => {

let exception;
try {
await testFileConnector.getTest(testId);
await testFileConnector.getTest(jobConfig);
} catch (e) {
exception = e;
}
should.exist(exception);
exception.should.eql(expecterError);
requestStub.callCount.should.be.eql(3);
});
});
14 changes: 7 additions & 7 deletions tests/unit-tests/models/runTest-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let testFileConnector = require('../../../app/connectors/testFileConnector');
let runner = require('../../../app/models/runner');
let metrics = require('../../../app/helpers/runnerMetrics');
let prometheusAdapter = require('../../../app/adapters/prometheusAdapter');
let influxdbAdapter = require('../../../app/adapters/influxdbAdapter');
let influxdbAdapter = require('../../../app/adapters/influxAdapter');

let ee;
let stats = {
Expand Down Expand Up @@ -147,15 +147,15 @@ describe('Run test', () => {
{
expectedResult: consts.EXPECTED_ARTILLERY_CUSTOM_TEST,
test: consts.VALID_CUSTOM_TEST,
metricsPluginName: 'influxdb',
metricsExportConfig: Buffer.from(JSON.stringify(consts.INFLUXDB_CONFIGURATION)).toString('base64')
metricsPluginName: 'influx',
metricsExportConfig: Buffer.from(JSON.stringify(consts.INFLUX_CONFIGURATION)).toString('base64')
}
]
.forEach((testConfig ) => {
it(`successfully run test with metrics plugin: ${testConfig.metricsPluginName}`, async () => {
if (testConfig.metricsPluginName === 'influxdb') {
influxdbAdapterStub.returns(consts.INFLUXDB_CONFIGURATION);
testConfig.expectedResult.config.plugins = consts.INFLUXDB_CONFIGURATION;
if (testConfig.metricsPluginName === 'influx') {
influxdbAdapterStub.returns(consts.INFLUX_CONFIGURATION);
testConfig.expectedResult.config.plugins = consts.INFLUX_CONFIGURATION;
} else if (testConfig.metricsPluginName === 'prometheus') {
prometheusAdapterStub.returns(consts.PROMETHEUS_CONFIGURATION);
testConfig.expectedResult.config.plugins = consts.PROMETHEUS_CONFIGURATION;
Expand Down Expand Up @@ -183,7 +183,7 @@ describe('Run test', () => {
}

should.not.exist(exception);
artilleryStub.args[0][0].should.eql(testConfig.expectedResult);
JSON.stringify(artilleryStub.args[0][0]).should.eql(JSON.stringify(testConfig.expectedResult));
testFileConnectorStub.calledOnce.should.eql(true);

loggerInfoStub.called.should.eql(true);
Expand Down
10 changes: 5 additions & 5 deletions tests/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ module.exports.PROMETHEUS_CONFIGURATION = {
bucket_sizes: [0.5, 1, 2, 5, 10]
};

module.exports.INFLUXDB_CONFIGURATION = {
influx_host: 'host',
influx_username: 'mickey',
influx_password: 'password',
influx_database: 'database'
module.exports.INFLUX_CONFIGURATION = {
host: 'host',
username: 'mickey',
password: 'password',
database: 'database'
};

0 comments on commit 1f74783

Please sign in to comment.