check app graphs
This commit is contained in:
parent
e609ae88d4
commit
e168952f63
33
cloudron.js
33
cloudron.js
@ -10,7 +10,8 @@ var assert = require('assert'),
|
||||
request = require('superagent-sync'),
|
||||
semver = require('semver'),
|
||||
sleep = require('sleep').sleep,
|
||||
url = require('url');
|
||||
url = require('url'),
|
||||
util = require('util');
|
||||
|
||||
exports = module.exports = Cloudron;
|
||||
|
||||
@ -305,6 +306,36 @@ 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")';
|
||||
|
||||
var params = {
|
||||
target: [ target ],
|
||||
format: 'json',
|
||||
from: '-' + timePeriod + 'min',
|
||||
access_token: this._credentials.accessToken
|
||||
};
|
||||
|
||||
var res;
|
||||
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('.');
|
||||
}
|
||||
|
||||
assert(false, 'Graphs are not populated');
|
||||
};
|
||||
|
||||
Cloudron.prototype.checkSPF = function (callback) {
|
||||
var that = this;
|
||||
dns.resolveTxt(this._box.domain, function (error, records) {
|
||||
|
@ -75,6 +75,10 @@ describe('Application flow test', function () {
|
||||
cloudron.checkAddons(location, owner);
|
||||
});
|
||||
|
||||
it('displays app graphs', function () {
|
||||
cloudron.checkGraps(appId);
|
||||
});
|
||||
|
||||
it('can configure app', function () {
|
||||
location = location + 'x';
|
||||
cloudron.configureApp(appId, location);
|
||||
|
Loading…
Reference in New Issue
Block a user