Skip to content

Commit 0939509

Browse files
unknownunknown
authored andcommitted
Update PIRtests
1 parent 2e35f08 commit 0939509

File tree

2 files changed

+53
-45
lines changed

2 files changed

+53
-45
lines changed

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

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
15+
using Microsoft.VisualStudio.TestTools.UnitTesting;
16+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
17+
using Microsoft.WindowsAzure.Commands.ServiceManagement.PlatformImageRepository.Model;
18+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.ConfigDataInfo;
1619
using System;
1720
using System.Collections.ObjectModel;
1821
using System.IO;
1922
using System.Reflection;
2023
using System.Threading;
21-
using Microsoft.VisualStudio.TestTools.UnitTesting;
22-
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
23-
using Microsoft.WindowsAzure.Commands.ServiceManagement.PlatformImageRepository.Model;
24-
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.ConfigDataInfo;
2524

2625
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests
2726
{
@@ -39,8 +38,8 @@ public class PIRTest : ServiceManagementTest
3938
private const string location2 = "North Central US";
4039
private const string location3 = "East US";
4140

42-
private const string publisher = "publisher1";
43-
private const string normaluser = "normaluser2";
41+
private static string publisher = "publisher1";
42+
private static string normaluser = "normaluser2";
4443
private const string normaluserSubId = "602258C5-52EC-46B3-A49A-7587A764AC84";
4544

4645
private const string storageNormalUser = "normalstorage";
@@ -52,6 +51,16 @@ public static void ClassInit(TestContext context)
5251
{
5352
Assert.Inconclusive("No Subscription is selected!");
5453
}
54+
55+
if (vmPowershellCmdlets.GetAzureSubscription(publisher) == null)
56+
{
57+
publisher = defaultAzureSubscription.SubscriptionName;
58+
}
59+
60+
if (vmPowershellCmdlets.GetAzureSubscription(normaluser) == null)
61+
{
62+
normaluser = defaultAzureSubscription.SubscriptionName;
63+
}
5564
}
5665

5766
[TestInitialize]
@@ -66,7 +75,7 @@ public void Initialize()
6675
{
6776
if (string.IsNullOrEmpty(localFile))
6877
{
69-
CredentialHelper.CopyTestData(testDataContainer, osVhdName, vhdContainerName, vhdName);
78+
vmPowershellCmdlets.AddAzureVhd(new FileInfo(osVhdName), vhdBlobLocation);
7079
}
7180
else
7281
{
@@ -101,6 +110,35 @@ public void Initialize()
101110
testStartTime = DateTime.Now;
102111
}
103112

113+
[TestCleanup]
114+
public virtual void CleanUp()
115+
{
116+
SwitchToPublisher();
117+
Console.WriteLine("Test {0}", pass ? "passed" : "failed");
118+
119+
if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
120+
{
121+
Console.WriteLine("Starting to clean up created VM and service.");
122+
123+
try
124+
{
125+
vmPowershellCmdlets.RemoveAzureVMImage(image, false);
126+
}
127+
catch (Exception e)
128+
{
129+
Console.WriteLine("Exception occurs during cleanup: {0}", e.ToString());
130+
}
131+
132+
try
133+
{
134+
}
135+
catch (Exception e)
136+
{
137+
Console.WriteLine(e.ToString());
138+
}
139+
}
140+
}
141+
104142
/// <summary>
105143
/// This test covers Get-AzurePlatformVMImage, Set-AzurePlatformVMImage and Remove-AzurePlatformVMImage cmdlets
106144
/// </summary>
@@ -301,35 +339,6 @@ public void AzurePlatformVMImageScenarioTest()
301339
}
302340
}
303341

304-
[TestCleanup]
305-
public virtual void CleanUp()
306-
{
307-
SwitchToPublisher();
308-
Console.WriteLine("Test {0}", pass ? "passed" : "failed");
309-
310-
if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
311-
{
312-
Console.WriteLine("Starting to clean up created VM and service.");
313-
314-
try
315-
{
316-
vmPowershellCmdlets.RemoveAzureVMImage(image, false);
317-
}
318-
catch (Exception e)
319-
{
320-
Console.WriteLine("Exception occurs during cleanup: {0}", e.ToString());
321-
}
322-
323-
try
324-
{
325-
}
326-
catch (Exception e)
327-
{
328-
Console.WriteLine(e.ToString());
329-
}
330-
}
331-
}
332-
333342
private void SwitchToPublisher()
334343
{
335344
vmPowershellCmdlets.SetDefaultAzureSubscription(publisher);

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Common.Authentication.Models;
16+
using Microsoft.VisualStudio.TestTools.UnitTesting;
17+
using Microsoft.WindowsAzure.Commands.Profile.Models;
18+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
19+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.Properties;
20+
using Microsoft.WindowsAzure.Commands.Sync.Download;
1521
using System;
1622
using System.Collections.Generic;
1723
using System.Collections.ObjectModel;
1824
using System.IO;
1925
using System.Linq;
2026
using System.Threading;
2127
using System.Xml.Linq;
22-
using Microsoft.VisualStudio.TestTools.UnitTesting;
23-
using Microsoft.Azure.Common.Authentication.Models;
24-
using Microsoft.WindowsAzure.Commands.Profile.Models;
25-
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
26-
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.Properties;
27-
using Microsoft.WindowsAzure.Commands.Sync.Download;
2828

2929
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests
3030
{
@@ -41,8 +41,7 @@ public class ServiceManagementTest
4141
protected const string username = "pstestuser";
4242
protected static string localFile = Resource.Vhd;
4343
protected static string vnetConfigFilePath = Directory.GetCurrentDirectory() + "\\vnetconfig.netcfg";
44-
protected const string testDataContainer = "testdata";
45-
protected const string osVhdName = "oneGBFixedWS2008R2.vhd";
44+
protected const string osVhdName = "os.vhd";
4645

4746
protected const string WinRmEndpointName = "PowerShell";
4847
protected const string RdpEndpointName = "RemoteDesktop";

0 commit comments

Comments
 (0)