Skip to content

Commit 65ba319

Browse files
committed
update test
1 parent 5b507d2 commit 65ba319

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/CredentialHelper.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public static string DefaultStorageName
239239
}
240240
}
241241

242-
public static void CopyTestData(string srcContainer, string srcBlob, string destContainer, string destBlob)
242+
public static void CopyTestData(string srcContainer, string srcBlob, string destContainer, string destBlob = null)
243243
{
244244
ServiceManagementCmdletTestHelper vmPowershellCmdlets = new ServiceManagementCmdletTestHelper();
245245
Process currentProcess = Process.GetCurrentProcess();
@@ -262,7 +262,15 @@ public static void CopyTestData(string srcContainer, string srcBlob, string dest
262262
// Make SAS Uri for the source blob.
263263
string srcSasUri = Utilities.GenerateSasUri(CredentialHelper.CredentialBlobUriFormat, storageAccount, storageAccountKey, srcContainer, srcBlob);
264264

265-
vmPowershellCmdlets.RunPSScript(string.Format("Start-AzureStorageBlobCopy -SrcUri \"{0}\" -DestContainer {1} -DestBlob {2} -Force", srcSasUri, destContainer, destBlob));
265+
if (string.IsNullOrEmpty(destBlob))
266+
{
267+
vmPowershellCmdlets.RunPSScript(string.Format("Start-AzureStorageBlobCopy -SrcContainer {0} -SrcBlob {1} -DestContainer {2} -Force", srcContainer, srcBlob, destContainer));
268+
destBlob = srcBlob;
269+
}
270+
else
271+
{
272+
vmPowershellCmdlets.RunPSScript(string.Format("Start-AzureStorageBlobCopy -SrcUri \"{0}\" -DestContainer {1} -DestBlob {2} -Force", srcSasUri, destContainer, destBlob));
273+
}
266274

267275
for (int i = 0; i < 60; i++)
268276
{

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/FunctionalTestCommonVhd.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,51 @@ public void AzureVMImageTest()
174174
vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
175175
Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName));
176176

177+
// Unique Container Prefix
178+
var containerPrefix = Utilities.GetUniqueShortName("vmimg");
179+
180+
// Disk Blobs
181+
var srcVhdName = "os1.vhd";
182+
var srcVhdContainer = vhdContainerName;
183+
var dstOSVhdContainer = containerPrefix.ToLower() + "os" + vhdContainerName;
184+
CredentialHelper.CopyTestData(srcVhdContainer, srcVhdName, dstOSVhdContainer);
185+
string osVhdLink = string.Format("{0}{1}/{2}", blobUrlRoot, dstOSVhdContainer, srcVhdName);
186+
187+
var dstDataVhdContainer = containerPrefix.ToLower() + "data" + vhdContainerName;
188+
CredentialHelper.CopyTestData(srcVhdContainer, srcVhdName, dstDataVhdContainer);
189+
string dataVhdLink = string.Format("{0}{1}/{2}", blobUrlRoot, dstDataVhdContainer, srcVhdName);
190+
191+
// VM Image OS/Data Disk Configuration
192+
var addVMImageName = containerPrefix + "Image";
193+
var diskConfig = new VirtualMachineImageDiskConfigSet
194+
{
195+
OSDiskConfiguration = new OSDiskConfiguration
196+
{
197+
HostCaching = HostCaching.ReadWrite.ToString(),
198+
OS = OSType.Windows.ToString(),
199+
OSState = "Generalized",
200+
MediaLink = new Uri(osVhdLink)
201+
},
202+
DataDiskConfigurations = new DataDiskConfigurationList
203+
{
204+
new DataDiskConfiguration
205+
{
206+
HostCaching = HostCaching.ReadOnly.ToString(),
207+
Lun = 0,
208+
MediaLink = new Uri(dataVhdLink)
209+
}
210+
}
211+
};
212+
213+
// Add-AzureVMImage
214+
vmPowershellCmdlets.AddAzureVMImage(addVMImageName, addVMImageName, diskConfig);
215+
216+
// Get-AzureVMImage
217+
var vmImage = vmPowershellCmdlets.GetAzureVMImageReturningVMImages(addVMImageName).First();
218+
219+
// Remove-AzureVMImage
220+
vmPowershellCmdlets.RemoveAzureVMImage(addVMImageName);
221+
177222
pass = true;
178223
}
179224
catch (Exception e)

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/IaasCmdletInfo/AddAzureVMImageCmdletInfo.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System;
1616
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.ConfigDataInfo;
1717
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
18+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
1819

1920
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.IaasCmdletInfo
2021
{
@@ -96,5 +97,19 @@ public AddAzureVMImageCmdletInfo(
9697
cmdletParams.Add(new CmdletParam("PublishedDate", publishedDate.ToString()));
9798
}
9899
}
100+
101+
public AddAzureVMImageCmdletInfo(string imageName, string label, VirtualMachineImageDiskConfigSet diskConfig)
102+
{
103+
cmdletName = Utilities.AddAzureVMImageCmdletName;
104+
105+
cmdletParams.Add(new CmdletParam("ImageName", imageName));
106+
107+
cmdletParams.Add(new CmdletParam("Label", label));
108+
109+
if (diskConfig != null)
110+
{
111+
cmdletParams.Add(new CmdletParam("DiskConfig", diskConfig));
112+
}
113+
}
99114
}
100115
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementCmdletTestHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,11 @@ public SM.OSImageContext AddAzureVMImage(string imageName, string mediaLocation,
13701370
return result;
13711371
}
13721372

1373+
public void AddAzureVMImage(string imageName, string label, SM.VirtualMachineImageDiskConfigSet diskConfig)
1374+
{
1375+
RunPSCmdletAndReturnFirst<ManagementOperationContext>(new AddAzureVMImageCmdletInfo(imageName, label, diskConfig));
1376+
}
1377+
13731378
public SM.OSImageContext UpdateAzureVMImage(string imageName, string label, string recommendedSize = null)
13741379
{
13751380
return RunPSCmdletAndReturnFirst<SM.OSImageContext>(new UpdateAzureVMImageCmdletInfo(imageName, label, recommendedSize, null, null));

0 commit comments

Comments
 (0)