Skip to content

Commit 0976619

Browse files
committed
Conflicts: src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.ps1
2 parents 3341025 + 027e0fc commit 0976619

File tree

31 files changed

+5546
-2464
lines changed

31 files changed

+5546
-2464
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,13 @@
123123
</Reference>
124124
</ItemGroup>
125125
<ItemGroup>
126+
<Compile Include="ScenarioTests\AzureBackupItemTestCases.cs" />
126127
<Compile Include="ScenarioTests\AzureBackupTests.cs" />
127128
<Compile Include="ScenarioTests\AzureBackupTestBase.cs" />
128129
<Compile Include="Properties\AssemblyInfo.cs" />
130+
<Compile Include="ScenarioTests\BackupItemTests.cs" />
131+
<Compile Include="ScenarioTests\AzureBackupJobTests.cs" />
132+
<Compile Include="ScenarioTests\RecoveryPointTests.cs" />
129133
</ItemGroup>
130134
<ItemGroup>
131135
<ProjectReference Include="..\..\..\Common\Commands.Common\Commands.Common.csproj">
@@ -151,19 +155,31 @@
151155
<None Include="packages.config">
152156
<SubType>Designer</SubType>
153157
</None>
158+
<None Include="ScenarioTests\AzureBackupItemTestCases.ps1">
159+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
160+
</None>
154161
<None Include="ScenarioTests\AzureBackupTests.ps1">
155-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
162+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
163+
</None>
164+
<None Include="ScenarioTests\BackupItemTests.ps1">
165+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
166+
</None>
167+
<None Include="ScenarioTests\AzureBackupJobTests.ps1">
168+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
169+
</None>
170+
<None Include="ScenarioTests\RecoveryPointTests.ps1">
171+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
156172
</None>
157-
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\BackUpAzureBackUpItem.json" />
158-
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\EnableDisableAzureBackupProtectionTest.json" />
159-
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\GetAzureBackupJobTests.json" />
160-
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\GetRecoveryPointTests.json" />
161-
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\ListAzureBackupItemTests.json" />
173+
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupItemTestCases\EnableDisableAzureBackupProtectionTest.json" />
174+
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupItemTestCases\ListAzureBackupItemTests.json" />
175+
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupJobTests\GetAzureBackupJobTests.json" />
162176
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\ListProtectionPolicyTests.json">
163177
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
164178
</None>
165-
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\StopAzureBackupJobTests.json" />
179+
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.BackupItemTests\BackUpAzureBackUpItem.json" />
180+
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.RecoveryPointTests\GetRecoveryPointTests.json" />
166181
</ItemGroup>
182+
<ItemGroup />
167183
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
168184
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
169185
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
19+
{
20+
public class AzureBackupItemTestCases : AzureBackupTestsBase
21+
{
22+
[Fact]
23+
public void ListAzureBackupItemTests()
24+
{
25+
this.RunPowerShellTest("Test-GetAzureBackupItemTests");
26+
}
27+
28+
[Fact]
29+
public void EnableDisableAzureBackupProtectionTest()
30+
{
31+
this.RunPowerShellTest("Test-EnableDisableAzureBackupProtectionTest");
32+
}
33+
}
34+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
$ResourceGroupName = "backuprg"
2+
$ResourceName = "backuprn"
3+
$ContainerName = "iaasvmcontainer;dev01testing;dev01testing"
4+
$ContainerType = "IaasVMContainer"
5+
$DataSourceType = "VM"
6+
$DataSourceId = "17593283453810"
7+
$Location = "SouthEast Asia"
8+
$PolicyName = "Policy9";
9+
$PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4";
10+
$POName = "iaasvmcontainer;dev01testing;dev01testing"
11+
12+
13+
function Test-GetAzureBackupItemTests
14+
{
15+
$azureBackUpContainer = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupContainer
16+
$azureBackUpContainer.ResourceGroupName = $ResourceGroupName
17+
$azureBackUpContainer.ResourceName = $ResourceName
18+
$azureBackUpContainer.Location = $Location
19+
$azureBackUpContainer.ContainerUniqueName = $ContainerName
20+
$azureBackUpContainer.ContainerType = $ContainerType
21+
$item = Get-AzureBackupItem -Container $azureBackUpContainer
22+
if (!($item -eq $null))
23+
{
24+
foreach($backupitem in $item)
25+
{
26+
Assert-NotNull $backupitem.ProtectionStatus 'ProtectionStatus should not be null'
27+
Assert-NotNull $backupitem.Name 'Name should not be null'
28+
Assert-NotNull $backupitem.Type 'Type should not be null'
29+
Assert-NotNull $backupitem.ContainerType 'ContainerType should not be null'
30+
Assert-NotNull $backupitem.ContainerUniqueName 'ContainerUniqueName should not be null'
31+
Assert-NotNull $backupitem.ResourceGroupName 'ResourceGroupName should not be null'
32+
Assert-NotNull $backupitem.ResourceName 'ResourceName should not be null'
33+
Assert-NotNull $backupitem.Location 'Location should not be null'
34+
}
35+
}
36+
}
37+
38+
function Test-EnableDisableAzureBackupProtectionTest
39+
{
40+
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupProtectionPolicy
41+
$policy.InstanceId = $PolicyId
42+
$policy.Name = $PolicyName
43+
$policy.ResourceGroupName = $ResourceGroupName
44+
$policy.ResourceName = $ResourceName
45+
$policy.Location = $Location
46+
$policy.WorkloadType = "VM"
47+
$policy.RetentionType = "1"
48+
$policy.ScheduleRunTimes = "2015-06-13T20:30:00"
49+
50+
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
51+
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
52+
$azureBackUpItem.ResourceName = $ResourceName
53+
$azureBackUpItem.Location = $Location
54+
$azureBackUpItem.ContainerUniqueName = $ContainerName
55+
$azureBackUpItem.ContainerType = $ContainerType
56+
$azureBackUpItem.DataSourceId = $DataSourceId
57+
$azureBackUpItem.Type = $DataSourceType
58+
$azureBackUpItem.Name = $POName
59+
60+
$jobId = Enable-AzureBackupProtection -Item $azureBackUpItem -Policy $policy
61+
sleep(20)
62+
$jobId1 = Disable-AzureBackupProtection -Item $azureBackUpItem
63+
sleep(20)
64+
$jobId2 = Enable-AzureBackupProtection -Item $azureBackUpItem -Policy $policy
65+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
19+
{
20+
public class AzureBackupJobTests : AzureBackupTestsBase
21+
{
22+
23+
[Fact]
24+
public void GetAzureBackupJobTests()
25+
{
26+
this.RunPowerShellTest("Test-GetAzureBackupJob");
27+
}
28+
29+
[Fact]
30+
public void StopAzureBackupJobTests()
31+
{
32+
this.RunPowerShellTest("Test-StopAzureBackupJob");
33+
}
34+
}
35+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
$ResourceGroupName = "backuprg"
2+
$ResourceName = "backuprn"
3+
$ContainerName = "iaasvmcontainer;dev01testing;dev01testing"
4+
$ContainerType = "IaasVMContainer"
5+
$DataSourceType = "VM"
6+
$DataSourceId = "17593283453810"
7+
$Location = "SouthEast Asia"
8+
$PolicyName = "Policy9";
9+
$PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4";
10+
$POName = "iaasvmcontainer;dev01testing;dev01testing"
11+
12+
13+
function Test-GetAzureBackupJob
14+
{
15+
$OneMonthBack = Get-Date;
16+
$OneMonthBack = $OneMonthBack.AddDays(-30);
17+
$jobs = Get-AzureBackupJob -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -From $OneMonthBack -Debug
18+
Assert-NotNull $jobs 'Jobs list should not be null'
19+
foreach($job in $jobs)
20+
{
21+
Assert-NotNull $jobs.InstanceId 'JobID should not be null';
22+
Assert-NotNull $jobs.StartTime 'StartTime should not be null';
23+
Assert-NotNull $jobs.WorkloadType 'WorkloadType should not be null';
24+
Assert-NotNull $jobs.WorkloadName 'WorkloadName should not be null';
25+
Assert-NotNull $jobs.Status 'Status should not be null';
26+
Assert-NotNull $jobs.Operation 'Operation should not be null';
27+
28+
$jobDetails = Get-AzureBackupJobDetails -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Job $job
29+
Assert-NotNull $jobDetails.InstanceId 'JobID should not be null';
30+
Assert-NotNull $jobDetails.StartTime 'StartTime should not be null';
31+
Assert-NotNull $jobDetails.WorkloadType 'WorkloadType should not be null';
32+
Assert-NotNull $jobDetails.WorkloadName 'WorkloadName should not be null';
33+
Assert-NotNull $jobDetails.Status 'Status should not be null';
34+
Assert-NotNull $jobDetails.Operation 'Operation should not be null';
35+
Assert-NotNull $jobDetails.Properties 'Properties in job details cannot be null';
36+
Assert-NotNull $jobDetails.SubTasks 'SubTasks in job details cannot be null';
37+
}
38+
}
39+
40+
41+
function Test-StopAzureBackupJob
42+
{
43+
$OneMonthBack = Get-Date;
44+
$OneMonthBack = $OneMonthBack.AddDays(-30);
45+
#TODO
46+
#Call trigger backup and get an inprogress job
47+
$jobsList = Get-AzureBackupJob -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -From $OneMonthBack #-Operation 'Backup' -Status 'InProgress'
48+
49+
Stop-AzureBackupJob -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Job $jobsList[0];
50+
$jobDetails = Get-AzureBackupJobDetails -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Job $jobsList[0];
51+
#Assert-AreEqual 'Cancelling' $jobDetails.Status
52+
}

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,5 @@ public void ListProtectionPolicyTests()
2424
{
2525
this.RunPowerShellTest("Test-GetAzureBackupProtectionPolicyTests");
2626
}
27-
28-
[Fact]
29-
public void ListAzureBackupItemTests()
30-
{
31-
this.RunPowerShellTest("Test-GetAzureBackupItemTests");
32-
}
33-
34-
[Fact]
35-
public void EnableDisableAzureBackupProtectionTest()
36-
{
37-
this.RunPowerShellTest("Test-EnableDisableAzureBackupProtectionTest");
38-
}
39-
40-
[Fact]
41-
42-
public void GetAzureBackupJobTests()
43-
{
44-
this.RunPowerShellTest("Test-GetAzureBackupJob");
45-
}
46-
47-
[Fact]
48-
public void StopAzureBackupJobTests()
49-
{
50-
this.RunPowerShellTest("Test-StopAzureBackupJob");
51-
}
52-
public void GetRecoveryPointTests()
53-
{
54-
this.RunPowerShellTest("Test-GetAzureRecoveryPoint");
55-
}
56-
57-
[Fact]
58-
public void BackUpAzureBackUpItem()
59-
{
60-
this.RunPowerShellTest("Test-BackUpAzureBackUpItem");
61-
}
6227
}
6328
}

0 commit comments

Comments
 (0)