Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function getVaultLocation{

function getPrimaryLocation
{
return "EastUS"
return "EastUS2"
}

function getLocationForEZScenario
Expand All @@ -52,7 +52,7 @@ function getLocationForEZAzScenario

function getPrimaryZoneLocation
{
return "EastUS"
return "EastUS2"
}

function getPrimaryExtendedLocation
Expand Down Expand Up @@ -201,7 +201,7 @@ function createAzureVm{
$stnd = "Standard"
$password=$VMLocalAdminSecurePassword|ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $password);
$vm = New-AzVM -Name $VMName -Credential $Credential -location $VMLocation -Image RHELRaw8LVMGen2 -DomainNameLabel $domain -SecurityType $stnd
$vm = New-AzVM -Name $VMName -Credential $Credential -location $VMLocation -Image 'MicrosoftWindowsServer:WindowsServer:2022-datacenter-azure-edition:latest' -DomainNameLabel $domain -SecurityType $stnd
return $vm.Id
}

Expand Down Expand Up @@ -255,7 +255,7 @@ function createAzureVmInAvailabilityZone{
$stnd = "Standard"
$password=$VMLocalAdminSecurePassword|ConvertTo-SecureString -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser, $password);
$vm = New-AzVM -Name $VMName -Credential $Credential -location $VMLocation -Image RHELRaw8LVMGen2 -DomainNameLabel $domain -Zone $VMZone -SecurityType $stnd
$vm = New-AzVM -Name $VMName -Credential $Credential -location $VMLocation -Image 'MicrosoftWindowsServer:WindowsServer:2022-datacenter-azure-edition:latest' -DomainNameLabel $domain -Zone $VMZone -SecurityType $stnd
return $vm.Id
}

Expand Down Expand Up @@ -375,16 +375,17 @@ function createCacheStorageAccount{
}

function createCacheStorageAccountForZone{
param([string] $location , [string] $resourceGroup)
param([string] $location , [string] $resourceGroup, [string] $type)

$type = if ($type) { $type } else { 'Standard_LRS' }
$StorageAccountName = getCacheStorageAccountName
$cacheLocation = getPrimaryZoneLocation
$storageRes = getAzureVmName
$storageAccount = New-AzStorageAccount `
-ResourceGroupName $storageRes `
-Location $cacheLocation `
-Name $StorageAccountName `
-Type 'Standard_LRS'
-Type $type
return $storageAccount.Id
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void TestNewA2ADiskReplicationConfig()
"Test-NewA2ADiskReplicationConfiguration");
}

