Skip to content

Commit

Permalink
[InAccountRestore] Introducing new PowerShell commands for InAccount …
Browse files Browse the repository at this point in the history
…Restore of Deleted Database/ Containers feature (Azure#19601)

* Cosmos DB: Update to 2.0.0 and Add support for NetworkAclBypass in Account (Azure#14211)

* Make changes for Network Acl Bypass

* Add help file updates

* Changes with enum not as string

* rerun tests

* Remove extra line

* rerun gremlin test with updated

* Update ChangeLog.md

Co-authored-by: Yabo Hu <yabhu@microsoft.com>

* InAccount Restore feature powershell support

* update session records

* update session records and help files

* address comments for validation and in changelog.md

* add session records for new tests and update help files

* add update help files

* update session records after rebase

* updated New-AzCosmosDBAccount.md and session records

* update session records with subscription id in variables and added ExampleIssues.csv

* update nuget package version and remove localfeed files

Co-authored-by: amar-sagare <45947937+amar-sagare@users.noreply.github.com>
Co-authored-by: Yabo Hu <yabhu@microsoft.com>
  • Loading branch information
3 people committed Jan 18, 2024
1 parent 0481a4f commit 458e3cd
Show file tree
Hide file tree
Showing 62 changed files with 10,324 additions and 146 deletions.
2 changes: 1 addition & 1 deletion src/CosmosDB/CosmosDB.Test/CosmosDB.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PsModuleName>CosmosDB</PsModuleName>
</PropertyGroup>
Expand Down
14 changes: 14 additions & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/MongoOperationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,19 @@ public void TestMongoRBACCmdlets()
{
TestRunner.RunTestScript("Test-MongoRBACCmdlets");
}

[Fact(Skip = "Cannot acquire token credential for a specific audience. No support from test framework. I have verified the tests manually.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestMongoDBCollectionThroughputRedistributionCmdlet()
{
TestRunner.RunTestScript("Test-MongoDBCollectionAdaptiveRUCmdlets");
}

[Fact(Skip = "Cannot acquire token credential for a specific audience. No support from test framework. I have verified the tests manually.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestMongoDBCollectionMergeCmdlet()
{
TestRunner.RunTestScript("Test-MongoDBCollectionMergeCmdlet");
}
}
}
1 change: 1 addition & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/RestoreTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ function Test-RestoreFailuresAccountCmdlets {
Assert-AreEqual $sourceRestorableAccount.DatabaseAccountInstanceId $sourceCosmosDBAccount.InstanceId
Assert-NotNull $sourceRestorableAccount.DatabaseAccountName
Assert-NotNull $sourceRestorableAccount.CreationTime
Assert-NotNull $sourceRestorableAccount.OldestRestorableTime

$restorableSqlDatabases = Get-AzCosmosDBSqlRestorableDatabase -Location $sourceCosmosDBAccount.Location -DatabaseAccountInstanceId $sourceCosmosDBAccount.InstanceId
Assert-NotNull $restorableSqlDatabases
Expand Down
14 changes: 14 additions & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/SqlOperationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,19 @@ public void TestClientEncryptionKeyCmdletsUsingInputObject()
{
TestRunner.RunTestScript("Test-ClientEncryptionKeyCmdletsUsingInputObject");
}

[Fact(Skip = "Cannot acquire token credential for a specific audience. No support from test framework. I have verified the tests manually.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSqlContainerMergeCmdlet()
{
TestRunner.RunTestScript("Test-SqlContainerMergeCmdlet");
}

[Fact(Skip = "Cannot acquire token credential for a specific audience. No support from test framework. I have verified the tests manually.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSqlContainerAdaptiveRUCmdlets()
{
TestRunner.RunTestScript("Test-SqlContainerAdaptiveRUCmdlets");
}
}
}
111 changes: 111 additions & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/SqlOperationsTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1604,4 +1604,115 @@ function Test-ClientEncryptionKeyCmdletsUsingInputObject
Remove-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $location -Force
Remove-AzKeyVault -VaultName $vaultName -InRemovedState -Force -Location $location
}
}


<#
.SYNOPSIS
Test SQL Throughput redistribution cmdlets
#>
function Test-SqlContainerAdaptiveRUCmdlets
{
$AccountName = "mergetest"
$rgName = "canary-sdk-test"
$DatabaseName = "adaptiverudatabase"
$ContainerName = "adaptiveruContainer"

$PartitionKeyPathValue = "/foo/bar"
$PartitionKeyKindValue = "Hash"

$ContainerThroughputValue = 24000
$UpdatedContainerThroughputValue = 2000

Try{

New-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
New-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Throughput $ContainerThroughputValue -Name $ContainerName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
Update-AzCosmosDBSqlContainerThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName -Throughput $UpdatedContainerThroughputValue
$partitions = Get-AzCosmosDBSqlContainerPerPartitionThroughput -ResourceGroupName $rgName -AccountName $AccountName -DatabaseName $DatabaseName -Name $ContainerName -AllPartitions
Assert-AreEqual $partitions.Count 4
$sources = @()
$targets = @()
Foreach($partition in $partitions)
{
Assert-AreEqual $partition.Throughput 500
if($partition.Id -lt 2)
{
$throughput = $partition.Throughput - 100
$sources += New-AzCosmosDBPhysicalPartitionThroughputObject -Id $partition.Id -Throughput $throughput
}
else
{
$throughput = $partition.Throughput + 100
$targets += New-AzCosmosDBPhysicalPartitionThroughputObject -Id $partition.Id -Throughput $throughput
}
}

$newPartitions = Update-AzCosmosDBSqlContainerPerPartitionThroughput -ResourceGroupName $rgName -AccountName $AccountName -DatabaseName $DatabaseName -Name $ContainerName -SourcePhysicalPartitionThroughputObject $sources -TargetPhysicalPartitionThroughputObject $targets
Assert-AreEqual $newPartitions.Count 4
Foreach($partition in $newPartitions)
{
if($partition.Id -lt 2)
{
Assert-AreEqual $partition.Throughput 400
}
else
{
Assert-AreEqual $partition.Throughput 600
}
}

$resetPartitions = Update-AzCosmosDBSqlContainerPerPartitionThroughput -ResourceGroupName $rgName -AccountName $AccountName -DatabaseName $DatabaseName -Name $ContainerName -EqualDistributionPolicy

Assert-AreEqual $resetPartitions.Count 4

Foreach($partition in $resetPartitions)
{
Assert-AreEqual $partition.Throughput 500
}

$somePartitions = Get-AzCosmosDBSqlContainerPerPartitionThroughput -ResourceGroupName $rgName -AccountName $AccountName -DatabaseName $DatabaseName -Name $ContainerName -PhysicalPartitionIds ('0', '1')
Assert-AreEqual $somePartitions.Count 2
}
Finally{
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
}
}


<#
.SYNOPSIS
Test sql merge cmdlet
#>
function Test-SqlContainerMergeCmdlet
{
$AccountName = "mergetest"
$rgName = "canary-sdk-test"
$DatabaseName = "mergedatabase"
$ContainerName = "mergecontainer"

$PartitionKeyPathValue = "/foo/bar"
$PartitionKeyKindValue = "Hash"

$ContainerThroughputValue = 24000
$UpdatedContainerThroughputValue = 2000

Try{

New-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
New-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Throughput $ContainerThroughputValue -Name $ContainerName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
Update-AzCosmosDBSqlContainerThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName -Throughput $UpdatedContainerThroughputValue
$physicalPartitionStorageInfos = Invoke-AzCosmosDBSqlContainerMerge -ResourceGroupName $rgName -AccountName $AccountName -DatabaseName $DatabaseName -Name $ContainerName -Force
Assert-AreEqual $physicalPartitionStorageInfos.Count 1
if($physicalPartitionStorageInfos[0].Id.contains("mergeTarget"))
{
throw "Name of partition: " + $physicalPartitionStorageInfos[0].Id + " Unexpected Id: mergeTarget"
}

}
Finally{
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@
"Microsoft-HTTPAPI/2.0"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"11980"
"11955"
],
"x-ms-request-id": [
"6a4130a3-1b64-42fd-97b2-510675a5f160"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"no-cache"
],
"x-ms-ratelimit-remaining-subscription-writes": [
"1199"
"1197"
],
"x-ms-request-id": [
"e33649c9-18b1-4e68-9e1f-e3365002215c"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@
"Microsoft-HTTPAPI/2.0"
],
"x-ms-ratelimit-remaining-subscription-writes": [
"1199"
"1197"
],
"x-ms-correlation-request-id": [
"21d86a66-f538-44e2-9e50-9451fc0e1be7"
Expand Down Expand Up @@ -978,7 +978,7 @@
"Microsoft-HTTPAPI/2.0"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"11997"
"11944"
],
"x-ms-request-id": [
"00eb73a5-cd3c-4c35-902c-ba44d7fd73da"
Expand Down Expand Up @@ -1038,7 +1038,7 @@
"Microsoft-HTTPAPI/2.0"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"11996"
"11943"
],
"x-ms-request-id": [
"340a5b20-e1b6-4281-9612-689cde330292"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
"Microsoft-HTTPAPI/2.0"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"11998"
"11971"
],
"x-ms-request-id": [
"4f19e082-c722-4b02-80ab-116670436862"
Expand Down Expand Up @@ -282,7 +282,7 @@
"Microsoft-HTTPAPI/2.0"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"11995"
"11968"
],
"x-ms-request-id": [
"aefe342a-1096-48c7-9da3-1e8d91793dd9"
Expand Down Expand Up @@ -927,7 +927,7 @@
"Microsoft-HTTPAPI/2.0"
],
"x-ms-ratelimit-remaining-subscription-deletes": [
"14999"
"14998"
],
"x-ms-correlation-request-id": [
"f3a86c25-b61f-41a0-ad04-b9e92f51231b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Microsoft-HTTPAPI/2.0"
],
"x-ms-ratelimit-remaining-subscription-reads": [
"11999"
"11940"
],
"x-ms-request-id": [
"2a83f4d1-c616-460f-9327-af3c6bc59721"
Expand Down
Loading

0 comments on commit 458e3cd

Please sign in to comment.