Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL] Check if DB is created by log replay before dropping it #18409

Merged
merged 6 commits into from
Jun 9, 2022
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 @@ -72,5 +72,12 @@ public void TestPipingCompleteCancelManagedDatabaseLogReplayService()
{
RunPowerShellTest("Test-PipingCompleteCancelManagedDatabaseLogReplay");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCancelManagedDatabaseLogReplayFailForWrongDatabase()
{
RunPowerShellTest("Test-CancelManagedDatabaseLogReplayFailForWrongDatabase");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,36 @@ function Test-PipingCompleteCancelManagedDatabaseLogReplay
}
}

<#
.SYNOPSIS
Tests Managed Database Log Replay cancel on a wrong database
#>
function Test-CancelManagedDatabaseLogReplayFailForWrongDatabase
{
# Setup
$rg = Create-ResourceGroupForTest
$managedInstance = Create-ManagedInstanceForTest $rg

$rgName = $rg.ResourceGroupName
$managedInstance = $managedInstance.ManagedInstanceName

try
{
# Start log replay
$managedDatabaseName = Get-ManagedDatabaseName
$db = New-AzSqlInstanceDatabase -ResourceGroupName $rgName -InstanceName $managedInstance -Name $managedDatabaseName

# Stop log replay on a DB that's not created with log replay should fail
Assert-ThrowsContains { $db | Stop-AzSqlInstanceDatabaseLogReplay -Force } "error"
$notDeletedDB = Get-AzSqlInstanceDatabase -ResourceGroupName $rgName -InstanceName $managedInstance -Name $managedDatabaseName
Assert-NotNull $notDeletedDB
}
finally
{
Remove-ResourceGroupForTest $rg
}
}

function Generate-SasToken ($rgname)
{
$key = Get-AzStorageAccountKey -ResourceGroupName $rgname -Name $stoname;
Expand Down
Loading