|
17 | 17 |
|
18 | 18 | ##Default Value ##
|
19 | 19 |
|
| 20 | +<# |
| 21 | +.SYNOPSIS |
| 22 | + Test Cluster Test Failover Job. |
| 23 | +#> |
| 24 | +function Test-ClusterTestFailoverAndFailoverCleanupJob { |
| 25 | + $primaryContainerName = getClusterPrimaryContainerName |
| 26 | + $primaryFabricName = getClusterPrimaryFabricName |
| 27 | + $vaultResourceGroupName = getClusterVaultResourceGroupName |
| 28 | + $recoveryResourceGroupName = getClusterRecoveryResourceGroupName |
| 29 | + $vaultName = getClusterVaultName |
| 30 | + $clusterName = getClusterName |
| 31 | + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $vaultResourceGroupName -Name $vaultName |
| 32 | + Set-ASRVaultContext -Vault $Vault |
| 33 | + $primaryFabric = get-asrFabric -Name $primaryFabricName |
| 34 | + $protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric |
| 35 | + $protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName |
| 36 | + |
| 37 | + #TFO |
| 38 | + $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 |
| 39 | + |
| 40 | + WaitForJobCompletion -JobId $tfoJob.Name |
| 41 | + #Get recovery vm and verify |
| 42 | + $recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1-test" |
| 43 | + Assert-NotNull($recvm.Id); |
| 44 | + |
| 45 | + #TFO cleanup |
| 46 | + $tfoCleanupJob = Start-AzRecoveryServicesAsrClusterTestFailoverCleanupJob -ReplicationProtectionCluster $protectionCluster |
| 47 | + |
| 48 | + WaitForJobCompletion -JobId $tfoCleanupJob.Name |
| 49 | + #Get recovery vm will give exception |
| 50 | + 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." |
| 51 | + |
| 52 | + #Get ClusterRecoveryPoint |
| 53 | + $clusterRecoveryPoints = Get-AzRecoveryServicesAsrClusterRecoveryPoint -ReplicationProtectionCluster $protectionCluster |
| 54 | + #Node Recovery Point |
| 55 | + $nodeRecoveryPoints = @("/Subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/ClusterRG-Vijami-rec-1103115126/providers/Microsoft.RecoveryServices/vaults/powershell-cluster-vault/replicationFabrics/asr-a2a-default-eastus2/replicationProtectionContainers/6dad6744-ee36-55e2-a77e-92e5bdcd088e/replicationProtectedItems/L1MqErJJvLX_0U05A1X2PfCN988iqFOo6ymNnyOoxhE/recoveryPoints/85c908c4-9a0a-40aa-a3b1-1975c9ca27bf") |
| 56 | + |
| 57 | + #TFO |
| 58 | + $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" -ClusterRecoveryPoint $clusterRecoveryPoints[-1] -NodeRecoveryPoints $nodeRecoveryPoints |
| 59 | + |
| 60 | + WaitForJobCompletion -JobId $tfoJob.Name |
| 61 | + #Get recovery vm and verify |
| 62 | + $recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1-test" |
| 63 | + Assert-NotNull($recvm.Id); |
| 64 | + #TFO cleanup |
| 65 | + $tfoCleanupJob = Start-AzRecoveryServicesAsrClusterTestFailoverCleanupJob -ReplicationProtectionCluster $protectionCluster |
| 66 | + |
| 67 | + WaitForJobCompletion -JobId $tfoCleanupJob.Name |
| 68 | + #Get recovery vm will give exception |
| 69 | + 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." |
| 70 | +} |
| 71 | + |
| 72 | +<# |
| 73 | +.SYNOPSIS |
| 74 | + Test Cluster Unplanned Failover Job. |
| 75 | +#> |
| 76 | +function Test-ClusterUnplannedFailoverJob { |
| 77 | + $primaryContainerName = getClusterPrimaryContainerName |
| 78 | + $primaryFabricName = getClusterPrimaryFabricName |
| 79 | + $recoveryResourceGroupName = getClusterRecoveryResourceGroupName |
| 80 | + $vaultResourceGroupName = getClusterVaultResourceGroupName |
| 81 | + $vaultName = getClusterVaultName |
| 82 | + $clusterName = getClusterName |
| 83 | + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $vaultResourceGroupName -Name $vaultName |
| 84 | + Set-ASRVaultContext -Vault $Vault |
| 85 | + $primaryFabric = get-asrFabric -Name $primaryFabricName |
| 86 | + $protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric |
| 87 | + $protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName |
| 88 | + |
| 89 | + $ufoJob = Start-AzRecoveryServicesAsrClusterUnplannedFailoverJob -ReplicationProtectionCluster $protectionCluster -Direction PrimaryToRecovery -LatestProcessedRecoveryPoint |
| 90 | + |
| 91 | + WaitForJobCompletion -JobId $ufoJob.Name |
| 92 | + #Get recovery vm and verify |
| 93 | + $recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1" |
| 94 | + Assert-NotNull($recvm.Id); |
| 95 | +} |
| 96 | + |
| 97 | +<# |
| 98 | +.SYNOPSIS |
| 99 | + Test Cluster Apply Cluster Recovery Point. |
| 100 | +#> |
| 101 | +function Test-ApplyClusterRecoveryPoint { |
| 102 | + $primaryContainerName = getClusterPrimaryContainerName |
| 103 | + $primaryFabricName = getClusterPrimaryFabricName |
| 104 | + $recoveryResourceGroupName = getClusterRecoveryResourceGroupName |
| 105 | + $vaultResourceGroupName = getClusterVaultResourceGroupName |
| 106 | + $vaultName = getClusterVaultName |
| 107 | + $clusterName = getClusterName |
| 108 | + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $vaultResourceGroupName -Name $vaultName |
| 109 | + Set-ASRVaultContext -Vault $Vault |
| 110 | + $primaryFabric = get-asrFabric -Name $primaryFabricName |
| 111 | + $protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric |
| 112 | + $protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName |
| 113 | + |
| 114 | + $changePitJob = Start-AzRecoveryServicesAsrApplyClusterRecoveryPoint -ReplicationProtectionCluster $protectionCluster -LatestProcessedRecoveryPoint |
| 115 | + |
| 116 | + WaitForJobCompletion -JobId $changePitJob.Name |
| 117 | + #Get recovery vm and verify |
| 118 | + $recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1" |
| 119 | + Assert-NotNull($recvm.Id); |
| 120 | +} |
| 121 | + |
| 122 | +<# |
| 123 | +.SYNOPSIS |
| 124 | + Test Cluster Commit Failover Job. |
| 125 | +#> |
| 126 | +function Test-ClusterCommitFailoverJob { |
| 127 | + $primaryContainerName = getClusterPrimaryContainerName |
| 128 | + $primaryFabricName = getClusterPrimaryFabricName |
| 129 | + $recoveryResourceGroupName = getClusterRecoveryResourceGroupName |
| 130 | + $vaultResourceGroupName = getClusterVaultResourceGroupName |
| 131 | + $vaultName = getClusterVaultName |
| 132 | + $clusterName = getClusterName |
| 133 | + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $vaultResourceGroupName -Name $vaultName |
| 134 | + Set-ASRVaultContext -Vault $Vault |
| 135 | + $primaryFabric = get-asrFabric -Name $primaryFabricName |
| 136 | + $protectionContainer = get-asrProtectionContainer -Name $primaryContainerName -Fabric $primaryFabric |
| 137 | + $protectionCluster = get-ASRReplicationProtectionCluster -ProtectionContainer $protectionContainer -Name $clusterName |
| 138 | + |
| 139 | + $CommitFailoverJob = Start-AzRecoveryServicesAsrClusterCommitFailoverJob -ReplicationProtectionCluster $protectionCluster |
| 140 | + |
| 141 | + WaitForJobCompletion -JobId $CommitFailoverJob.Name |
| 142 | + #Get recovery vm and verify |
| 143 | + $recvm = get-azVm -ResourceGroupName $recoveryResourceGroupName -Name "sdgql1" |
| 144 | + Assert-NotNull($recvm.Id); |
| 145 | +} |
| 146 | + |
20 | 147 | <#
|
21 | 148 | .SYNOPSIS
|
22 | 149 | NewA2ADiskReplicationConfiguration creation test.
|
|
0 commit comments