diff --git a/AzurePowershell.Test.targets b/AzurePowershell.Test.targets index 3882a3655a8f..7a52401f742f 100644 --- a/AzurePowershell.Test.targets +++ b/AzurePowershell.Test.targets @@ -8,6 +8,7 @@ .\src\Common\Commands.ScenarioTest\bin\Debug\Microsoft.WindowsAzure.Commands.ScenarioTest.dll .\src\Common\Commands.Common.Test\bin\Debug\Microsoft.WindowsAzure.Commands.Common.Test.dll .\src\ResourceManager\Sql\Commands.Sql.Test\bin\Debug\Microsoft.Azure.Commands.Sql.Test.dll + .\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.dll .\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.Test.dll .\src\ResourceManager\Network\Commands.Network.Test\bin\Debug\Microsoft.Azure.Commands.Network.Test.dll .\src\AzureRT.testsettings @@ -397,9 +398,7 @@ diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/PIRTest.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/PIRTest.cs index 4b0e95bb49c4..56ae1c60a5c8 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/PIRTest.cs +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/PIRTest.cs @@ -12,16 +12,15 @@ // limitations under the License. // ---------------------------------------------------------------------------------- - +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; +using Microsoft.WindowsAzure.Commands.ServiceManagement.PlatformImageRepository.Model; +using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.ConfigDataInfo; using System; using System.Collections.ObjectModel; using System.IO; using System.Reflection; using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; -using Microsoft.WindowsAzure.Commands.ServiceManagement.PlatformImageRepository.Model; -using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.ConfigDataInfo; namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests { @@ -39,8 +38,8 @@ public class PIRTest : ServiceManagementTest private const string location2 = "North Central US"; private const string location3 = "East US"; - private const string publisher = "publisher1"; - private const string normaluser = "normaluser2"; + private static string publisher = "publisher1"; + private static string normaluser = "normaluser2"; private const string normaluserSubId = "602258C5-52EC-46B3-A49A-7587A764AC84"; private const string storageNormalUser = "normalstorage"; @@ -52,6 +51,16 @@ public static void ClassInit(TestContext context) { Assert.Inconclusive("No Subscription is selected!"); } + + if (vmPowershellCmdlets.GetAzureSubscription(publisher) == null) + { + publisher = defaultAzureSubscription.SubscriptionName; + } + + if (vmPowershellCmdlets.GetAzureSubscription(normaluser) == null) + { + normaluser = defaultAzureSubscription.SubscriptionName; + } } [TestInitialize] @@ -66,7 +75,7 @@ public void Initialize() { if (string.IsNullOrEmpty(localFile)) { - CredentialHelper.CopyTestData(testDataContainer, osVhdName, vhdContainerName, vhdName); + vmPowershellCmdlets.AddAzureVhd(new FileInfo(osVhdName), vhdBlobLocation); } else { @@ -101,6 +110,35 @@ public void Initialize() testStartTime = DateTime.Now; } + [TestCleanup] + public virtual void CleanUp() + { + SwitchToPublisher(); + Console.WriteLine("Test {0}", pass ? "passed" : "failed"); + + if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass)) + { + Console.WriteLine("Starting to clean up created VM and service."); + + try + { + vmPowershellCmdlets.RemoveAzureVMImage(image, false); + } + catch (Exception e) + { + Console.WriteLine("Exception occurs during cleanup: {0}", e.ToString()); + } + + try + { + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + } + } + /// /// This test covers Get-AzurePlatformVMImage, Set-AzurePlatformVMImage and Remove-AzurePlatformVMImage cmdlets /// @@ -301,35 +339,6 @@ public void AzurePlatformVMImageScenarioTest() } } - [TestCleanup] - public virtual void CleanUp() - { - SwitchToPublisher(); - Console.WriteLine("Test {0}", pass ? "passed" : "failed"); - - if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass)) - { - Console.WriteLine("Starting to clean up created VM and service."); - - try - { - vmPowershellCmdlets.RemoveAzureVMImage(image, false); - } - catch (Exception e) - { - Console.WriteLine("Exception occurs during cleanup: {0}", e.ToString()); - } - - try - { - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - } - } - } - private void SwitchToPublisher() { vmPowershellCmdlets.SetDefaultAzureSubscription(publisher); diff --git a/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementTest.cs b/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementTest.cs index 79a8bce5dbab..e4902afca353 100644 --- a/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementTest.cs +++ b/src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementTest.cs @@ -12,6 +12,12 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.WindowsAzure.Commands.Profile.Models; +using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; +using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.Properties; +using Microsoft.WindowsAzure.Commands.Sync.Download; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -19,12 +25,6 @@ using System.Linq; using System.Threading; using System.Xml.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Microsoft.Azure.Common.Authentication.Models; -using Microsoft.WindowsAzure.Commands.Profile.Models; -using Microsoft.WindowsAzure.Commands.ServiceManagement.Model; -using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.Properties; -using Microsoft.WindowsAzure.Commands.Sync.Download; namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests { @@ -41,8 +41,7 @@ public class ServiceManagementTest protected const string username = "pstestuser"; protected static string localFile = Resource.Vhd; protected static string vnetConfigFilePath = Directory.GetCurrentDirectory() + "\\vnetconfig.netcfg"; - protected const string testDataContainer = "testdata"; - protected const string osVhdName = "oneGBFixedWS2008R2.vhd"; + protected const string osVhdName = "os.vhd"; protected const string WinRmEndpointName = "PowerShell"; protected const string RdpEndpointName = "RemoteDesktop";