check disk graphs

This commit is contained in:
Girish Ramakrishnan 2016-04-05 18:43:30 -07:00
parent e168952f63
commit c05d6eb7b4
2 changed files with 32 additions and 16 deletions

View File

@ -306,16 +306,11 @@ Cloudron.prototype.checkA = function (callback) {
});
};
Cloudron.prototype.checkGraphs = function (appId) {
var timePeriod = 2 * 60; // in minutes
var timeBucketSize = 30; // in minutes
var target = 'summarize(collectd.localhost.table-' + appId + '-memory.gauge-rss, "' + timeBucketSize + 'min", "avg")';
Cloudron.prototype._checkGraphs = function (targets, from) {
var params = {
target: [ target ],
target: targets,
format: 'json',
from: '-' + timePeriod + 'min',
from: from,
access_token: this._credentials.accessToken
};
@ -323,19 +318,40 @@ Cloudron.prototype.checkGraphs = function (appId) {
for (var i = 0; i < 40; i++) {
sleep(10);
res = request.get(this._origin + '/api/v1/cloudron/graphs').query(params).end();
if (res.statusCode === 200) {
if (util.isArray(res.body) && res.body.length !== 0 && res.body[0].target && res.body[0].datapoints && res.body[0].datapoints.length !== 0) {
console.log();
console.log(res.body);
break;
}
}
process.stdout.write('.');
if (res.statusCode !== 200) continue;
if (!util.isArray(res.body) && res.body.length !== targets.length) continue;
for (var j = 0; j < res.body.length; j++) {
if (res.body[j].datapoints.length === 0) break; // no data
console.log();
console.log(res.body);
return; // success
}
}
assert(false, 'Graphs are not populated');
};
Cloudron.prototype.checkAppGraphs = function (appId) {
var timePeriod = 2 * 60; // in minutes
var timeBucketSize = 30; // in minutes
var target = 'summarize(collectd.localhost.table-' + appId + '-memory.gauge-rss, "' + timeBucketSize + 'min", "avg")';
this._checkGraphs([target], '-' + timePeriod + 'min');
};
Cloudron.prototype.checkDiskGraphs = function () {
var targets = [
'averageSeries(collectd.localhost.df-loop*.df_complex-free)',
'averageSeries(collectd.localhost.df-loop*.df_complex-reserved)',
'averageSeries(collectd.localhost.df-loop*.df_complex-used)'
];
this._checkGraphs(targets, '-1min');
};
Cloudron.prototype.checkSPF = function (callback) {
var that = this;
dns.resolveTxt(this._box.domain, function (error, records) {

View File

@ -76,7 +76,7 @@ describe('Application flow test', function () {
});
it('displays app graphs', function () {
cloudron.checkGraps(appId);
cloudron.checkAppGraphs(appId);
});
it('can configure app', function () {