Skip to content

Commit

Permalink
Revert "Test Fixes for live production"
Browse files Browse the repository at this point in the history
This reverts commit 2541201.
  • Loading branch information
acharyarajiv committed Apr 24, 2014
1 parent 2541201 commit bb42175
Show file tree
Hide file tree
Showing 3 changed files with 307 additions and 311 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ Next, provide the following parameters by setting environment variables:
- `AZURE_GITHUB_REPOSITORY` - name an empty GitHub repository to use during tests (e.g. `tjanczuk/clitest`)
- `SSHCERT` - path of SSH Certificate (eg. `path\cert.pem`)
- `BLOB_SOURCE_PATH` - source url path for disk upload (`container\subcontainer\disk.vhd`)
- `AZURE_COMMUNITY_IMAGE_ID` - Community image id


To run the tests, call
Expand Down
112 changes: 55 additions & 57 deletions test/commands/cli.vm-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var should = require('should');
var sinon = require('sinon');
var util = require('util');
var crypto = require('crypto');
var fs = require('fs');
var path = require('path');
var isForceMocked = !process.env.NOCK_OFF;

var utils = require('../../lib/util/utils');
var testUtils = require('../util/util');
var CLITest = require('../framework/cli-test');

var communityImageId = process.env['AZURE_COMMUNITY_IMAGE_ID'];
var storageAccountKey = process.env['AZURE_STORAGE_ACCESS_KEY'] ? process.env['AZURE_STORAGE_ACCESS_KEY'] : 'YW55IGNhcm5hbCBwbGVhc3VyZQ==';
var storageAccountKey = process.env['AZURE_STORAGE_ACCOUNT'] ? process.env['AZURE_STORAGE_ACCOUNT'] : 'YW55IGNhcm5hbCBwbGVhc3VyZQ==';
var createdDisks = [];

