|
17 | 17 |
|
18 | 18 | ##Default Value ##
|
19 | 19 |
|
| 20 | +<# |
| 21 | +.SYNOPSIS |
| 22 | + Test Cluster Test Failover Job. |
| 23 | +#> |
| 24 | +function Test-ClusterTestFailoverJob { |
| 25 | + $primaryContainerName = getClusterPrimaryContainerName |
| 26 | + $primaryFabricName = getClusterPrimaryFabricName |
| 27 | + $recoveryResourceGroupName = getClusterRecoveryResourceGroupName |
| 28 | + $vaultName = getClusterVaultName |
| 29 | + $clusterName = getClusterName |
| 30 | + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName |
| 31 | + Set-ASRVaultContext -Vault $Vault |
| 32 | + $primaryFabric = get-asrFabric -Name $primaryFabricName |
| 33 | + $protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric |
| 34 | + $protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName |
| 35 | + |
| 36 | + $tfoJob = Start-AzRecoveryServicesAsrClusterTestFailoverJob -ReplicationProtectionCluster $protectionCluster -Direction PrimaryToRecovery -AzureVMNetworkId "/subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/ClusterRG-Vijami-1103115126-asr/providers/Microsoft.Network/virtualNetworks/adVNET-asr" -LatestProcessedRecoveryPoint |
| 37 | + |
| 38 | + WaitForJobCompletion -JobId $tfoJob.Name |
| 39 | + #Get recovery vm and verify |
| 40 | + $recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1-test" |
| 41 | + Assert-NotNull($recvm.Id); |
| 42 | +} |
| 43 | + |
| 44 | +<# |
| 45 | +.SYNOPSIS |
| 46 | + Test Cluster Unplanned Failover Job. |
| 47 | +#> |
| 48 | +function Test-ClusterUnplannedFailoverJob { |
| 49 | + $primaryContainerName = getClusterPrimaryContainerName |
| 50 | + $primaryFabricName = getClusterPrimaryFabricName |
| 51 | + $recoveryResourceGroupName = getClusterRecoveryResourceGroupName |
| 52 | + $vaultName = getClusterVaultName |
| 53 | + $clusterName = getClusterName |
| 54 | + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName |
| 55 | + Set-ASRVaultContext -Vault $Vault |
| 56 | + $primaryFabric = get-asrFabric -Name $primaryFabricName |
| 57 | + $protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric |
| 58 | + $protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName |
| 59 | + |
| 60 | + $ufoJob = Start-AzRecoveryServicesAsrClusterUnplannedFailoverJob -ReplicationProtectionCluster $protectionCluster -Direction PrimaryToRecovery -LatestProcessedRecoveryPoint |
| 61 | + |
| 62 | + WaitForJobCompletion -JobId $ufoJob.Name |
| 63 | + #Get recovery vm and verify |
| 64 | + $recvm = get-azVm -ResourceGroupName $$recoveryResourceGroupName -Name "sdgql1" |
| 65 | + Assert-NotNull($recvm.Id); |
| 66 | +} |
| 67 | + |
| 68 | +<# |
| 69 | +.SYNOPSIS |
| 70 | + Test Cluster Test Failover Cleanup Job. |
| 71 | +#> |
| 72 | +function Test-ClusterTestFailoverCleanupJob { |
| 73 | + $primaryContainerName = getClusterPrimaryContainerName |
| 74 | + $primaryFabricName = getClusterPrimaryFabricName |
| 75 | + $recoveryResourceGroupName = getClusterRecoveryResourceGroupName |
| 76 | + $vaultName = getClusterVaultName |
| 77 | + $clusterName = getClusterName |
| 78 | + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName |
| 79 | + Set-ASRVaultContext -Vault $Vault |
| 80 | + $primaryFabric = get-asrFabric -Name $primaryFabricName |
| 81 | + $protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric |
| 82 | + $protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName |
| 83 | + |
| 84 | + $tfoCleanupJob = Start-AzRecoveryServicesAsrClusterTestFailoverCleanupJob -ReplicationProtectionCluster $protectionCluster |
| 85 | + |
| 86 | + WaitForJobCompletion -JobId $tfoCleanupJob.Name |
| 87 | + #Get recovery vm will give exception |
| 88 | + Assert-ThrowsContains { get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1-test"} "The Resource 'Microsoft.Compute/virtualMachines/sdgql1-test' under resource group 'ClusterRG-Vijami-1103115126-asr' was not found." |
| 89 | +} |
| 90 | + |
| 91 | +<# |
| 92 | +.SYNOPSIS |
| 93 | + Test Cluster Apply Cluster Recovery Point. |
| 94 | +#> |
| 95 | +function Test-ApplyClusterRecoveryPoint { |
| 96 | + $primaryContainerName = getClusterPrimaryContainerName |
| 97 | + $primaryFabricName = getClusterPrimaryFabricName |
| 98 | + $recoveryResourceGroupName = getClusterRecoveryResourceGroupName |
| 99 | + $vaultName = getClusterVaultName |
| 100 | + $clusterName = getClusterName |
| 101 | + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName |
| 102 | + Set-ASRVaultContext -Vault $Vault |
| 103 | + $primaryFabric = get-asrFabric -Name $primaryFabricName |
| 104 | + $protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric |
| 105 | + $protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName |
| 106 | + |
| 107 | + $changePitJob = Start-AzRecoveryServicesAsrApplyClusterRecoveryPoint -ReplicationProtectionCluster $protectionCluster -LatestProcessedRecoveryPoint |
| 108 | + |
| 109 | + WaitForJobCompletion -JobId $changePitJob.Name |
| 110 | + #Get recovery vm and verify |
| 111 | + $recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1" |
| 112 | + Assert-NotNull($recvm.Id); |
| 113 | +} |
| 114 | + |
| 115 | +<# |
| 116 | +.SYNOPSIS |
| 117 | + Test Cluster Commit Failover Job. |
| 118 | +#> |
| 119 | +function Test-ClusterCommitFailoverJob { |
| 120 | + $primaryContainerName = getClusterPrimaryContainerName |
| 121 | + $primaryFabricName = getClusterPrimaryFabricName |
| 122 | + $recoveryResourceGroupName = getClusterRecoveryResourceGroupName |
| 123 | + $vaultName = getClusterVaultName |
| 124 | + $clusterName = getClusterName |
| 125 | + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $recoveryResourceGroupName -Name $vaultName |
| 126 | + Set-ASRVaultContext -Vault $Vault |
| 127 | + $primaryFabric = get-asrFabric -Name $primaryFabricName |
| 128 | + $protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric |
| 129 | + $protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName |
| 130 | + |
| 131 | + $CommitFailoverJob = Start-AzRecoveryServicesAsrClusterCommitFailoverJob -ReplicationProtectionCluster $protectionCluster |
| 132 | + |
| 133 | + WaitForJobCompletion -JobId $CommitFailoverJob.Name |
| 134 | + #Get recovery vm and verify |
| 135 | + $recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1" |
| 136 | + Assert-NotNull($recvm.Id); |
| 137 | +} |
| 138 | + |
20 | 139 | <#
|
21 | 140 | .SYNOPSIS
|
22 | 141 | NewA2ADiskReplicationConfiguration creation test.
|
|
0 commit comments