Skip to content

[CosmosDB] Migration support for throughput #12814

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

Merged
merged 5 commits into from
Sep 8, 2020
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
2 changes: 1 addition & 1 deletion src/CosmosDB/CosmosDB.Test/CosmosDB.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.2.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.0.2-preview" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@ public void TestCassandraCreateUpdateGetCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CassandraCreateUpdateGetCmdlets");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCassandraMigrateThroughputCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CassandraMigrateThroughputCmdlets");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,61 @@ function Test-CassandraThroughputCmdlets
}
}

<#
.SYNOPSIS
Test Cassandra migrate throughput cmdlets
#>
function Test-CassandraMigrateThroughputCmdlets
{

$AccountName = "db2725"
$rgName = "CosmosDBResourceGroup2510"
$KeyspaceName = "KeyspaceName3"
$TableName = "tableName"

$ThroughputValue = 1200
$TableThroughputValue = 800

$Autoscale = "Autoscale"
$Manual = "Manual"

Try{
$Column1 = New-AzCosmosDBCassandraColumn -Name "ColumnA" -Type "int"
$Column2 = New-AzCosmosDBCassandraColumn -Name "ColumnB" -Type "ascii"
$clusterkey1 = New-AzCosmosDBCassandraClusterKey -Name "ColumnB" -OrderBy "Asc"
$schema = New-AzCosmosDBCassandraSchema -Column $Column1,$Column2 -ClusterKey $clusterkey1 -PartitionKey "ColumnA"

$NewKeyspace = New-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName -Throughput $ThroughputValue
$Throughput = Get-AzCosmosDBCassandraKeyspaceThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName
Assert-AreEqual $Throughput.Throughput $ThroughputValue
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0

$AutoscaleThroughput = Invoke-AzCosmosDBCassandraKeyspaceThroughputMigration -InputObject $NewKeyspace -ThroughputType $Autoscale
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0

$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
$ManualThroughput = Invoke-AzCosmosDBCassandraKeyspaceThroughputMigration -ParentObject $CosmosDBAccount -Name $KeyspaceName -ThroughputType $Manual
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0

$NewTable = New-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName -Schema $schema -Throughput $TableThroughputValue
$TableThroughput = Get-AzCosmosDBCassandraTableThroughput -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName
Assert-AreEqual $TableThroughput.Throughput $TableThroughputValue

$AutoscaledTableThroughput = Invoke-AzCosmosDBCassandraTableThroughputMigration -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName -ThroughputType $Autoscale
Assert-AreNotEqual $AutoscaledTableThroughput.AutoscaleSettings.MaxThroughput 0

$ManuaTableThroughput = Invoke-AzCosmosDBCassandraTableThroughputMigration -InputObject $NewTable -ThroughputType $Manual
Assert-AreEqual $ManuaTableThroughput.AutoscaleSettings.MaxThroughput 0

Remove-AzCosmosDBCassandraTable -InputObject $NewTable
Remove-AzCosmosDBCassandraKeyspace -InputObject $NewKeyspace
}
Finally{
Remove-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName
Remove-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName
}
}

function Validate-EqualColumns($Column1, $Column2)
{
Assert-AreEqual $Column1.Name $Column2.Name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@ public void TestGremlinThroughputCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GremlinThroughputCmdlets");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGremlinMigrateThroughputCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GremlinMigrateThroughputCmdlets");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,57 @@ function Test-GremlinThroughputCmdlets
Remove-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName
Remove-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
}
}

