Skip to content

Commit

Permalink
[OGUI-484] Add checks for errors in mysql sources (#448)
Browse files Browse the repository at this point in the history
* [OGUI-484] Add checks for errors in mysql sources

* [OGUI-484] Use latest version of web-ui

* [OGUI-484] Increase timeout

* [OGUI-484] Use new web-ui
  • Loading branch information
graduta authored Feb 18, 2020
1 parent f6626b6 commit 4526b15
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 53 deletions.
3 changes: 2 additions & 1 deletion InfoLogger/config-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = {
user: 'root',
password: 'root',
database: 'INFOLOGGER',
port: 3306
port: 3306,
timeout: 60000
},

// optional data source, comment object if not used
Expand Down
26 changes: 19 additions & 7 deletions InfoLogger/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ const jsonDb = new JsonFileConnector(config.dbFile || __dirname + '/../db.json')

if (config.mysql) {
log.info(`Detected InfoLogger database configration`);
const connection = new MySQL(config.mysql);
querySource = new SQLDataSource(connection, config.mysql);
querySource.isConnectionUpAndRunning();
const connector = new MySQL(config.mysql);
connector.testConnection().then(() => {
querySource = new SQLDataSource(connector, config.mysql);
querySource.isConnectionUpAndRunning().catch((error) => {
log.error(`Unable to instantiate data source due to ${error}`);
querySource = null;
});
}).catch((error) => {
log.error(`Unable to connect to mysql due to ${error}`);
querySource = null;
});
} else {
log.warn(`InfoLogger databse config not found, Query mode not available`);
log.warn(`InfoLogger database config not found, Query mode not available`);
}

if (config.infoLoggerServer) {
Expand Down Expand Up @@ -54,9 +62,13 @@ module.exports.attachTo = (http, ws) => {
* @param {Response} res
*/
function query(req, res) {
querySource.queryFromFilters(req.body.criterias, req.body.options)
.then((result) => res.json(result))
.catch((error) => handleError(res, error));
if (querySource) {
querySource.queryFromFilters(req.body.criterias, req.body.options)
.then((result) => res.json(result))
.catch((error) => handleError(res, error));
} else {
handleError(res, 'MySQL Data Source is not available');
}
}

/**
Expand Down
94 changes: 54 additions & 40 deletions InfoLogger/package-lock.json

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

6 changes: 3 additions & 3 deletions InfoLogger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@aliceo2/infologger",
"version": "1.2.2",
"description": "Infologger GUI to query and stream log events",
"author": "Vladimir Kosmala",
"author": "Vladimir Kosmala",
"contributors": [
"George Raduta",
"Adam Wegrzynek"
Expand All @@ -27,7 +27,7 @@
"coverage-local": "nyc --reporter=lcov npm run mocha"
},
"dependencies": {
"@aliceo2/web-ui": "1.9.1"
"@aliceo2/web-ui": "1.9.4"
},
"devDependencies": {
"eslint": "^5.15.0",
Expand All @@ -38,4 +38,4 @@
"sinon": "^7.3.2"
},
"main": "index.js"
}
}
6 changes: 5 additions & 1 deletion InfoLogger/public/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ export default class Model extends Observable {
}

if (!result.query && !result.live) {
this.notification.show(`No service configured`, 'danger', Infinity);
this.notification.show(`No QUERY / LIVE services configured`, 'danger', Infinity);
} else if (!result.query) {
this.notification.show(`No QUERY service configured`, 'danger', Infinity);
} else if (!result.live) {
this.notification.show(`No LIVE service configured`, 'danger', Infinity);
}

this.servicesResult = RemoteData.success(result);
Expand Down
2 changes: 1 addition & 1 deletion InfoLogger/test/mocha-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe('InfoLogger', function() {
window.model.log.filter.setCriteria('hostname', 'match', 'aldaqecs01-v1');
});
await page.evaluate(() => window.model.log.liveStart());
await page.waitFor(5000);
await page.waitFor(7000);
const list = await page.evaluate(() => window.model.log.list);
await page.waitFor(1000);
const isHostNameMatching = list.map((element) => element.hostname).every((hostname) => hostname === 'aldaqecs01-v1');
Expand Down

0 comments on commit 4526b15

Please sign in to comment.