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 Ledger Cmdlets #14997

Merged
merged 86 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
dbdcfc0
ledger changes + changes for new SDK version
rewongmicrosoft May 13, 2021
af01912
adding tests, updating cmdlets
rewongmicrosoft May 13, 2021
9b02401
adding tests, fixing cmdlets
rewongmicrosoft May 14, 2021
5dc5c66
adding comments to locations model
rewongmicrosoft May 14, 2021
7b3d2db
adding to changelog.md
rewongmicrosoft May 14, 2021
6225512
adding markdowe help files
rewongmicrosoft May 14, 2021
801da5e
fixing merge problems with backup restore resources
rewongmicrosoft May 14, 2021
4a6b843
updating help file for new-azsqldatabase
rewongmicrosoft May 14, 2021
b24ecb7
rerecording tests
rewongmicrosoft May 14, 2021
efef183
removing EnableLedger from Set-AzureSqlDatabase
rewongmicrosoft May 14, 2021
ca33bc4
removing extra parameter
rewongmicrosoft May 14, 2021
c71933f
adding whatif text
rewongmicrosoft May 14, 2021
2e76d33
upgrading Microsoft.Azure.Management.Sql to 1.52
rewongmicrosoft May 14, 2021
0276433
fixing online version link
rewongmicrosoft May 14, 2021
05c8a6e
adding audit action group for ledger
rewongmicrosoft May 15, 2021
7b01c3d
adding default parameter set
rewongmicrosoft May 15, 2021
b732ead
adding default parameter set
rewongmicrosoft May 15, 2021
033f2cf
adding -EnableLedger description to new-azsqldatabase help file
rewongmicrosoft May 15, 2021
2f1d5b1
adding ResourceIdentityWithUserAssignedIdentities to breaking changes…
rewongmicrosoft May 15, 2021
cf9a296
adding breaking change message
rewongmicrosoft May 16, 2021
0bebc05
fixing type name
rewongmicrosoft May 16, 2021
ea33943
adding using directive
rewongmicrosoft May 16, 2021
fa97167
updating breaking changes message
rewongmicrosoft May 16, 2021
14b7295
testing updating TestDatabaseDataMaskingPrivilegedUsersChanges test
rewongmicrosoft May 16, 2021
547499a
adding first batch of test re-records
rewongmicrosoft May 17, 2021
510d4c4
adding more re-recordings
rewongmicrosoft May 17, 2021
dabf2b9
more changes for re-recording
rewongmicrosoft May 17, 2021
0633b81
adding re-recordings, adding ignore api version to some tests
rewongmicrosoft May 17, 2021
f0591fd
adding ignore API version to instance pools test
rewongmicrosoft May 18, 2021
dfd0f0c
removing ignore API version from Auditing
rewongmicrosoft May 18, 2021
7599efa
adding auditing tests, removing database override from vulnerability …
rewongmicrosoft May 18, 2021
4640b3e
addding test re-recordings
rewongmicrosoft May 19, 2021
94ecd76
updating version to newest SDK, removing breaking change warnings
rewongmicrosoft May 19, 2021
3641573
adding server crud test re-records, instance pool crud tests to ignor…
rewongmicrosoft May 19, 2021
fc7a898
adding skip to managed instance tests
rewongmicrosoft May 20, 2021
cd90d0d
Commenting out instance pool, adding vulnerability assessment tests
rewongmicrosoft May 20, 2021
5b12258
Adding more test rescordings, skipping tests
rewongmicrosoft May 20, 2021
c79598f
reverting unneeded file changes
rewongmicrosoft May 20, 2021
830d876
Merge branch 'master' into sqlledger
rewongmicrosoft May 25, 2021
fb8838f
Update ChangeLog.md
wyunchi-ms May 25, 2021
8b09bcb
rerecording test
rewongmicrosoft May 25, 2021
3763528
Merge branch 'sqlledger' of https://github.com/rewongmicrosoft/azure-…
rewongmicrosoft May 25, 2021
8a43525
update changelog
rewongmicrosoft May 25, 2021
785a61e
ledger changes + changes for new SDK version
rewongmicrosoft May 13, 2021
74767bf
adding tests, updating cmdlets
rewongmicrosoft May 13, 2021
8dd0b33
adding tests, fixing cmdlets
rewongmicrosoft May 14, 2021
f107957
adding comments to locations model
rewongmicrosoft May 14, 2021
3f51814
adding to changelog.md
rewongmicrosoft May 14, 2021
12db9b2
adding markdowe help files
rewongmicrosoft May 14, 2021
6e73321
fixing merge problems with backup restore resources
rewongmicrosoft May 14, 2021
5430b6b
updating help file for new-azsqldatabase
rewongmicrosoft May 14, 2021
32fc76f
rerecording tests
rewongmicrosoft May 14, 2021
f13328c
removing EnableLedger from Set-AzureSqlDatabase
rewongmicrosoft May 14, 2021
003a6d8
removing extra parameter
rewongmicrosoft May 14, 2021
d1b451c
adding whatif text
rewongmicrosoft May 14, 2021
a8eda69
upgrading Microsoft.Azure.Management.Sql to 1.52
rewongmicrosoft May 14, 2021
f4c7b84
fixing online version link
rewongmicrosoft May 14, 2021
d76b84c
adding audit action group for ledger
rewongmicrosoft May 15, 2021
6fb3579
adding default parameter set
rewongmicrosoft May 15, 2021
acff20a
adding default parameter set
rewongmicrosoft May 15, 2021
a8129ad
adding -EnableLedger description to new-azsqldatabase help file
rewongmicrosoft May 15, 2021
c7a5413
adding ResourceIdentityWithUserAssignedIdentities to breaking changes…
rewongmicrosoft May 15, 2021
a580359
adding breaking change message
rewongmicrosoft May 16, 2021
1a851dd
fixing type name
rewongmicrosoft May 16, 2021
8c1471c
adding using directive
rewongmicrosoft May 16, 2021
9585886
updating breaking changes message
rewongmicrosoft May 16, 2021
481b086
testing updating TestDatabaseDataMaskingPrivilegedUsersChanges test
rewongmicrosoft May 16, 2021
9686c98
adding first batch of test re-records
rewongmicrosoft May 17, 2021
89a17c1
adding more re-recordings
rewongmicrosoft May 17, 2021
6e33b2e
more changes for re-recording
rewongmicrosoft May 17, 2021
f422f37
adding re-recordings, adding ignore api version to some tests
rewongmicrosoft May 17, 2021
94f1627
adding ignore API version to instance pools test
rewongmicrosoft May 18, 2021
fda30bf
removing ignore API version from Auditing
rewongmicrosoft May 18, 2021
c67c789
adding auditing tests, removing database override from vulnerability …
rewongmicrosoft May 18, 2021
87b1a74
addding test re-recordings
rewongmicrosoft May 19, 2021
af1c19c
updating version to newest SDK, removing breaking change warnings
rewongmicrosoft May 19, 2021
e248b32
adding server crud test re-records, instance pool crud tests to ignor…
rewongmicrosoft May 19, 2021
12e0f35
adding skip to managed instance tests
rewongmicrosoft May 20, 2021
d22d599
Commenting out instance pool, adding vulnerability assessment tests
rewongmicrosoft May 20, 2021
d95f104
Adding more test rescordings, skipping tests
rewongmicrosoft May 20, 2021
78a9386
reverting unneeded file changes
rewongmicrosoft May 20, 2021
8a3afed
rerecording test
rewongmicrosoft May 25, 2021
13f56e7
Update ChangeLog.md
wyunchi-ms May 25, 2021
227dc72
update changelog
rewongmicrosoft May 25, 2021
cb1a3ca
Merge branch 'sqlledger' of https://github.com/rewongmicrosoft/azure-…
rewongmicrosoft May 26, 2021
5bffdde
re-recording named secondary test after rebase
rewongmicrosoft May 26, 2021
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 @@ -39,7 +39,7 @@ public AdvancedDataSecurityManagedInstanceTests(ITestOutputHelper output) : base
};
}