<#
.SYNOPSIS
Test Gremlin migrate throughput cmdlets
#>
function Test-GremlinMigrateThroughputCmdlets
{
$AccountName = "db1002"
$rgName = "CosmosDBResourceGroup2510"
$DatabaseName = "dbName4"
$GraphName = "graphName"

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

$ThroughputValue = 1200

$GraphThroughputValue = 800

$Autoscale = "Autoscale"
$Manual = "Manual"

Try{
$NewDatabase = New-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -Throughput $ThroughputValue
$Throughput = Get-AzCosmosDBGremlinDatabaseThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
Assert-AreEqual $Throughput.Throughput $ThroughputValue
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0

$AutoscaleThroughput = Invoke-AzCosmosDBGremlinDatabaseThroughputMigration -InputObject $NewDatabase -ThroughputType $Autoscale
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0

$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
$ManualThroughput = Invoke-AzCosmosDBGremlinDatabaseThroughputMigration -ParentObject $CosmosDBAccount -Name $DatabaseName -ThroughputType $Manual
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0

$NewGraph = New-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Throughput $GraphThroughputValue -Name $GraphName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
$GraphThroughput = Get-AzCosmosDBGremlinGraphThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName
Assert-AreEqual $GraphThroughput.Throughput $GraphThroughputValue

$AutoscaledGraphThroughput = Invoke-AzCosmosDBGremlinGraphThroughputMigration -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName -ThroughputType $Autoscale
Assert-AreNotEqual $AutoscaledGraphThroughput.AutoscaleSettings.MaxThroughput 0

$ManualGraphThroughput = Invoke-AzCosmosDBGremlinGraphThroughputMigration -InputObject $NewGraph -ThroughputType $Manual
Assert-AreEqual $ManualGraphThroughput.AutoscaleSettings.MaxThroughput 0

Remove-AzCosmosDBGremlinGraph -InputObject $NewGraph
Remove-AzCosmosDBGremlinDatabase -InputObject $NewDatabase
}
Finally{
Remove-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName
Remove-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@ public void TestMongoThroughputCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-MongoThroughputCmdlets");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestMongoMigrateThroughputCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-MongoMigrateThroughputCmdlets");
}
}
}
51 changes: 51 additions & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/MongoOperationsTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,55 @@ function Validate-EqualLists($list1, $list2)
{
Assert-true($list1 -contains $ele)
}
}

<#
.SYNOPSIS
Test Mongo migrate throughput cmdlets
#>
function Test-MongoMigrateThroughputCmdlets
{

$AccountName = "db001"
$rgName = "CosmosDBResourceGroup3668"
$DatabaseName = "dbName4"
$CollectionName = "collectionName"

$ShardKey = "shardKeyPath"
$ThroughputValue = 1200
$CollectionThroughputValue = 800

$Autoscale = "Autoscale"
$Manual = "Manual"

Try{
$NewDatabase = New-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -Throughput $ThroughputValue
$Throughput = Get-AzCosmosDBMongoDBDatabaseThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
Assert-AreEqual $Throughput.Throughput $ThroughputValue
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0

$AutoscaleThroughput = Invoke-AzCosmosDBMongoDBDatabaseThroughputMigration -InputObject $NewDatabase -ThroughputType $Autoscale
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0

$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
$ManualThroughput = Invoke-AzCosmosDBMongoDBDatabaseThroughputMigration -ParentObject $CosmosDBAccount -Name $DatabaseName -ThroughputType $Manual
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0

$NewCollection = New-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Throughput $CollectionThroughputValue -Name $CollectionName -Shard $ShardKey
$CollectionThroughput = Get-AzCosmosDBMongoDBCollectionThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName
Assert-AreEqual $CollectionThroughput.Throughput $CollectionThroughputValue

$AutoscaledCollectionThroughput = Invoke-AzCosmosDBMongoDBCollectionThroughputMigration -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName -ThroughputType $Autoscale
Assert-AreNotEqual $AutoscaledCollectionThroughput.AutoscaleSettings.MaxThroughput 0

$ManualCollectionThroughput = Invoke-AzCosmosDBMongoDBCollectionThroughputMigration -InputObject $NewCollection -ThroughputType $Manual
Assert-AreEqual $ManualCollectionThroughput.AutoscaleSettings.MaxThroughput 0

Remove-AzCosmosDBMongoDBCollection -InputObject $NewCollection
Remove-AzCosmosDBMongoDBDatabase -InputObject $NewDatabase
}
Finally{
Remove-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName
Remove-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@ public void TestSqlThroughputCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SqlThroughputCmdlets");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSqlMigrateThroughputCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SqlMigrateThroughputCmdlets");
}
}
}
53 changes: 53 additions & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/SqlOperationsTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -569,4 +569,57 @@ function Test-SqlThroughputCmdlets
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName2 -Name $ContainerName2
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName2
}
}