[Fact(Skip = "to be re-recorded in next release")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewA2AManagedDiskReplicationConfig()
{
Expand All @@ -50,6 +50,27 @@ public void TestNewA2AManagedDiskReplicationConfig()
"Test-NewA2AManagedDiskReplicationConfiguration");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewA2AManagedDiskReplicationConfigForPv2()
{
TestRunner.RunTestScript(
$"Import-Module {_helperModule.AsAbsoluteLocation()}",
$"Import-Module {_testModule.AsAbsoluteLocation()}",
"Test-NewA2AManagedDiskReplicationConfigurationForPv2");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewA2AManagedDiskReplicationConfigForUltraDisk()
{
TestRunner.RunTestScript(
$"Import-Module {_helperModule.AsAbsoluteLocation()}",
$"Import-Module {_testModule.AsAbsoluteLocation()}",
"Test-NewA2AManagedDiskReplicationConfigurationForUltraDisk");
}


[Fact(Skip = "to be re-recorded in next release")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewA2AManagedDiskReplicationConfigWithCmk()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,188 @@

##Default Value ##

<#
.SYNOPSIS
NewA2ADiskReplicationConfigurationUltraDisk creation test.
#>
function Test-NewA2AManagedDiskReplicationConfigurationForUltraDisk {
param([string] $seed = '108')

$primaryPolicyName = getPrimaryPolicy
$recoveryPolicyName = getRecoveryPolicy

$primaryContainerMappingName = getPrimaryContainerMapping
$recoveryContainerMappingName = getRecoveryContainerMapping

$primaryContainerName = getPrimaryContainer
$recoveryContainerName = getRecoveryContainer
$vaultRgLocation = getVaultRgLocation
$vaultName = getVaultName
$vaultLocation = getVaultLocation
$vaultRg = getVaultRg
$primaryLocation = getPrimaryLocation
$recoveryLocation = getRecoveryLocation
$primaryFabricName = getPrimaryFabric
$recoveryFabricName = getRecoveryFabric
$RecoveryReplicaDiskAccountType = "Premium_LRS"
$RecoveryTargetDiskAccountType = "UltraSSD_LRS"
$policyName = getPrimaryPolicy
$mappingName = getPrimaryContainerMapping
$primaryNetMapping = getPrimaryNetworkMapping

#create recovery side resources
$recRgName = getRecoveryResourceGroupName
New-AzResourceGroup -name $recRgName -location $recoveryLocation -force
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
$RecoveryAzureNetworkId = createRecoveryNetworkId

#create primary
$vmName = getAzureVmName
$v2VmId = createAzureVmInAvailabilityZone
$vm = get-azVm -ResourceGroupName $vmName -Name $vmName

# Stop the VM
Stop-AzVM -Name $vmName -ResourceGroupName $vmName -force
# Enable Ultra Disk compatibility
$vm = Get-AzVM -name $vmName -ResourceGroupName $vmName
Update-AzVM -ResourceGroupName $vmName -VM $vm -UltraSSDEnabled $True
# Start the VM
Start-AzVM -Name $vmName -ResourceGroupName $vmName

#create disk and attach
$diskName = getAzureDataDiskName
$primaryZone = getPrimaryZone
$newDiskConfig = New-AzDiskConfig -SkuName 'UltraSSD_LRS' -Location $vm.Location -CreateOption Empty -DiskSizeGB 20 -Zone $primaryZone
$newDisk = New-AzDisk -ResourceGroupName $vm.ResourceGroupName -DiskName $diskName -Disk $newDiskConfig
$vm = Add-AzVMDataDisk -VM $vm -Name $diskName -CreateOption Attach -ManagedDiskId $newDisk.Id -Lun 1
Update-azVm -ResourceGroupName $vmName -VM $vm


$logStg = createCacheStorageAccountForZone($vm.Location, $vm.ReservationGroupName, "Premium_LRS")
$dataDiskId = $vm.StorageProfile.DataDisks[0].ManagedDisk.Id
$index = $v2VmId.IndexOf("/providers/")
$Rg = $v2VmId.Substring(0, $index)
$PrimaryAzureNetworkId = $Rg + "/providers/Microsoft.Network/virtualNetworks/" + $vmName

# vault Creation
New-AzResourceGroup -name $vaultRg -location $vaultRgLocation -force
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
New-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName -Location $vaultLocation
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
$Vault = Get-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName
Set-ASRVaultContext -Vault $Vault

# fabric Creation
$fabJob = New-AzRecoveryServicesAsrFabric -Azure -Name $primaryFabricName -Location $primaryLocation
WaitForJobCompletion -JobId $fabJob.Name
$fab = Get-AzRecoveryServicesAsrFabric -Name $primaryFabricName
Assert-true { $fab.name -eq $primaryFabricName }
Assert-AreEqual $fab.FabricSpecificDetails.Location $primaryLocation

$fabJob = New-AzRecoveryServicesAsrFabric -Azure -Name $recoveryFabricName -Location $recoveryLocation
WaitForJobCompletion -JobId $fabJob.Name
$fab = Get-AzRecoveryServicesAsrFabric -Name $recoveryFabricName
Assert-true { $fab.name -eq $recoveryFabricName }
Assert-AreEqual $fab.FabricSpecificDetails.Location $recoveryLocation
$pf = get-asrFabric -Name $primaryFabricName
$rf = get-asrFabric -Name $recoveryFabricName

$RecoveryResourceGroupId = "/subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/" + $recRgName

$v = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $logStg `
-DiskId $dataDiskId -RecoveryResourceGroupId $RecoveryResourceGroupId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType `
-RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType

Assert-True { $v.DiskId -eq $dataDiskId }
}

<#
.SYNOPSIS
NewA2ADiskReplicationConfigurationPv2 creation test.
#>
function Test-NewA2AManagedDiskReplicationConfigurationForPv2 {
param([string] $seed = '107')

$primaryPolicyName = getPrimaryPolicy
$recoveryPolicyName = getRecoveryPolicy

$primaryContainerMappingName = getPrimaryContainerMapping
$recoveryContainerMappingName = getRecoveryContainerMapping

$primaryContainerName = getPrimaryContainer
$recoveryContainerName = getRecoveryContainer
$vaultRgLocation = getVaultRgLocation
$vaultName = getVaultName
$vaultLocation = getVaultLocation
$vaultRg = getVaultRg
$primaryLocation = getPrimaryLocation
$recoveryLocation = getRecoveryLocation
$primaryFabricName = getPrimaryFabric
$recoveryFabricName = getRecoveryFabric
$RecoveryReplicaDiskAccountType = "Premium_LRS"
$RecoveryTargetDiskAccountType = "PremiumV2_LRS"
$policyName = getPrimaryPolicy
$mappingName = getPrimaryContainerMapping
$primaryNetMapping = getPrimaryNetworkMapping

#create recovery side resources
$recRgName = getRecoveryResourceGroupName
New-AzResourceGroup -name $recRgName -location $recoveryLocation -force
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
$RecoveryAzureNetworkId = createRecoveryNetworkId

#create primary
$vmName = getAzureVmName
$v2VmId = createAzureVmInAvailabilityZone
$vm = get-azVm -ResourceGroupName $vmName -Name $vmName

#create disk and attach
$diskName = getAzureDataDiskName
$primaryZone = getPrimaryZone
$newDiskConfig = New-AzDiskConfig -SkuName 'PremiumV2_LRS' -Location $vm.Location -CreateOption Empty -DiskSizeGB 20 -Zone $primaryZone
$newDisk = New-AzDisk -ResourceGroupName $vm.ResourceGroupName -DiskName $diskName -Disk $newDiskConfig
$vm = Add-AzVMDataDisk -VM $vm -Name $diskName -CreateOption Attach -ManagedDiskId $newDisk.Id -Lun 1
Update-azVm -ResourceGroupName $vmName -VM $vm


$logStg = createCacheStorageAccountForZone($vm.Location, $vm.ReservationGroupName, "Premium_LRS")
$dataDiskId = $vm.StorageProfile.DataDisks[0].ManagedDisk.Id
$index = $v2VmId.IndexOf("/providers/")
$Rg = $v2VmId.Substring(0, $index)
$PrimaryAzureNetworkId = $Rg + "/providers/Microsoft.Network/virtualNetworks/" + $vmName

# vault Creation
New-AzResourceGroup -name $vaultRg -location $vaultRgLocation -force
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
New-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName -Location $vaultLocation
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
$Vault = Get-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName
Set-ASRVaultContext -Vault $Vault

# fabric Creation
$fabJob = New-AzRecoveryServicesAsrFabric -Azure -Name $primaryFabricName -Location $primaryLocation
WaitForJobCompletion -JobId $fabJob.Name
$fab = Get-AzRecoveryServicesAsrFabric -Name $primaryFabricName
Assert-true { $fab.name -eq $primaryFabricName }
Assert-AreEqual $fab.FabricSpecificDetails.Location $primaryLocation

$fabJob = New-AzRecoveryServicesAsrFabric -Azure -Name $recoveryFabricName -Location $recoveryLocation
WaitForJobCompletion -JobId $fabJob.Name
$fab = Get-AzRecoveryServicesAsrFabric -Name $recoveryFabricName
Assert-true { $fab.name -eq $recoveryFabricName }
Assert-AreEqual $fab.FabricSpecificDetails.Location $recoveryLocation
$pf = get-asrFabric -Name $primaryFabricName
$rf = get-asrFabric -Name $recoveryFabricName

$RecoveryResourceGroupId = "/subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/" + $recRgName

$v = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $logStg `
-DiskId $dataDiskId -RecoveryResourceGroupId $RecoveryResourceGroupId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType `
-RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType

Assert-True { $v.DiskId -eq $dataDiskId }
}

<#
.SYNOPSIS
NewA2ADiskReplicationConfiguration creation test.
Expand Down
Loading