[Fact]
[Fact(Skip = "Cannot re-record.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void AdvancedDataSecurityPolicyTest()
{
Expand Down
41 changes: 41 additions & 0 deletions src/Sql/Sql.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,47 @@ function Create-BasicTestEnvironmentWithParams ($params, $location, $serverVersi
New-AzSqlDatabase -DatabaseName $params.databaseName -ResourceGroupName $params.rgname -ServerName $params.serverName -Edition Basic -Force
}

<#
.SYNOPSIS
Gets the values of the parameters used for ledger digest upload tests
#>
function Get-LedgerTestEnvironmentParameters ($testSuffix)
{
return @{ subscriptionId = (Get-AzContext).Subscription.Id;
rgname = "ledger-cmdlet-test-rg" + $testSuffix;
serverName = "ledger-cmdlet-server" + $testSuffix;
databaseName = "ledger-cmdlet-db" + $testSuffix;
}
}

<#
.SYNOPSIS
Creates the basic test environment used for the ledger tests - creates resource group, server, and database
#>
function Create-LedgerTestEnvironment ($params)
{
$location = "eastus2euap"
$serverVersion = "12.0"
New-AzResourceGroup -Name $params.rgname -Location $location
$serverName = $params.serverName
$serverLogin = "testusername"
<#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Test passwords only valid for the duration of the test")]#>
$serverPassword = "t357ingP@s5w0rd!ledger"
$credentials = new-object System.Management.Automation.PSCredential($serverLogin, ($serverPassword | ConvertTo-SecureString -asPlainText -Force))
New-AzSqlServer -ResourceGroupName $params.rgname -ServerName $params.serverName -Location $location -ServerVersion $serverVersion -SqlAdministratorCredentials $credentials
New-AzSqlDatabase -DatabaseName $params.databaseName -ResourceGroupName $params.rgname -ServerName $params.serverName -Edition Basic
}

<#
.SYNOPSIS
Removes the test environment that was needed to perform the ledger digest upload tests
#>
function Remove-LedgerTestEnvironment ($testSuffix)
{
$params = Get-LedgerTestEnvironmentParameters $testSuffix
Remove-AzResourceGroup -Name $params.rgname -Force
}

<#
.SYNOPSIS
Creates the basic test environment needed to perform the Sql data security tests - resource group, managed instance and managed database
Expand Down
4 changes: 2 additions & 2 deletions src/Sql/Sql.Test/ScenarioTests/DatabaseBackupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DatabaseBackupTests(ITestOutputHelper output) : base(output)
};
}

[Fact]
[Fact(Skip = "Not recordable")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListDatabaseRestorePoints()
{
Expand Down Expand Up @@ -171,7 +171,7 @@ public void TestNewDatabaseRestorePoint()
}
}

[Fact]
[Fact(Skip = "Not recordable")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveDatabaseRestorePoint()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Sql/Sql.Test/ScenarioTests/DatabaseBackupTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function Test-LongTermRetentionV2Policy($location = "southeastasia")
{
# Create with default values
$databaseName = Get-DatabaseName
$db = New-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName
$db = New-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -Force

# Basic Policy Test
Set-AzSqlDatabaseLongTermRetentionPolicy -ResourceGroup $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -WeeklyRetention $weeklyRetention2
Expand Down Expand Up @@ -194,7 +194,7 @@ function Test-LongTermRetentionV2Backup($location = "southeastasia")
{
# Create with default values
$databaseName = Get-DatabaseName
$db = New-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName
$db = New-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -Force

# Basic Get Tests
Get-AzSqlDatabaseLongTermRetentionBackup -Location $db.Location
Expand All @@ -221,7 +221,7 @@ function Test-LongTermRetentionV2ResourceGroupBasedBackup($location = "southeast
{
# Create with default values
$databaseName = Get-DatabaseName
$db = New-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName
$db = New-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -Force

# Basic Get Tests
Get-AzSqlDatabaseLongTermRetentionBackup -Location $db.Location -ResourceGroupName $server.ResourceGroupName
Expand Down
7 changes: 7 additions & 0 deletions src/Sql/Sql.Test/ScenarioTests/DatabaseCrudTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,12 @@ public void TestDatabaseGetWithBackupStorageRedundancy()
{
RunPowerShellTest("Test-GetDatabaseWithBackupStorageRedundancy");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseCreateWithLedgerEnabled()
{
RunPowerShellTest("Test-DatabaseCreateWithLedgerEnabled");
}
}
}
32 changes: 29 additions & 3 deletions src/Sql/Sql.Test/ScenarioTests/DatabaseCrudTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ function Test-CreateDatabaseWithZoneRedundancy
function Test-CreateDatabaseWithMaintenanceConfigurationId
{
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "East US 2 EUAP"
# Further actions required if you use Microsoft internal subscription. Please contact feature owners
$location = Get-Location "Microsoft.Sql" "operations" "West Europe"
$rg = Create-ResourceGroupForTest $location

try
Expand Down Expand Up @@ -630,7 +631,8 @@ function Test-UpdateDatabaseWithZoneRedundant ()
function Test-UpdateDatabaseWithMaintenanceConfigurationId
{
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "East US 2 EUAP"
# Further actions required if you use Microsoft internal subscription. Please contact feature owners
$location = Get-Location "Microsoft.Sql" "operations" "West Europe"
$rg = Create-ResourceGroupForTest $location

try
Expand Down Expand Up @@ -939,7 +941,8 @@ function Test-GetDatabaseWithZoneRedundancy
function Test-GetDatabaseWithMaintenanceConfigurationId
{
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "East US 2 EUAP"
# Further actions required if you use Microsoft internal subscription. Please contact feature owners
$location = Get-Location "Microsoft.Sql" "operations" "West Europe"
$rg = Create-ResourceGroupForTest $location
try
{
Expand Down Expand Up @@ -972,6 +975,29 @@ function Test-GetDatabaseWithMaintenanceConfigurationId
}
}

<#
.SYNOPSIS
Tests creating a database with ledger enabled
#>
function Test-DatabaseCreateWithLedgerEnabled ($location = "eastus2euap")
{
# Setup
$rg = Create-ResourceGroupForTest
$server = Create-ServerForTest $rg $location

# Create with ledger enabled
$databaseName = Get-DatabaseName
$db1 = New-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -EnableLedger -Force
Assert-AreEqual $db1.DatabaseName $databaseName
Assert-AreEqual "True" $db1.EnableLedger

# Validate Get-AzSqlDatabase returns ledger property
$databaseFromGet = Get-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName
Assert-AreEqual "True" $databaseFromGet.EnableLedger

Remove-ResourceGroupForTest $rg
}

<#
.SYNOPSIS
Tests Deleting a database
Expand Down
9 changes: 6 additions & 3 deletions src/Sql/Sql.Test/ScenarioTests/ElasticPoolCrudTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ function Test-CreateElasticPoolWithZoneRedundancy
function Test-CreateElasticPoolWithMaintenanceConfigurationId
{
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "East US 2 EUAP"
# Further actions required if you use Microsoft internal subscription. Please contact feature owners
$location = Get-Location "Microsoft.Sql" "operations" "West Europe"
$rg = Create-ResourceGroupForTest $location

try
Expand Down Expand Up @@ -411,7 +412,8 @@ function Test-UpdateElasticPoolWithZoneRedundancy
function Test-UpdateElasticPoolWithMaintenanceConfigurationId
{
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "East US 2 EUAP"
# Further actions required if you use Microsoft internal subscription. Please contact feature owners
$location = Get-Location "Microsoft.Sql" "operations" "West Europe"
$rg = Create-ResourceGroupForTest $location

try
Expand Down Expand Up @@ -542,7 +544,8 @@ function Test-GetElasticPoolWithZoneRedundancy
function Test-GetElasticPoolWithMaintenanceConfigurationId
{
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "East US 2 EUAP"
# Further actions required if you use Microsoft internal subscription. Please contact feature owners
$location = Get-Location "Microsoft.Sql" "operations" "West Europe"
$rg = Create-ResourceGroupForTest $location
try
{
Expand Down
8 changes: 4 additions & 4 deletions src/Sql/Sql.Test/ScenarioTests/ImportExportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ public ImportExportTests(ITestOutputHelper output) : base(output)
};
}

[Fact]
[Fact(Skip = "Cannot re-record.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestExportDatabase()
{
RunPowerShellTest("Test-ExportDatabase");
}

[Fact]
[Fact(Skip = "Cannot re-record.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestExportDatabase_NetworkIsolation()
{
RunPowerShellTest("Test-ExportDatabaseNetworkIsolation");
}

[Fact]
[Fact(Skip = "Cannot re-record.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Sql, "Needs to be re-recorded")]
public void TestImportNewDatabase()
{
RunPowerShellTest("Test-ImportNewDatabase");
}

[Fact]
[Fact(Skip = "Cannot re-record.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Sql, "Needs to be re-recorded")]
public void TestImportNewDatabase_NetworkIsolation()
Expand Down
24 changes: 12 additions & 12 deletions src/Sql/Sql.Test/ScenarioTests/InstanceFailoverGroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,84 +25,84 @@ public InstanceFailoverGroupTests(ITestOutputHelper output) : base(output)
{
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateInstanceFailoverGroup_Named()
{
RunPowerShellTest("Test-CreateInstanceFailoverGroup-Named");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateInstanceFailoverGroup_Positional()
{
RunPowerShellTest("Test-CreateInstanceFailoverGroup-Positional");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateInstanceFailoverGroup_AutomaticPolicy()
{
RunPowerShellTest("Test-CreateInstanceFailoverGroup-AutomaticPolicy");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateInstanceFailoverGroup_AutomaticPolicyGracePeriodReadOnlyFailover()
{
RunPowerShellTest("Test-CreateInstanceFailoverGroup-AutomaticPolicyGracePeriodReadOnlyFailover");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateInstanceFailoverGroup_ManualPolicy()
{
RunPowerShellTest("Test-CreateInstanceFailoverGroup-ManualPolicy");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetInstanceFailoverGroup_Named()
{
RunPowerShellTest("Test-SetInstanceFailoverGroup-Named");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetInstanceFailoverGroup_Positional()
{
RunPowerShellTest("Test-SetInstanceFailoverGroup-Positional");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetInstanceFailoverGroup_AutomaticWithGracePeriodReadOnlyFailover()
{
RunPowerShellTest("Test-SetInstanceFailoverGroup-AutomaticWithGracePeriodReadOnlyFailover");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetInstanceFailoverGroup_AutomaticToManual()
{
RunPowerShellTest("Test-SetInstanceFailoverGroup-AutomaticToManual");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetInstanceFailoverGroup_ManualToAutomaticNoGracePeriod()
{
RunPowerShellTest("Test-SetInstanceFailoverGroup-ManualToAutomaticNoGracePeriod");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void Test_SwitchInstanceFailoverGroup()
{
RunPowerShellTest("Test-SwitchInstanceFailoverGroup");
}

[Fact]
[Fact(Skip = "Has manual setup, unable to re-record")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void Test_SwitchInstanceFailoverGroupAllowDataLoss()
{
Expand Down
Loading