Skip to content

[Azure Site Recovery] PR contains: aligning PowerShell to service object model, supporting some new features and some bug fixes. #2912

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 6 commits into from
Sep 15, 2016
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
@{

# Version number of this module.
ModuleVersion = '2.1.0'
ModuleVersion = '2.1.1'

# ID used to uniquely identify this module
GUID = '4AA53B7E-FCFE-4E22-979C-9A4E6380DE58'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
<Reference Include="Microsoft.Azure.Common.NetFramework">
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.3.0.0-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.3.0.1-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -173,4 +173,4 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="Hyak.Common" version="1.0.3" targetFramework="net45" />
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="2.0.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="3.0.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.11-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.6052.28118-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Azure.Management.RecoveryServices, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.3.0.0-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.3.0.1-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.28.1.741, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.1\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
Expand Down Expand Up @@ -168,4 +168,4 @@
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="Hyak.Common" version="1.0.3" targetFramework="net45" />
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="3.0.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RecoveryServices" version="3.0.1-preview" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/SiteRecovery/AzureRM.SiteRecovery.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@{

# Version number of this module.
ModuleVersion = '2.1.0'
ModuleVersion = '3.0.0'

# ID used to uniquely identify this module
GUID = 'd1de7560-48e1-48f3-bc8c-4eea3af2bbe1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<Reference Include="Microsoft.Azure.Common.NetFramework">
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.SiteRecovery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.SiteRecovery.1.0.3-preview\lib\net40\Microsoft.Azure.Management.SiteRecovery.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.SiteRecovery, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.SiteRecovery.2.0.0-preview\lib\net40\Microsoft.Azure.Management.SiteRecovery.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -130,6 +130,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScenarioTests\Constants.cs" />
<Compile Include="ScenarioTests\SiteRecoveryTests.cs" />
<Compile Include="ScenarioTests\SiteRecoveryTestsBase.cs" />
</ItemGroup>
Expand All @@ -144,6 +145,12 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.SiteRecovery.Test.ScenarioTests.SiteRecoveryTests\EnumerationTests.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.SiteRecovery.Test.ScenarioTests.SiteRecoveryTests\FabricTests.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.SiteRecovery.Test.ScenarioTests.SiteRecoveryTests\NewModelE2ETest.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.SiteRecovery.Test.ScenarioTests.SiteRecoveryTests\TestAssociateProfile.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -201,4 +208,4 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

using System;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.SiteRecovery.Test.ScenarioTests
{
public class Constants
{
public const string Default = "Default";
public const string NewModel = "NewModel";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,77 +30,91 @@ public SiteRecoveryTests(ITestOutputHelper output)
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void EnumerationTests()
{
this.RunPowerShellTest("Test-SiteRecoveryEnumerationTests -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryEnumerationTests -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateProfile()
{
this.RunPowerShellTest("Test-SiteRecoveryCreateProfile -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryCreateProfile -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDeleteProfile()
{
this.RunPowerShellTest("Test-SiteRecoveryDeleteProfile -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryDeleteProfile -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAssociateProfile()
{
this.RunPowerShellTest("Test-SiteRecoveryAssociateProfile -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryAssociateProfile -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDissociateProfile()
{
this.RunPowerShellTest("Test-SiteRecoveryDissociateProfile -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryDissociateProfile -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEnableDR()
{
this.RunPowerShellTest("Test-SiteRecoveryEnableDR -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryEnableDR -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDisableDR()
{
this.RunPowerShellTest("Test-SiteRecoveryDisableDR -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryDisableDR -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateRP()
{
this.RunPowerShellTest("Test-SiteRecoveryCreateRecoveryPlan -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryCreateRecoveryPlan -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEnumerateRP()
{
this.RunPowerShellTest("Test-SiteRecoveryEnumerateRecoveryPlan -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryEnumerateRecoveryPlan -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveRP()
{
this.RunPowerShellTest("Test-SiteRecoveryRemoveRecoveryPlan -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryRemoveRecoveryPlan -vaultSettingsFilePath \"" + vaultSettingsFilePath + "\"");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void VaultCRUDTests()
{
this.RunPowerShellTest("Test-SiteRecoveryVaultCRUDTests");
this.RunPowerShellTest(Constants.Default, "Test-SiteRecoveryVaultCRUDTests");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void FabricTests()
{
this.RunPowerShellTest(Constants.NewModel, "Test-SiteRecoveryFabricTest");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void NewModelE2ETest()
{
this.RunPowerShellTest(Constants.NewModel, "Test-SiteRecoveryNewModelE2ETest");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,135 @@ function Test-SiteRecoveryVaultCRUDTests
Remove-AzureRmSiteRecoveryVault -Vault $vaultToBeRemoved
$vaults = Get-AzureRmSiteRecoveryVault -ResourceGroupName rg1 -Name v2
Assert-True { $vaults.Count -eq 0 }
}
}


<#
.SYNOPSIS
Site Recovery Fabric Tests New model
#>
function Test-SiteRecoveryFabricTest
Copy link
Contributor

@shahabhijeet shahabhijeet Sep 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SiteRecoveryFabricTest [](start = 14, length = 22)

Is this good enough test coverage for anyone to contribute to your feature as this is a public repo? I think we need more scenario tests or at least bare minimum unit tests. #Resolved

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure..i will update the PR with needed tests.


In reply to: 78799081 [](ancestors = 78799081)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the PR.


In reply to: 78818997 [](ancestors = 78818997,78799081)

{
# Enumerate vaults and set Azure Site Recovery Vault Settings
$vault = Get-AzureRmSiteRecoveryVault -ResourceGroupName ReleaseResourceGroup -Name ReleaseVault
Assert-NotNull($vault)
Assert-True { $vault.Count -gt 0 }
Assert-NotNull($vault.Name)
Assert-NotNull($vault.ID)
Set-AzureRmSiteRecoveryVaultSettings -ASRVault $vault

# Create Fabric
$job = New-AzureRmSiteRecoveryFabric -Name ReleaseFabric -Type HyperVSite
Assert-NotNull($job)

# Enumerate Fabrics
$fabrics = Get-AzureRmSiteRecoveryFabric
Assert-True { $fabrics.Count -gt 0 }
Assert-NotNull($fabrics)
foreach($fabric in $fabrics)
{
Assert-NotNull($fabrics.Name)
Assert-NotNull($fabrics.ID)
}

# Enumerate specific Fabric
$fabric = Get-AzureRmSiteRecoveryFabric -Name ReleaseFabric
Assert-NotNull($fabric)
Assert-NotNull($fabrics.Name)
Assert-NotNull($fabrics.ID)

# Remove specific fabric
$job = Remove-AzureRmSiteRecoveryFabric -Fabric $fabric
Assert-NotNull($job)
WaitForJobCompletion -JobId $job.Name
$fabric = Get-AzureRmSiteRecoveryFabric | Where-Object {$_.Name -eq "ReleaseFabric"}
Assert-Null($fabric)
}


<#
.SYNOPSIS
Site Recovery New model End to End
#>
function Test-SiteRecoveryNewModelE2ETest
{
$JobQueryWaitTimeInSeconds = 30

# Enumerate vaults and set Azure Site Recovery Vault Settings
$vault = Get-AzureRmSiteRecoveryVault -ResourceGroupName ReleaseResourceGroup -Name ReleaseVault
Assert-NotNull($vault)
Assert-True { $vault.Count -eq 1 }
Assert-NotNull($vault.Name)
Assert-NotNull($vault.ID)
Set-AzureRmSiteRecoveryVaultSettings -ASRVault $vault

# Enumerate Fabrics
$fabrics = Get-AzureRmSiteRecoveryFabric
Assert-True { $fabrics.Count -gt 0 }
Assert-NotNull($fabrics)
foreach($fabric in $fabrics)
{
Assert-NotNull($fabrics.Name)
Assert-NotNull($fabrics.ID)
}

# Enumerate RSPs
$rsps = Get-AzureRmSiteRecoveryFabric | Get-AzureRmSiteRecoveryServicesProvider
Assert-True { $rsps.Count -gt 0 }
Assert-NotNull($rsps)
foreach($rsp in $rsps)
{
Assert-NotNull($rsp.Name)
}

$StorageAccountID = "/subscriptions/19b823e2-d1f3-4805-93d7-401c5d8230d5/resourceGroups/releaseresourcegroup/providers/Microsoft.Storage/storageAccounts/releasestorageav"

# Create Policy
$currentJob = New-AzureRmSiteRecoveryPolicy -Name "PP1" -ReplicationProvider HyperVReplicaAzure -ReplicationFrequencyInSeconds 30 -RecoveryPoints 1 -ApplicationConsistentSnapshotFrequencyInHours 0 -Encryption Disable -RecoveryAzureStorageAccountId $StorageAccountID
$ProtectionProfile = Get-AzureRMSiteRecoveryPolicy -Name "PP1"
Assert-NotNull($ProtectionProfile)
Assert-NotNull($ProtectionProfile.Name)

# Get conatiners
$ProtectionContainers = Get-AzureRmSiteRecoveryFabric | Get-AzureRmSiteRecoveryProtectionContainer
$PrimaryContainer = $ProtectionContainers | where { $_.FriendlyName -eq "hark-123" }
Assert-NotNull($PrimaryContainer)
Assert-NotNull($PrimaryContainer.Name)

# Create new Conatiner mapping
$currentJob = New-AzureRmSiteRecoveryProtectionContainerMapping -Name $("hark123" + "PP1") -Policy $ProtectionProfile -PrimaryProtectionContainer $PrimaryContainer

# Get container mapping
$ProtectionContainerMapping = Get-AzureRmSiteRecoveryProtectionContainerMapping -Name $("hark123" + "PP1") -ProtectionContainer $PrimaryContainer
Assert-NotNull($ProtectionContainerMapping)
Assert-NotNull($ProtectionContainerMapping.Name)

# Get protectable item
$protectable = Get-AzureRmSiteRecoveryProtectableItem -ProtectionContainer $PrimaryContainer -FriendlyName "vm3"
Assert-NotNull($protectable)
Assert-NotNull($protectable.Name)

# New replication protected item
$currentJob = New-AzureRmSiteRecoveryReplicationProtectedItem -ProtectableItem $protectable -Name $protectable.Name -ProtectionContainerMapping $ProtectionContainerMapping -RecoveryAzureStorageAccountId $StorageAccountID
Assert-NotNull($currentJob)

# Get replication protected item
$protected = Get-AzureRmSiteRecoveryReplicationProtectedItem -ProtectionContainer $PrimaryContainer -Name $protectable.Name
Assert-NotNull($protected)
Assert-NotNull($protected.Name)

# Remove protected item
$currentJob = Remove-AzureRmSiteRecoveryReplicationProtectedItem -ReplicationProtectedItem $protected -Force -Confirm:$false
$protected = Get-AzureRmSiteRecoveryReplicationProtectedItem -ProtectionContainer $PrimaryContainer | Where-Object {$_.Name -eq $protectable.Name}
Assert-Null($protected)

# Remove conatiner mapping
$currentJob = Remove-AzureRmSiteRecoveryProtectionContainerMapping -ProtectionContainerMapping $ProtectionContainerMapping
$ProtectionContainerMapping = Get-AzureRmSiteRecoveryProtectionContainerMapping -ProtectionContainer $PrimaryContainer | Where-Object {$_.Name -eq $("hark123" + "PP1")}
Assert-Null($ProtectionContainerMapping)

# Remove Policy
$currentJob = Remove-AzureRMSiteRecoveryPolicy -Policy $ProtectionProfile
$ProtectionProfile = Get-AzureRMSiteRecoveryPolicy | Where-Object {$_.Name -eq "PP1"}
Assert-Null($ProtectionProfile)
}
Loading