Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vmss #137

Merged
merged 2 commits into from Jan 31, 2016
Merged

Vmss #137

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/commands/asm/vm/vmclient.js
Expand Up @@ -215,7 +215,10 @@ _.extend(VMClient.prototype, {
if (roles) {
for (var j = 0; j < roles.length; j++) {
if (roles[j].roleType === 'PersistentVMRole') {
vms.push(createVMView(roles[j], deployments[i], logger));
var vm = createVMView(roles[j], deployments[i], logger);
if (vm !== null) {
vms.push(vm);
}
}
}
}
Expand Down Expand Up @@ -254,7 +257,10 @@ _.extend(VMClient.prototype, {
for (var j = 0; j < roles.length; j++) {
if (roles[j].roleType === 'PersistentVMRole' &&
roles[j].roleName === name) {
vms.push(createVMView(roles[j], deployments[i], logger));
var vm = createVMView(roles[j], deployments[i], logger);
if (vm !== null) {
vms.push(vm);
}
}
}
}
Expand Down Expand Up @@ -3148,10 +3154,10 @@ var svcParams = {

// helpers methods
function createVMView(role, deployment, logger) {
var roleInstance = getRoleInstance(role.roleName, deployment.deploy);
var networkConfigSet = getNetworkConfigSet(role);
var result = null;
try {
var roleInstance = getRoleInstance(role.roleName, deployment.deploy);
var networkConfigSet = getNetworkConfigSet(role);
result = {
DNSName: (deployment.deploy && deployment.deploy.uri) ? url.parse(deployment.deploy.uri).host : '',
Location: deployment.Location,
Expand Down
133 changes: 95 additions & 38 deletions test/commands/cli.vm.list_show-tests.js
Expand Up @@ -14,52 +14,109 @@
*/
var should = require('should');
var util = require('util');
var fs = require('fs');
var testUtils = require('../util/util');
var CLITest = require('../framework/cli-test');
var vmTestUtil = require('../util/asmVMTestUtil');

var suite;
var vmPrefix = 'clitestvm';
var createdVms = [];
var testPrefix = 'cli.vm.list_show-tests';

var requiredEnvironment = [{
name: 'AZURE_VM_TEST_LOCATION',
defaultValue: 'West US'
}, {
name: 'SSHCERT',
defaultValue: 'test/myCert.pem'
}];

describe('cli', function() {
describe('vm', function() {
var vmName, retry = 5;
before(function(done) {
suite = new CLITest(this, testPrefix, []);
suite.setupSuite(done);
});
after(function(done) {
suite.teardownSuite(done);
});
beforeEach(function(done) {
suite.setupTest(done);
});
afterEach(function(done) {
suite.teardownTest(done);
});
describe('Vm', function() {
//location list
it('Location List', function(done) {
var cmd = util.format('vm location list --json').split(' ');
testUtils.executeCommand(suite, retry, cmd, function(result) {
result.exitStatus.should.equal(0);
result.text.should.not.empty;
done();
});
});
it('List and Show', function(done) {
var cmd = util.format('vm list --json').split(' ');
describe('vm', function() {
var customVmName;
var fileName = 'customdata',
certFile,
timeout,
location,
retry,
vmsize = 'Small',
sshPort = '223',
username = 'azureuser';
testUtils.TIMEOUT_INTERVAL = 5000;
var vmUtil = new vmTestUtil();

var vmToUse = {
Name: null,
Created: false,
Delete: false
};

before(function(done) {
suite = new CLITest(this, testPrefix, requiredEnvironment);
suite.setupSuite(done);
});

after(function(done) {
suite.teardownSuite(done);
});

beforeEach(function(done) {
suite.setupTest(function() {
location = process.env.AZURE_VM_TEST_LOCATION;
customVmName = suite.generateId(vmPrefix, createdVms);
certFile = process.env.SSHCERT;
timeout = suite.isPlayback() ? 0 : testUtils.TIMEOUT_INTERVAL;
retry = 5;
done();
});
});

afterEach(function(done) {
vmUtil.deleteUsedVM(vmToUse, timeout, suite, function() {
suite.teardownTest(done);
});
});

describe('Create VM for Show and List:', function() {
it('create vm for show and list', function(done) {
vmUtil.getImageName('Linux', suite, function(vmImgName) {
vmUtil.generateFile(fileName, null, 'nodejs,python,wordpress');
var cmd = util.format('vm create -e %s -z %s --ssh-cert %s --no-ssh-password %s %s %s -d %s --json --verbose',
sshPort, vmsize, certFile, customVmName, vmImgName, username, fileName).split(' ');
cmd.push('-l');
cmd.push(location);
testUtils.executeCommand(suite, retry, cmd, function(result) {
result.exitStatus.should.equal(0);
var verboseString = result.text;
var iPosCustom = verboseString.indexOf('customdata');
iPosCustom.should.not.equal(-1);
fs.unlinkSync(fileName);
vmToUse.Name = customVmName;
vmToUse.Created = true;
vmToUse.Delete = true;
var cmd = util.format('vm location list --json').split(' ');
testUtils.executeCommand(suite, retry, cmd, function(result) {
result.exitStatus.should.equal(0);
result.text.should.not.empty;
var cmd = util.format('vm list --json').split(' ');
testUtils.executeCommand(suite, retry, cmd, function(result) {
result.exitStatus.should.equal(0);
var vmList = JSON.parse(result.text);
vmList.length.should.be.above(0);
vmName = vmList[0].VMName;
var cmd = util.format('vm show %s --json', vmName).split(' ');
testUtils.executeCommand(suite, retry, cmd, function(result) {
result.exitStatus.should.equal(0);
var vmList = JSON.parse(result.text);
vmList.length.should.be.above(0);
vmName = vmList[0].VMName;
cmd = util.format('vm show %s --json', vmName).split(' ');
testUtils.executeCommand(suite, retry, cmd, function(result) {
result.exitStatus.should.equal(0);
var vmObj = JSON.parse(result.text);
vmObj.VMName.should.equal(vmName);
done();
});
result.exitStatus.should.equal(0);
var vmObj = JSON.parse(result.text);
vmObj.VMName.should.equal(vmName);
done();
});
});
});
});
});
});
});
});
});

Large diffs are not rendered by default.

561 changes: 15 additions & 546 deletions test/recordings/cli.vm.list_show-tests/cli_vm_Vm_List_and_Show.nock.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Expand Up @@ -6,13 +6,14 @@ exports.getMockedProfile = function () {
var newProfile = new profile.Profile();

newProfile.addSubscription(new profile.Subscription({
id: 'bfb5e0bf-124b-4d0c-9352-7c0a9f4d9948',
name: 'CollaberaInteropTest',
id: 'e33f361b-53c2-4cc7-b829-78906708387b',
name: 'Microsoft Azure Internal Consumption',
user: {
name: 'user@domain.example',
type: 'user'
},
tenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47',
state: 'Enabled',
registeredProviders: [],
isDefault: true
}, newProfile.environments['AzureCloud']));
Expand All @@ -21,6 +22,8 @@ exports.getMockedProfile = function () {
};

exports.setEnvironment = function() {
process.env['AZURE_VM_TEST_LOCATION'] = 'Central US';
process.env['SSHCERT'] = 'test/myCert.pem';
};

exports.scopes = [];
1 change: 1 addition & 0 deletions test/testlist-vm-live.txt
@@ -1,4 +1,5 @@
# Live + Playback
commands/cli.vm.list_show-tests.js
commands/cli.vm.create_affin_vnet_vm-tests.js
commands/cli.vm.create_vnet_multi_nic-tests.js
commands/cli.vm.capture-tests.js
Expand Down