<#
.SYNOPSIS
Test SQL migrate throughput cmdlets
#>
function Test-SqlMigrateThroughputCmdlets
{
$AccountName = "cosmosdb9921232812"
$rgName = "rgtest9921232812"
$DatabaseName = "dbName4"
$ContainerName = "containerName"

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

$ThroughputValue = 1200

$ContainerThroughputValue = 800

$Autoscale = "Autoscale"
$Manual = "Manual"

Try{
$NewDatabase = New-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -Throughput $ThroughputValue
$Throughput = Get-AzCosmosDBSqlDatabaseThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
Assert-AreEqual $Throughput.Throughput $ThroughputValue
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0

$AutoscaleThroughput = Invoke-AzCosmosDBSqlDatabaseThroughputMigration -InputObject $NewDatabase -ThroughputType $Autoscale
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0

$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
$ManualThroughput = Invoke-AzCosmosDBSqlDatabaseThroughputMigration -ParentObject $CosmosDBAccount -Name $DatabaseName -ThroughputType $Manual
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0

$NewContainer = New-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Throughput $ContainerThroughputValue -Name $ContainerName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
$ContainerThroughput = Get-AzCosmosDBSqlContainerThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName
Assert-AreEqual $ContainerThroughput.Throughput $ContainerThroughputValue

$AutoscaledContainerThroughput = Invoke-AzCosmosDBSqlContainerThroughputMigration -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName -ThroughputType $Autoscale
Assert-AreNotEqual $AutoscaledContainerThroughput.AutoscaleSettings.MaxThroughput 0

$ManualContainerThroughput = Invoke-AzCosmosDBSqlContainerThroughputMigration -InputObject $NewContainer -ThroughputType $Manual
Assert-AreEqual $ManualContainerThroughput.AutoscaleSettings.MaxThroughput 0

Remove-AzCosmosDBSqlContainer -InputObject $NewContainer
Remove-AzCosmosDBSqlDatabase -InputObject $NewDatabase
}
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 @@ -47,5 +47,12 @@ public void TestTableThroughputCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-TableThroughputCmdlets");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestTableMigrateThroughputCmdlets()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-TableMigrateThroughputCmdlets");
}
}
}
37 changes: 37 additions & 0 deletions src/CosmosDB/CosmosDB.Test/ScenarioTests/TableOperationsTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,41 @@ function Test-TableThroughputCmdlets
Finally{
Remove-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName
}
}

<#
.SYNOPSIS
Test Cassandra migrate throughput cmdlets
#>
function Test-TableMigrateThroughputCmdlets
{

$AccountName = "db2527"
$rgName = "CosmosDBResourceGroup2510"
$TableName = "tableName4"

$ThroughputValue = 1200
$TableThroughputValue = 800

$Autoscale = "Autoscale"
$Manual = "Manual"

Try{
$NewTable = New-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName -Throughput $ThroughputValue
$Throughput = Get-AzCosmosDBTableThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName
Assert-AreEqual $Throughput.Throughput $ThroughputValue
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0

$AutoscaleThroughput = Invoke-AzCosmosDBTableThroughputMigration -InputObject $NewTable -ThroughputType $Autoscale
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0

$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
$ManualThroughput = Invoke-AzCosmosDBTableThroughputMigration -ParentObject $CosmosDBAccount -Name $TableName -ThroughputType $Manual
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0

Remove-AzCosmosDBTable -InputObject $NewTable
}
Finally{
Remove-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName
}
}
Loading