// A common VM used by multiple tests
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('cli', function () {
location;

before(function (done) {
suite = new CLITest(testPrefix, isForceMocked);
suite = new CLITest(testPrefix, true);

if (suite.isMocked) {
sinon.stub(crypto, 'randomBytes', function () {
Expand All @@ -78,7 +78,7 @@ describe('cli', function () {
(function deleteUsedDisk() {
if (createdDisks.length > 0) {
var diskName = createdDisks.pop();
suite.execute('vm disk delete -b %s --json', diskName, function (result) {
suite.execute('vm disk delete -b %s --json', diskName, function () {
deleteUsedDisk();
});
} else {
Expand All @@ -95,7 +95,7 @@ describe('cli', function () {
afterEach(function (done) {
function deleteUsedVM(vm, callback) {
if (vm.Created && vm.Delete) {
suite.execute('vm delete %s -b --quiet --json', vm.Name, function (result) {
suite.execute('vm delete %s -b --json --quiet', vm.Name, function () {
vm.Name = null;
vm.Created = vm.Delete = false;
return callback();
Expand Down Expand Up @@ -220,11 +220,11 @@ describe('cli', function () {

// Negative Test Case by specifying VM Name Twice
it('Negavtive test case by specifying Vm Name Twice', function (done) {
var vmNegName = vmName;
var vmNegName = 'xplattestvm';
suite.execute('vm create %s %s "azureuser" "Pa$$word@123" --json --location %s',
vmNegName, vmImgName, location, function (result) {
result.exitStatus.should.equal(1);
result.errorText.should.include('A VM with dns prefix "xplattestvm" already exists');
result.errorText.should.include(' A VM with dns prefix "xplattestvm" already exists');
return done();
});
});
Expand All @@ -247,7 +247,7 @@ describe('cli', function () {

// Attach-New
it('Attach-New', function (done) {
var blobUrl = domainUrl + '/disks/' + suite.generateId(vmPrefix, null) + '.vhd';
var blobUrl = domainUrl + '/disks/xplattestDiskUpload.vhd';
suite.execute('vm disk attach-new %s %s %s --json', vmName, 1, blobUrl, function (result) {
result.exitStatus.should.equal(0);
suite.execute('vm disk detach %s 0 --json', vmName, function (result) {
Expand Down Expand Up @@ -395,7 +395,9 @@ describe('cli', function () {
suite.execute('vm show %s --json', vnetVmName, function (result) {
var vmVnet = JSON.parse(result.text);
createdDisks.push(vmVnet.OSDisk.DiskName);
done();
vmToUse.Name = vnetVmName;
vmToUse.Created = true;
return done();
});
});
});
Expand All @@ -417,7 +419,7 @@ describe('cli', function () {
return ep.Name.toLowerCase() === vmEndpointName.toLowerCase();
});
epExists.should.be.ok;
done();
return done();
});
});
});
Expand Down Expand Up @@ -531,8 +533,6 @@ describe('cli', function () {
endPointListLbVmSetAndProb[0].LoadBalancerProbe.Port.should.be.equal(endPoints.PPLPLBSetAndProb.ProbPort);

// Set Delete to true if this is the last test using shared vm
vmToUse.Name = vnetVmName;
vmToUse.Created = true;
vmToUse.Delete = true;
done();
});
Expand Down Expand Up @@ -596,45 +596,6 @@ describe('cli', function () {
});
});

// Create VM with custom data
it('Create vm with custom data', function (done) {
var customVmName = vmName + 'customdata';
var fileName = 'customdata';
generateFile(fileName, null, 'nodejs,python,wordpress');
suite.execute('vm create %s %s testuser Collabera@01 -l %s -d %s --json --verbose',
customVmName, vmImgName, location, fileName, function (result) {
result.exitStatus.should.equal(0);
var verboseString = result.text;
var iPosCustom = verboseString.indexOf('CustomData:');
iPosCustom.should.equal(-1);
fs.unlink(fileName, function (err) {
if (err)
throw err;
vmToUse.Name = customVmName;
vmToUse.Created = true;
vmToUse.Delete = true;
return done();
});
});
});

// Create VM with custom data with large file as customdata file
it('negetive testcase for custom data - Large File', function (done) {
var customVmName = vmName + 'customdatalargefile';
var fileName = 'customdatalargefile';
generateFile(fileName, 70000, null);
suite.execute('vm create %s %s testuser Collabera@01 -l %s -d %s --json',
customVmName, vmImgName, location, fileName, function (result) {
result.exitStatus.should.equal(1);
result.errorText.should.include('Input custom data file exceeded the maximum length of 65535 bytes');
fs.unlink(fileName, function (err) {
if (err)
throw err;
return done();
});
});
});

// Delete a Vnet
it('Delete Vnet', function (done) {
suite.execute('network vnet delete %s --quiet --json', vnetName, function (result) {
Expand Down Expand Up @@ -669,19 +630,56 @@ describe('cli', function () {

// upload disk
it('Should verify upload disk', function (done) {
var sourcePath = suite.isMocked ? diskSourcePath : (process.env['BLOB_SOURCE_PATH'] || diskSourcePath);
var sourcePath = process.env['BLOB_SOURCE_PATH'] || diskSourcePath;
var blobUrl = sourcePath.substring(0, sourcePath.lastIndexOf('/')) + '/disknewupload.vhd';
suite.execute('vm disk upload %s %s %s --json', sourcePath, blobUrl, storageAccountKey, function (result) {
result.exitStatus.should.equal(0);
done();
});
});

// Create VM with custom data
it('Create vm with custom data', function (done) {
var customVmName = vmName + 'customdata';
var fileName = 'customdata';
generateFile(fileName, null, 'nodejs,python,wordpress');
suite.execute('vm create %s %s testuser Collabera@01 -l %s -d %s --json --verbose',
customVmName, vmImgName, location, fileName, function (result) {
result.exitStatus.should.equal(0);
var verboseString = result.text;
var iPosCustom = verboseString.indexOf('CustomData:');
iPosCustom.should.equal(-1);
fs.unlink(fileName, function (err) {
if (err)
throw err;
vmToUse.Name = customVmName;
vmToUse.Created = true;
vmToUse.Delete = true;
return done();
});
});
});

// Create VM with custom data with large file as customdata file
it('negetive testcase for custom data - Large File', function (done) {
var customVmName = vmName + 'customdatalargefile';
var fileName = 'customdatalargefile';
generateFile(fileName, 70000, null);
suite.execute('vm create %s %s testuser Collabera@01 -l %s -d %s --json',
customVmName, vmImgName, location, fileName, function (result) {
result.exitStatus.should.equal(1);
result.errorText.should.include('Input custom data file exceeded the maximum length of 65535 bytes');
fs.unlink(fileName, function (err) {
if (err)
throw err;
return done();
});
});
});

// create vm from a community image
it('Should create from community image', function (done) {
var vmComName = suite.generateId(vmPrefix, vmNames);
if (suite.isMocked)
communityImageId = 'vmdepot-1-1-1';

// Create a VM using community image (-o option)
suite.execute('vm create %s %s communityUser PassW0rd$ -o --json --ssh --location %s',
Expand All @@ -707,7 +705,7 @@ describe('cli', function () {
suite.execute('vm image list --json', function (result) {
var imageList = JSON.parse(result.text);
imageList.some(function (image) {
if (image.OS.toLowerCase() === category.toLowerCase() && image.Category.toLowerCase() === 'public') {
if (image.Category.toLowerCase() === category.toLowerCase()) {
getImageName.imageName = image.Name;
}
});
Expand All @@ -723,9 +721,9 @@ describe('cli', function () {
if (vmToUse.Created) {
return callBack(vmToUse);
} else {
getImageName('Windows', function (imageName) {
getImageName('Microsoft Corporation', function (imageName) {
var name = suite.generateId(vmPrefix, vmNames);
suite.execute('vm create %s %s azureuser PassW0rd$ --json --location %s',
suite.execute('vm create %s %s azureuser PassW0rd$ --ssh --json --location %s',
name,
imageName,
location,
Expand Down
505 changes: 252 additions & 253 deletions test/recordings/cli.vm-tests.nock.js

Large diffs are not rendered by default.

0 comments on commit bb42175

Please sign in to comment.