|
| 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 | +$ResourceGroupName = "backuprg" |
| 16 | +$ResourceName = "backuprn" |
| 17 | +$DataSourceType = "VM" |
| 18 | +$Location = "SouthEast Asia" |
| 19 | +$PolicyName = "Policy9"; |
| 20 | +$PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4"; |
| 21 | +$POName = "iaasvmcontainer;dev01testing;dev01testing" |
| 22 | +$WorkloadType = "VM" |
| 23 | +$RetentionType = "Days" |
| 24 | +$ScheduleRunTimes = "2015-06-13T20:30:00" |
| 25 | +$ScheduleRunDays = "Monday" |
| 26 | +$RetentionDuration = 30 |
| 27 | +$BackupType = "Full" |
| 28 | +$ScheduleType = "Daily" |
| 29 | + |
| 30 | +<# |
| 31 | +.SYNOPSIS |
| 32 | +Tests creating new resource group and a simple resource. |
| 33 | +#> |
| 34 | +function Test-GetAzureBackupProtectionPolicyTests |
| 35 | +{ |
| 36 | + $protectionPolicies = Get-AzureBackupProtectionPolicy -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location |
| 37 | + Assert-NotNull $protectionPolicies 'Protection Policies should not be null' |
| 38 | + foreach($protectionPolicy in $protectionPolicies) |
| 39 | + { |
| 40 | + Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null' |
| 41 | + Assert-NotNull $protectionPolicy.Name 'Name should not be null' |
| 42 | + Assert-NotNull $protectionPolicy.WorkloadType 'WorkloadType should not be null' |
| 43 | + Assert-NotNull $protectionPolicy.BackupType 'BackupType should not be null' |
| 44 | + Assert-NotNull $protectionPolicy.ScheduleRunTimes 'ScheduleRunTimes should not be null' |
| 45 | + Assert-NotNull $protectionPolicy.RetentionDuration 'RetentionDuration should not be null' |
| 46 | + Assert-NotNull $protectionPolicy.ResourceGroupName 'ResourceGroupName should not be null' |
| 47 | + Assert-NotNull $protectionPolicy.ResourceName 'ResourceName should not be null' |
| 48 | + Assert-NotNull $protectionPolicy.Location 'Location should not be null' |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +function Test-GetAzureBackupProtectionPolicyByNameTests |
| 53 | +{ |
| 54 | + $protectionPolicy = Get-AzureBackupProtectionPolicy -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Name $PolicyName |
| 55 | + |
| 56 | + Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null' |
| 57 | + Assert-NotNull $protectionPolicy.Name 'Name should not be null' |
| 58 | + Assert-NotNull $protectionPolicy.WorkloadType 'WorkloadType should not be null' |
| 59 | + Assert-NotNull $protectionPolicy.BackupType 'BackupType should not be null' |
| 60 | + Assert-NotNull $protectionPolicy.ScheduleRunTimes 'ScheduleRunTimes should not be null' |
| 61 | + Assert-NotNull $protectionPolicy.RetentionDuration 'RetentionDuration should not be null' |
| 62 | + Assert-NotNull $protectionPolicy.ResourceGroupName 'ResourceGroupName should not be null' |
| 63 | + Assert-NotNull $protectionPolicy.ResourceName 'ResourceName should not be null' |
| 64 | + Assert-NotNull $protectionPolicy.Location 'Location should not be null' |
| 65 | + |
| 66 | +} |
| 67 | + |
| 68 | +function Test-NewAzureBackupProtectionPolicyTests |
| 69 | +{ |
| 70 | + $protectionPolicy = New-AzureBackupProtectionPolicy -Name $PolicyName -WorkloadType $WorkloadType -BackupType $BackupType -Daily -RetentionType $RetentionType -RetentionDuration $RetentionDuration -ScheduleRunTimes $ScheduleRunTimes -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location |
| 71 | + |
| 72 | + Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null' |
| 73 | + Assert-NotNull $protectionPolicy.Name 'Name should not be null' |
| 74 | + Assert-NotNull $protectionPolicy.WorkloadType 'WorkloadType should not be null' |
| 75 | + Assert-NotNull $protectionPolicy.BackupType 'BackupType should not be null' |
| 76 | + Assert-NotNull $protectionPolicy.ScheduleRunTimes 'ScheduleRunTimes should not be null' |
| 77 | + Assert-NotNull $protectionPolicy.RetentionDuration 'RetentionDuration should not be null' |
| 78 | + Assert-NotNull $protectionPolicy.ResourceGroupName 'ResourceGroupName should not be null' |
| 79 | + Assert-NotNull $protectionPolicy.ResourceName 'ResourceName should not be null' |
| 80 | + Assert-NotNull $protectionPolicy.Location 'Location should not be null' |
| 81 | +} |
| 82 | + |
| 83 | +function Test-SetAzureBackupProtectionPolicyTests |
| 84 | +{ |
| 85 | + $policy = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupProtectionPolicy |
| 86 | + $policy.InstanceId = $PolicyId |
| 87 | + $policy.Name = $PolicyName |
| 88 | + $policy.ResourceGroupName = $ResourceGroupName |
| 89 | + $policy.ResourceName = $ResourceName |
| 90 | + $policy.Location = $Location |
| 91 | + $policy.WorkloadType = $WorkloadType |
| 92 | + $policy.RetentionType = $RetentionType |
| 93 | + $policy.ScheduleRunTimes = $ScheduleRunTimes |
| 94 | + $policy.ScheduleType = $ScheduleType |
| 95 | + $policyNewName = "policy09_new" |
| 96 | + |
| 97 | + $protectionPolicy = New-AzureBackupProtectionPolicy -ProtectionPolicy $policy -NewName $policyNewName |
| 98 | + |
| 99 | + Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null' |
| 100 | + Assert-NotNull $protectionPolicy.Name 'Name should not be null' |
| 101 | + Assert-NotNull $protectionPolicy.WorkloadType 'WorkloadType should not be null' |
| 102 | + Assert-NotNull $protectionPolicy.BackupType 'BackupType should not be null' |
| 103 | + Assert-NotNull $protectionPolicy.ScheduleRunTimes 'ScheduleRunTimes should not be null' |
| 104 | + Assert-NotNull $protectionPolicy.RetentionDuration 'RetentionDuration should not be null' |
| 105 | + Assert-NotNull $protectionPolicy.ResourceGroupName 'ResourceGroupName should not be null' |
| 106 | + Assert-NotNull $protectionPolicy.ResourceName 'ResourceName should not be null' |
| 107 | + Assert-NotNull $protectionPolicy.Location 'Location should not be null' |
| 108 | +} |
| 109 | + |
| 110 | +function Test-RemoveAzureBackupProtectionPolicyTests |
| 111 | +{ |
| 112 | + $policyNewName = "policy09_new" |
| 113 | + $policy = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupProtectionPolicy |
| 114 | + $policy.InstanceId = $PolicyId |
| 115 | + $policy.Name = $policyNewName |
| 116 | + $policy.ResourceGroupName = $ResourceGroupName |
| 117 | + $policy.ResourceName = $ResourceName |
| 118 | + $policy.Location = $Location |
| 119 | + $policy.WorkloadType = $WorkloadType |
| 120 | + $policy.RetentionType = $RetentionType |
| 121 | + $policy.ScheduleRunTimes = $ScheduleRunTimes |
| 122 | + $policy.ScheduleType = $ScheduleType |
| 123 | + |
| 124 | + Remove-AzureBackupProtectionPolicy -ProtectionPolicy $policy |
| 125 | +} |
0 commit comments