UNPKG

cloud-blender

Version:

A high level library for cloud compute operations

289 lines (203 loc) 6.88 kB
var should = require('should'), underscore = require('underscore'), compute = require('../lib/azure_v2.js'), azureConfig = require('../examples/azure_v2.json') process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0; compute.setProxy('http://web-proxy.isr.hp.com:8080'); var providerName = 'azure_v2', regionAuthSettings = azureConfig, regionLimits = {}, node1, image1; var regionContext = compute.createRegionContext(regionAuthSettings, regionLimits); describe('checking azure local atomic lib', function () { it('should create an authentication context', function () { var regionContext = compute.createRegionContext(regionAuthSettings, regionLimits); should.exist(regionContext.cloudRegion); should.exist(regionContext.providerName); should.exist(regionContext.groupId); should.exist(regionContext.tenantId); should.exist(regionContext.clientId); should.exist(regionContext.secret); }); }); describe('checking azure atomic lib', function () { var regionContext = compute.createRegionContext(regionAuthSettings, regionLimits); /* it('should delete unnecessary objects', function (done) { var settingsDelete = { regionContext: regionContext }; this.timeout(300000); compute.deleteObjects(settingsDelete,function (error, result1) { if (error[0]) { console.log('error delete objects-' + error); done(); return; } should.not.exist(error[0]); done(); }); }); /* it('should launch instance on azure', function (done) { var settingsCreate = { regionContext: regionContext, nodeParams: { imageId: 'image1447864142926-osDisk.ae7c694f-4451-4db8-be22-bb4369cc070b.vhd', instanceType: 'Standard_D2', securityGroups: ['test1234'], tags: { jobId: 'dummyJobId', env: 'test', role: 'injector-Test', environment:'test_linux' }, userData: {'paramA': 'keyA', 'paramB': 'keyB', 'paramC': 'keyc'} } }; this.timeout(300000); compute.createNode(settingsCreate, null, 0, function (error1, result1) { if (error1) { console.log('error creating node1-' + error1); done(); return; } node1 = result1.node; should.not.exist(error1); done(); }); }); /* it('should get a list of nodes from azure and find the node which was created', function (done) { var waitInterval = 120000, settings = { regionContext: regionContext }; this.timeout(200000); compute.listNodes(settings, function (error, result) { if (error) { console.log('error get node list-' + error); done(); return; } console.log('result-' + JSON.stringify(result)) should.not.exist(error); done(); }); }); it('should get a list of nodes from azure and find the node which was created', function (done) { var waitInterval = 1000 * 120, settings = { regionContext: regionContext }; this.timeout(waitInterval); compute.listNodes(settings, function (error, result) { if (error) { console.log('error get node list-' + error); done(); return; } console.log('result-' + JSON.stringify(result)) should.not.exist(error); done(); }); })*/ it('should create image from the first node which was created', function (done) { var waitInterval = 1*45, settingsList = { regionContext: regionContext }; this.timeout(1000*500); setTimeout(function () { var settingsImage = { regionContext: regionContext, imageParams: { nodeId: 'winSU', tags: { 'creationDate': new Date(), 'createdFor': 'test purposes', 'logicName': 'dummy-image' }, vendorSpecificParams: { Description: 'blah blah blah created by a dummy test' } } }; compute.createImage(settingsImage, function (error, resultImage) { console.log('resultImage-'+JSON.stringify(resultImage)) if (error) { console.log('error create image-' + error); done(); return; } image1=resultImage.imageId; done(); }); },waitInterval) }); /* it('should get a list of images from azure in find the image which was created', function (done) { var waitInterval = 1000*230, settings = { regionContext: regionContext }; this.timeout(1000*5600); setTimeout(function () { compute.listImages(settings,null,function (error, result) { if (error) { console.log('error get image list-' + error); done(); return; } console.log('result-'+JSON.stringify(result)) done(); }); }, waitInterval); }); it('should delete image from azure', function (done) { var waitInterval = 1000*260; this.timeout(1000*700); setTimeout(function () { var settingsDelImage = { regionContext: regionContext, imageParams: { imageId: image1 } } console.log('image -' + settingsDelImage.imageParams.imageId + ' will be deleted'); if (settingsDelImage.imageParams.imageId) { compute.deleteImage(settingsDelImage, function (error, result) { if (error) { console.log('error delete image-' + error); done(); return; } should.not.exist(error); done(); }); } }, waitInterval); }); it('should delete instance from azure', function (done) { var waitInterval = 1000*300; this.timeout(1000*800); setTimeout(function () { var settingsDelete = { regionContext: regionContext, node: node1 }; console.log(settingsDelete.node.id+'- will be deleted') compute.deleteNode(settingsDelete, function (error, result) { if (error) { console.log('error delete node-' + error); done(); return; } done(); }); },waitInterval); }); */ });