Skip to content

Commit 7355ff5

Browse files
author
Samuel Anudeep
committed
Added test case for Set Vault Context cmdlet usage.
1 parent 1e1f779 commit 7355ff5

File tree

7 files changed

+30839
-1
lines changed

7 files changed

+30839
-1
lines changed

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Test/Commands.RecoveryServices.Backup.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@
238238
<None Include="SessionRecords\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.ItemTests\TestAzureSqlGetRPs.json">
239239
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
240240
</None>
241+
<None Include="SessionRecords\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.ItemTests\TestAzureVMSetVaultContext.json">
242+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
243+
</None>
241244
<None Include="SessionRecords\Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.JobTests\TestAzureVMCancelJob.json">
242245
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
243246
</None>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,14 @@ public void TestAzureVMRPMountScript()
9090

9191
Assert.True(AzureSession.Instance.DataStore.FileExists(mountScriptDetails.FilePath));
9292
}
93+
94+
[Fact]
95+
[Trait(Category.AcceptanceType, Category.CheckIn)]
96+
[Trait(TestConstants.Workload, TestConstants.AzureVM)]
97+
public void TestAzureVMSetVaultContext()
98+
{
99+
TestController.NewInstance.RunPsTest(
100+
PsBackupProviderTypes.IaasVm, "Test-AzureVMSetVaultContext");
101+
}
93102
}
94103
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.ps1

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,48 @@ function Test-AzureVMBackup
321321
# Cleanup
322322
Cleanup-ResourceGroup $resourceGroupName
323323
}
324+
}
325+
326+
function Test-AzureVMSetVaultContext
327+
{
328+
$location = Get-ResourceGroupLocation
329+
$resourceGroupName = Create-ResourceGroup $location
330+
331+
try
332+
{
333+
# Setup
334+
$vm = Create-VM $resourceGroupName $location
335+
$vault = Create-RecoveryServicesVault $resourceGroupName $location
336+
337+
Set-AzureRmRecoveryServicesVaultContext -Vault $vault
338+
339+
# Get default policy
340+
$policy = Get-AzureRmRecoveryServicesBackupProtectionPolicy `
341+
-Name "DefaultPolicy";
342+
343+
# Enable protection
344+
Enable-AzureRmRecoveryServicesBackupProtection `
345+
-Policy $policy `
346+
-Name $vm.Name `
347+
-ResourceGroupName $vm.ResourceGroupName;
348+
349+
$container = Get-AzureRmRecoveryServicesBackupContainer `
350+
-ContainerType AzureVM `
351+
-Status Registered;
352+
353+
$item = Get-AzureRmRecoveryServicesBackupItem `
354+
-Container $container `
355+
-WorkloadType AzureVM
356+
357+
# Disable protection
358+
Disable-AzureRmRecoveryServicesBackupProtection `
359+
-Item $item `
360+
-RemoveRecoveryPoints `
361+
-Force;
362+
}
363+
finally
364+
{
365+
# Cleanup
366+
Cleanup-ResourceGroup $resourceGroupName
367+
}
324368
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Test/SessionRecords/Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.ItemTests/TestAzureVMSetVaultContext.json

Lines changed: 30782 additions & 0 deletions
Large diffs are not rendered by default.

src/StackAdmin/AzureRM/AzureRM.psm1

-2.85 KB
Binary file not shown.
-2.03 KB
Binary file not shown.

tools/AzureRM/AzureRM.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Placeholder for script template
1+
# Placeholder for script template

0 commit comments

Comments
 (0)