Skip to content

Dev #23

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

Merged
merged 5 commits into from
Jun 13, 2015
Merged

Dev #23

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions AzurePowershell.Test.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ScenarioTestDebug>.\src\Common\Commands.ScenarioTest\bin\Debug\Microsoft.WindowsAzure.Commands.ScenarioTest.dll</ScenarioTestDebug>
<CommonTestDebug>.\src\Common\Commands.Common.Test\bin\Debug\Microsoft.WindowsAzure.Commands.Common.Test.dll</CommonTestDebug>
<SqlTestDebug>.\src\ResourceManager\Sql\Commands.Sql.Test\bin\Debug\Microsoft.Azure.Commands.Sql.Test.dll</SqlTestDebug>
<ComputeDebug>.\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.dll</ComputeDebug>
<ComputeTestDebug>.\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.Test.dll</ComputeTestDebug>
<NetworkTestDebug>.\src\ResourceManager\Network\Commands.Network.Test\bin\Debug\Microsoft.Azure.Commands.Network.Test.dll</NetworkTestDebug>
<AzureRTTestSettings>.\src\AzureRT.testsettings</AzureRTTestSettings>
Expand Down Expand Up @@ -397,9 +398,7 @@
<Message Importance="high" Text="Gathering Code Coverage data from Compute tests..." />
<Delete Files="Project.covarage" />
<Exec
Command="pushd .\src\ResourceManager\Compute\Commands.Compute.Test\
.\ComputeCodeCoverage.cmd
popd"
Command="C:\cc\ComputeCodeCoverage.cmd $(ComputeDebug) $(ComputeTestDebug)"
ContinueOnError="false" />
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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";
Expand All @@ -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]
Expand All @@ -66,7 +75,7 @@ public void Initialize()
{
if (string.IsNullOrEmpty(localFile))
{
CredentialHelper.CopyTestData(testDataContainer, osVhdName, vhdContainerName, vhdName);
vmPowershellCmdlets.AddAzureVhd(new FileInfo(osVhdName), vhdBlobLocation);
}
else
{
Expand Down Expand Up @@ -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());
}
}
}

/// <summary>
/// This test covers Get-AzurePlatformVMImage, Set-AzurePlatformVMImage and Remove-AzurePlatformVMImage cmdlets
/// </summary>
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
// 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;
using System.IO;
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
{
Expand All @@ -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";
Expand Down