kaanalnet
Version:
Virtual Network Emulator Lab for SDN and traditional networks
72 lines (58 loc) • 1.93 kB
JavaScript
// Generated by CoffeeScript 1.9.3
(function() {
var Test, extend, log, request, util;
util = require('util');
request = require('request-json');
extend = require('util')._extend;
log = require('./utils/logger').getLogger();
log.info("Test - Logger test message");
Test = (function() {
function Test(data) {
this.config = extend({}, data);
this.testsuiteid = data.testsuiteid;
this.statistics = {};
this.status = {};
log.info("Test object created with " + JSON.stringify(this.config));
}
Test.prototype.start = function(callback) {
var client;
log.info("starting a test " + JSON.stringify(this.config));
this.URL = "http://" + this.config.source + ":5051";
log.info("Agent url is " + this.URL);
client = request.newClient(this.URL);
return client.post('/Test', this.config, (function(_this) {
return function(err, res, body) {
if (err != null) {
log.info("err" + JSON.stringify(err));
}
log.info("start test result " + JSON.stringify(body));
_this.uuid = body.id;
return callback(_this.body);
};
})(this));
};
Test.prototype.run = function(callback) {
return this.start((function(_this) {
return function(result) {
return callback(result);
};
})(this));
};
Test.prototype.get = function(callback) {
var client;
client = request.newClient(this.URL);
return client.get("/Test/" + this.uuid, (function(_this) {
return function(err, res, body) {
if (err != null) {
log.info("err" + JSON.stringify(err));
}
log.info("get test result " + JSON.stringify(body));
_this.status = body;
return callback(body);
};
})(this));
};
return Test;
})();
module.exports = Test;
}).call(this);