mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
introduced tests for volume feature
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ bgpalerter.pid
|
||||
alertdata/
|
||||
.npmrc
|
||||
.cache/
|
||||
volumetests/
|
@@ -10,3 +10,4 @@ bgpalerter.pid
|
||||
alertdata/
|
||||
.npmrc
|
||||
.cache/
|
||||
volumetests/
|
||||
|
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"babel": "./node_modules/.bin/babel",
|
||||
"test": "./node_modules/.bin/mocha --exit tests/*.js --require @babel/register",
|
||||
"test": "rm -rf volumetests/ && ./node_modules/.bin/mocha --exit tests/*.js --require @babel/register && rm -rf volumetests/",
|
||||
"build": "./build.sh",
|
||||
"watch-and-serve": "nodemon -e yml,js,json,txt --inspect --exec babel-node index.js",
|
||||
"serve": "babel-node index.js",
|
||||
|
@@ -34,27 +34,22 @@ const chai = require("chai");
|
||||
const chaiSubset = require('chai-subset');
|
||||
const readLastLines = require('read-last-lines');
|
||||
const moment = require('moment');
|
||||
const fs = require('fs');
|
||||
chai.use(chaiSubset);
|
||||
const expect = chai.expect;
|
||||
|
||||
const volume = "volumetests/";
|
||||
const asyncTimeout = 20000;
|
||||
global.EXTERNAL_VERSION_FOR_TEST = "0.0.1";
|
||||
global.EXTERNAL_CONFIG_FILE = "tests/config.test.yml";
|
||||
global.EXTERNAL_CONFIG_FILE = volume + "config.test.yml";
|
||||
|
||||
describe("Composition", function() {
|
||||
// Prepare test environment
|
||||
if (!fs.existsSync(volume)) {
|
||||
fs.mkdirSync(volume);
|
||||
}
|
||||
fs.copyFileSync("tests/config.test.yml", volume + "config.test.yml");
|
||||
fs.copyFileSync("tests/prefixes.test.yml", volume + "prefixes.test.yml");
|
||||
|
||||
describe("Software updates check", function () {
|
||||
it("new version detected", function (done) {
|
||||
|
||||
const worker = require("../index");
|
||||
const pubSub = worker.pubSub;
|
||||
|
||||
pubSub.subscribe("software-update", function (type, message) {
|
||||
expect(type).to.equal("software-update");
|
||||
done();
|
||||
});
|
||||
}).timeout(asyncTimeout);
|
||||
});
|
||||
describe("Tests", function() {
|
||||
|
||||
describe("Configuration loader", function () {
|
||||
const worker = require("../index");
|
||||
@@ -85,6 +80,14 @@ describe("Composition", function() {
|
||||
.property('class')
|
||||
});
|
||||
|
||||
it("volume setting", function () {
|
||||
expect(config.volume).to.equals(volume);
|
||||
});
|
||||
|
||||
it("check for updates setting", function () {
|
||||
expect(config.checkForUpdatesAtBoot).to.equals(true);
|
||||
});
|
||||
|
||||
it("loading connectors", function () {
|
||||
expect(config.connectors[0]).to
|
||||
.containSubset({
|
||||
@@ -185,6 +188,19 @@ describe("Composition", function() {
|
||||
|
||||
});
|
||||
|
||||
describe("Software updates check", function () {
|
||||
it("new version detected", function (done) {
|
||||
|
||||
const worker = require("../index");
|
||||
const pubSub = worker.pubSub;
|
||||
|
||||
pubSub.subscribe("software-update", function (type, message) {
|
||||
expect(type).to.equal("software-update");
|
||||
done();
|
||||
});
|
||||
}).timeout(asyncTimeout);
|
||||
});
|
||||
|
||||
describe("Input loader", function () {
|
||||
const worker = require("../index");
|
||||
const input = worker.input;
|
||||
@@ -326,7 +342,7 @@ describe("Composition", function() {
|
||||
message: message
|
||||
});
|
||||
|
||||
const file = config.logging.directory + "/error-" + moment().format('YYYY-MM-DD') + ".log";
|
||||
const file = volume + config.logging.directory + "/error-" + moment().format('YYYY-MM-DD') + ".log";
|
||||
readLastLines
|
||||
.read(file, 1)
|
||||
.then((line) => {
|
||||
@@ -347,7 +363,7 @@ describe("Composition", function() {
|
||||
message: message
|
||||
});
|
||||
|
||||
const file = config.logging.directory + "/reports-" + moment().format('YYYY-MM-DD') + ".log";
|
||||
const file = volume + config.logging.directory + "/reports-" + moment().format('YYYY-MM-DD') + ".log";
|
||||
readLastLines
|
||||
.read(file, 1)
|
||||
.then((line) => {
|
||||
|
@@ -34,14 +34,14 @@ const chai = require("chai");
|
||||
const chaiSubset = require('chai-subset');
|
||||
chai.use(chaiSubset);
|
||||
const expect = chai.expect;
|
||||
|
||||
const volume = "volumetests/";
|
||||
const asyncTimeout = 20000;
|
||||
global.EXTERNAL_VERSION_FOR_TEST = "0.0.1";
|
||||
global.EXTERNAL_CONFIG_FILE = "tests/config.test.yml";
|
||||
global.EXTERNAL_CONFIG_FILE = volume + "config.test.yml";
|
||||
|
||||
describe("Alerting", function () {
|
||||
const worker = require("../index");
|
||||
const pubSub = worker.pubSub;
|
||||
var worker = require("../index");
|
||||
var pubSub = worker.pubSub;
|
||||
|
||||
it("visibility reporting", function(done) {
|
||||
|
||||
|
@@ -35,10 +35,10 @@ const chaiSubset = require('chai-subset');
|
||||
const axios = require('axios');
|
||||
chai.use(chaiSubset);
|
||||
const expect = chai.expect;
|
||||
|
||||
const volume = "volumetests/";
|
||||
const asyncTimeout = 20000;
|
||||
global.EXTERNAL_VERSION_FOR_TEST = "0.0.1";
|
||||
global.EXTERNAL_CONFIG_FILE = "tests/config.test.yml";
|
||||
global.EXTERNAL_CONFIG_FILE = volume + "config.test.yml";
|
||||
|
||||
describe("Uptime Monitor", function() {
|
||||
|
||||
|
@@ -65,7 +65,7 @@ reports:
|
||||
# The file containing the monitored prefixes. Please see monitored_prefixes_test.yml for an example
|
||||
# This is an array (use new lines and dashes!)
|
||||
monitoredPrefixesFiles:
|
||||
- tests/prefixes.test.yml
|
||||
- prefixes.test.yml
|
||||
|
||||
logging:
|
||||
directory: logs
|
||||
@@ -78,6 +78,8 @@ logging:
|
||||
checkForUpdatesAtBoot: true
|
||||
persistStatus: true
|
||||
|
||||
volume: volumetests/
|
||||
|
||||
processMonitors:
|
||||
- file: uptimeApi
|
||||
params:
|
||||
|
Reference in New Issue
Block a user