UNPKG

jchaos

Version:

module to access chaos resources

152 lines (130 loc) 5.5 kB
var assert = require('assert'); //var assert = require('chai').assert; var jchaos = require('jchaos'); options = {}; process.argv.forEach(function (val, index, array) { if (val == "uri") { options.uri = array[index + 1]; console.log(val + "=" + array[index + 1]); } if (val == "async") { options.async = (array[index + 1] == "true"); console.log(val + "=" + array[index + 1]); } if (val == "npush") { npush = (array[index + 1]); console.log(val + "=" + array[index + 1]); } }); var cualive = []; var status_to_check = ["Start", "Stop", "Init", "Deinit", "Fatal Error", "Recoverable Error"]; var cualive_by_status = []; var cualive_ds = []; var cu_all = []; var class_alive = []; var class_all = []; var zone_alive = []; var zone_all = []; var tot_ok = 0; var cu_in_start=[]; jchaos.setOptions(options); describe('CHAOS TEST TRANSITIONS', function () { this.timeout(120000); it('check Start->Stop', function (done) { cu_in_start = []; jchaos.getCUStatus("Start", function (ll) { console.log("\tN. CU in Start:" + ll.length); cu_in_start = ll; if (cu_in_start.length == 0) done(); jchaos.node(cu_in_start, "stop", "cu", (ok)=>{ jchaos.checkLive('\tCheck Start->Stop',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Stop"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); }); it('check Stop->Deinit', function (done) { jchaos.node(cu_in_start, "deinit", "cu", (ok)=>{ jchaos.checkLive('\tCheck Stop->Deinit',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Deinit"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); it('check Deinit->Init', function (done) { var cu_status = []; jchaos.node(cu_in_start, "init", "cu", (ok)=>{ jchaos.checkLive('\tCheck Deinit->Init',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Init"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); it('check Init->Start', function (done) { var cu_status = []; jchaos.node(cu_in_start, "start", "cu", (ok)=>{ jchaos.checkLive('\tCheck Init->Start',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Start"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); it('check2 Start->Stop', function (done) { var cu_status = []; jchaos.node(cu_in_start, "stop", "cu", (ok)=>{ jchaos.checkLive('\tCheck2 Start->Stop',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Stop"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); it('check2 Stop->Deinit', function (done) { var cu_status = []; jchaos.node(cu_in_start, "deinit", "cu", (ok)=>{ jchaos.checkLive('\tCheck2 Stop->Deinit',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Deinit"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); it('check Deinit->Unload', function (done) { var cu_status = []; jchaos.node(cu_in_start, "unload", "cu", (ok)=>{ jchaos.checkLive('\tCheck Deinit->Unload',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Unload"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); it('check Unload->Load', function (done) { var cu_status = []; jchaos.node(cu_in_start, "load", "cu", (ok)=>{ jchaos.checkLive('\tUnload->Load',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Load"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); it('check Load->Init', function (done) { var cu_status = []; jchaos.node(cu_in_start, "init", "cu", (ok)=>{ jchaos.checkLive('\tLoad->Init',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Init"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); it('check3 Init->Start', function (done) { var cu_status = []; jchaos.node(cu_in_start, "start", "cu", (ok)=>{ jchaos.checkLive('\tCheck3 Init->Start',cu_in_start, 20, 5000, function (ds) { return (ds!=null)&&ds.hasOwnProperty("health")&&ds.health.hasOwnProperty("nh_status")&&(ds.health.nh_status == "Start"); }, function () { done(0); }, function () { done(1) }); },(bad)=>{ console.log("command failed"); done(1); }); }); });