Skip to content

Commit 1b55546

Browse files
MehaKaushikMeha Kaushik
andauthored
[CosmosDB] Migration support for throughput (#12814)
* Migration support for throughput + sql tests * updating tests * Renamed cmdlets + help * updated session records * updating ChangeLog Co-authored-by: Meha Kaushik <[email protected]>
1 parent 1a2b64f commit 1b55546

File tree

59 files changed

+13386
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+13386
-141
lines changed

src/CosmosDB/CosmosDB.Test/CosmosDB.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</PropertyGroup>
55
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
66
<ItemGroup>
7-
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.2.0" />
7+
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="1.2.1" />
88
<PackageReference Include="Microsoft.Azure.Management.Network" Version="20.0.2-preview" />
99
</ItemGroup>
1010
</Project>

src/CosmosDB/CosmosDB.Test/ScenarioTests/CassandraOperationsTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,12 @@ public void TestCassandraCreateUpdateGetCmdlets()
4747
{
4848
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CassandraCreateUpdateGetCmdlets");
4949
}
50+
51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestCassandraMigrateThroughputCmdlets()
54+
{
55+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CassandraMigrateThroughputCmdlets");
56+
}
5057
}
5158
}

src/CosmosDB/CosmosDB.Test/ScenarioTests/CassandraOperationsTests.ps1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,61 @@ function Test-CassandraThroughputCmdlets
292292
}
293293
}
294294

295+
<#
296+
.SYNOPSIS
297+
Test Cassandra migrate throughput cmdlets
298+
#>
299+
function Test-CassandraMigrateThroughputCmdlets
300+
{
301+
302+
$AccountName = "db2725"
303+
$rgName = "CosmosDBResourceGroup2510"
304+
$KeyspaceName = "KeyspaceName3"
305+
$TableName = "tableName"
306+
307+
$ThroughputValue = 1200
308+
$TableThroughputValue = 800
309+
310+
$Autoscale = "Autoscale"
311+
$Manual = "Manual"
312+
313+
Try{
314+
$Column1 = New-AzCosmosDBCassandraColumn -Name "ColumnA" -Type "int"
315+
$Column2 = New-AzCosmosDBCassandraColumn -Name "ColumnB" -Type "ascii"
316+
$clusterkey1 = New-AzCosmosDBCassandraClusterKey -Name "ColumnB" -OrderBy "Asc"
317+
$schema = New-AzCosmosDBCassandraSchema -Column $Column1,$Column2 -ClusterKey $clusterkey1 -PartitionKey "ColumnA"
318+
319+
$NewKeyspace = New-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName -Throughput $ThroughputValue
320+
$Throughput = Get-AzCosmosDBCassandraKeyspaceThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName
321+
Assert-AreEqual $Throughput.Throughput $ThroughputValue
322+
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0
323+
324+
$AutoscaleThroughput = Invoke-AzCosmosDBCassandraKeyspaceThroughputMigration -InputObject $NewKeyspace -ThroughputType $Autoscale
325+
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0
326+
327+
$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
328+
$ManualThroughput = Invoke-AzCosmosDBCassandraKeyspaceThroughputMigration -ParentObject $CosmosDBAccount -Name $KeyspaceName -ThroughputType $Manual
329+
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0
330+
331+
$NewTable = New-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName -Schema $schema -Throughput $TableThroughputValue
332+
$TableThroughput = Get-AzCosmosDBCassandraTableThroughput -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName
333+
Assert-AreEqual $TableThroughput.Throughput $TableThroughputValue
334+
335+
$AutoscaledTableThroughput = Invoke-AzCosmosDBCassandraTableThroughputMigration -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName -ThroughputType $Autoscale
336+
Assert-AreNotEqual $AutoscaledTableThroughput.AutoscaleSettings.MaxThroughput 0
337+
338+
$ManuaTableThroughput = Invoke-AzCosmosDBCassandraTableThroughputMigration -InputObject $NewTable -ThroughputType $Manual
339+
Assert-AreEqual $ManuaTableThroughput.AutoscaleSettings.MaxThroughput 0
340+
341+
Remove-AzCosmosDBCassandraTable -InputObject $NewTable
342+
Remove-AzCosmosDBCassandraKeyspace -InputObject $NewKeyspace
343+
}
344+
Finally{
345+
Remove-AzCosmosDBCassandraTable -AccountName $AccountName -ResourceGroupName $rgName -KeyspaceName $KeyspaceName -Name $TableName
346+
Remove-AzCosmosDBCassandraKeyspace -AccountName $AccountName -ResourceGroupName $rgName -Name $KeyspaceName
347+
}
348+
}
349+
295350
function Validate-EqualColumns($Column1, $Column2)
296351
{
297352
Assert-AreEqual $Column1.Name $Column2.Name

src/CosmosDB/CosmosDB.Test/ScenarioTests/GremlinOperationsTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,12 @@ public void TestGremlinThroughputCmdlets()
4747
{
4848
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GremlinThroughputCmdlets");
4949
}
50+
51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestGremlinMigrateThroughputCmdlets()
54+
{
55+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GremlinMigrateThroughputCmdlets");
56+
}
5057
}
5158
}

src/CosmosDB/CosmosDB.Test/ScenarioTests/GremlinOperationsTests.ps1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,57 @@ function Test-GremlinThroughputCmdlets
305305
Remove-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName
306306
Remove-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
307307
}
308+
}
309+
310+
<#
311+
.SYNOPSIS
312+
Test Gremlin migrate throughput cmdlets
313+
#>
314+
function Test-GremlinMigrateThroughputCmdlets
315+
{
316+
$AccountName = "db1002"
317+
$rgName = "CosmosDBResourceGroup2510"
318+
$DatabaseName = "dbName4"
319+
$GraphName = "graphName"
320+
321+
$PartitionKeyPathValue = "/foo"
322+
$PartitionKeyKindValue = "Hash"
323+
324+
$ThroughputValue = 1200
325+
326+
$GraphThroughputValue = 800
327+
328+
$Autoscale = "Autoscale"
329+
$Manual = "Manual"
330+
331+
Try{
332+
$NewDatabase = New-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -Throughput $ThroughputValue
333+
$Throughput = Get-AzCosmosDBGremlinDatabaseThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
334+
Assert-AreEqual $Throughput.Throughput $ThroughputValue
335+
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0
336+
337+
$AutoscaleThroughput = Invoke-AzCosmosDBGremlinDatabaseThroughputMigration -InputObject $NewDatabase -ThroughputType $Autoscale
338+
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0
339+
340+
$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
341+
$ManualThroughput = Invoke-AzCosmosDBGremlinDatabaseThroughputMigration -ParentObject $CosmosDBAccount -Name $DatabaseName -ThroughputType $Manual
342+
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0
343+
344+
$NewGraph = New-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Throughput $GraphThroughputValue -Name $GraphName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
345+
$GraphThroughput = Get-AzCosmosDBGremlinGraphThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName
346+
Assert-AreEqual $GraphThroughput.Throughput $GraphThroughputValue
347+
348+
$AutoscaledGraphThroughput = Invoke-AzCosmosDBGremlinGraphThroughputMigration -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName -ThroughputType $Autoscale
349+
Assert-AreNotEqual $AutoscaledGraphThroughput.AutoscaleSettings.MaxThroughput 0
350+
351+
$ManualGraphThroughput = Invoke-AzCosmosDBGremlinGraphThroughputMigration -InputObject $NewGraph -ThroughputType $Manual
352+
Assert-AreEqual $ManualGraphThroughput.AutoscaleSettings.MaxThroughput 0
353+
354+
Remove-AzCosmosDBGremlinGraph -InputObject $NewGraph
355+
Remove-AzCosmosDBGremlinDatabase -InputObject $NewDatabase
356+
}
357+
Finally{
358+
Remove-AzCosmosDBGremlinGraph -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $GraphName
359+
Remove-AzCosmosDBGremlinDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
360+
}
308361
}

src/CosmosDB/CosmosDB.Test/ScenarioTests/MongoOperationsTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,12 @@ public void TestMongoThroughputCmdlets()
4747
{
4848
TestController.NewInstance.RunPowerShellTest(_logger, "Test-MongoThroughputCmdlets");
4949
}
50+
51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestMongoMigrateThroughputCmdlets()
54+
{
55+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-MongoMigrateThroughputCmdlets");
56+
}
5057
}
5158
}

src/CosmosDB/CosmosDB.Test/ScenarioTests/MongoOperationsTests.ps1

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,55 @@ function Validate-EqualLists($list1, $list2)
358358
{
359359
Assert-true($list1 -contains $ele)
360360
}
361+
}
362+
363+
<#
364+
.SYNOPSIS
365+
Test Mongo migrate throughput cmdlets
366+
#>
367+
function Test-MongoMigrateThroughputCmdlets
368+
{
369+
370+
$AccountName = "db001"
371+
$rgName = "CosmosDBResourceGroup3668"
372+
$DatabaseName = "dbName4"
373+
$CollectionName = "collectionName"
374+
375+
$ShardKey = "shardKeyPath"
376+
$ThroughputValue = 1200
377+
$CollectionThroughputValue = 800
378+
379+
$Autoscale = "Autoscale"
380+
$Manual = "Manual"
381+
382+
Try{
383+
$NewDatabase = New-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -Throughput $ThroughputValue
384+
$Throughput = Get-AzCosmosDBMongoDBDatabaseThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
385+
Assert-AreEqual $Throughput.Throughput $ThroughputValue
386+
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0
387+
388+
$AutoscaleThroughput = Invoke-AzCosmosDBMongoDBDatabaseThroughputMigration -InputObject $NewDatabase -ThroughputType $Autoscale
389+
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0
390+
391+
$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
392+
$ManualThroughput = Invoke-AzCosmosDBMongoDBDatabaseThroughputMigration -ParentObject $CosmosDBAccount -Name $DatabaseName -ThroughputType $Manual
393+
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0
394+
395+
$NewCollection = New-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Throughput $CollectionThroughputValue -Name $CollectionName -Shard $ShardKey
396+
$CollectionThroughput = Get-AzCosmosDBMongoDBCollectionThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName
397+
Assert-AreEqual $CollectionThroughput.Throughput $CollectionThroughputValue
398+
399+
$AutoscaledCollectionThroughput = Invoke-AzCosmosDBMongoDBCollectionThroughputMigration -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName -ThroughputType $Autoscale
400+
Assert-AreNotEqual $AutoscaledCollectionThroughput.AutoscaleSettings.MaxThroughput 0
401+
402+
$ManualCollectionThroughput = Invoke-AzCosmosDBMongoDBCollectionThroughputMigration -InputObject $NewCollection -ThroughputType $Manual
403+
Assert-AreEqual $ManualCollectionThroughput.AutoscaleSettings.MaxThroughput 0
404+
405+
Remove-AzCosmosDBMongoDBCollection -InputObject $NewCollection
406+
Remove-AzCosmosDBMongoDBDatabase -InputObject $NewDatabase
407+
}
408+
Finally{
409+
Remove-AzCosmosDBMongoDBCollection -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $CollectionName
410+
Remove-AzCosmosDBMongoDBDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
411+
}
361412
}

src/CosmosDB/CosmosDB.Test/ScenarioTests/SqlOperationsTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,12 @@ public void TestSqlThroughputCmdlets()
4747
{
4848
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SqlThroughputCmdlets");
4949
}
50+
51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestSqlMigrateThroughputCmdlets()
54+
{
55+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SqlMigrateThroughputCmdlets");
56+
}
5057
}
5158
}

src/CosmosDB/CosmosDB.Test/ScenarioTests/SqlOperationsTests.ps1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,4 +569,57 @@ function Test-SqlThroughputCmdlets
569569
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName2 -Name $ContainerName2
570570
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName2
571571
}
572+
}
573+
574+
<#
575+
.SYNOPSIS
576+
Test SQL migrate throughput cmdlets
577+
#>
578+
function Test-SqlMigrateThroughputCmdlets
579+
{
580+
$AccountName = "cosmosdb9921232812"
581+
$rgName = "rgtest9921232812"
582+
$DatabaseName = "dbName4"
583+
$ContainerName = "containerName"
584+
585+
$PartitionKeyPathValue = "/foo/bar"
586+
$PartitionKeyKindValue = "Hash"
587+
588+
$ThroughputValue = 1200
589+
590+
$ContainerThroughputValue = 800
591+
592+
$Autoscale = "Autoscale"
593+
$Manual = "Manual"
594+
595+
Try{
596+
$NewDatabase = New-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName -Throughput $ThroughputValue
597+
$Throughput = Get-AzCosmosDBSqlDatabaseThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
598+
Assert-AreEqual $Throughput.Throughput $ThroughputValue
599+
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0
600+
601+
$AutoscaleThroughput = Invoke-AzCosmosDBSqlDatabaseThroughputMigration -InputObject $NewDatabase -ThroughputType $Autoscale
602+
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0
603+
604+
$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
605+
$ManualThroughput = Invoke-AzCosmosDBSqlDatabaseThroughputMigration -ParentObject $CosmosDBAccount -Name $DatabaseName -ThroughputType $Manual
606+
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0
607+
608+
$NewContainer = New-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Throughput $ContainerThroughputValue -Name $ContainerName -PartitionKeyPath $PartitionKeyPathValue -PartitionKeyKind $PartitionKeyKindValue
609+
$ContainerThroughput = Get-AzCosmosDBSqlContainerThroughput -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName
610+
Assert-AreEqual $ContainerThroughput.Throughput $ContainerThroughputValue
611+
612+
$AutoscaledContainerThroughput = Invoke-AzCosmosDBSqlContainerThroughputMigration -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName -ThroughputType $Autoscale
613+
Assert-AreNotEqual $AutoscaledContainerThroughput.AutoscaleSettings.MaxThroughput 0
614+
615+
$ManualContainerThroughput = Invoke-AzCosmosDBSqlContainerThroughputMigration -InputObject $NewContainer -ThroughputType $Manual
616+
Assert-AreEqual $ManualContainerThroughput.AutoscaleSettings.MaxThroughput 0
617+
618+
Remove-AzCosmosDBSqlContainer -InputObject $NewContainer
619+
Remove-AzCosmosDBSqlDatabase -InputObject $NewDatabase
620+
}
621+
Finally{
622+
Remove-AzCosmosDBSqlContainer -AccountName $AccountName -ResourceGroupName $rgName -DatabaseName $DatabaseName -Name $ContainerName
623+
Remove-AzCosmosDBSqlDatabase -AccountName $AccountName -ResourceGroupName $rgName -Name $DatabaseName
624+
}
572625
}

src/CosmosDB/CosmosDB.Test/ScenarioTests/TableOperationsTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,12 @@ public void TestTableThroughputCmdlets()
4747
{
4848
TestController.NewInstance.RunPowerShellTest(_logger, "Test-TableThroughputCmdlets");
4949
}
50+
51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestTableMigrateThroughputCmdlets()
54+
{
55+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-TableMigrateThroughputCmdlets");
56+
}
5057
}
5158
}

src/CosmosDB/CosmosDB.Test/ScenarioTests/TableOperationsTests.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,41 @@ function Test-TableThroughputCmdlets
161161
Finally{
162162
Remove-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName
163163
}
164+
}
165+
166+
<#
167+
.SYNOPSIS
168+
Test Cassandra migrate throughput cmdlets
169+
#>
170+
function Test-TableMigrateThroughputCmdlets
171+
{
172+
173+
$AccountName = "db2527"
174+
$rgName = "CosmosDBResourceGroup2510"
175+
$TableName = "tableName4"
176+
177+
$ThroughputValue = 1200
178+
$TableThroughputValue = 800
179+
180+
$Autoscale = "Autoscale"
181+
$Manual = "Manual"
182+
183+
Try{
184+
$NewTable = New-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName -Throughput $ThroughputValue
185+
$Throughput = Get-AzCosmosDBTableThroughput -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName
186+
Assert-AreEqual $Throughput.Throughput $ThroughputValue
187+
Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput 0
188+
189+
$AutoscaleThroughput = Invoke-AzCosmosDBTableThroughputMigration -InputObject $NewTable -ThroughputType $Autoscale
190+
Assert-AreNotEqual $AutoscaleThroughput.AutoscaleSettings.MaxThroughput 0
191+
192+
$CosmosDBAccount = Get-AzCosmosDBAccount -ResourceGroupName $rgName -Name $AccountName #get parent object
193+
$ManualThroughput = Invoke-AzCosmosDBTableThroughputMigration -ParentObject $CosmosDBAccount -Name $TableName -ThroughputType $Manual
194+
Assert-AreEqual $ManualThroughput.AutoscaleSettings.MaxThroughput 0
195+
196+
Remove-AzCosmosDBTable -InputObject $NewTable
197+
}
198+
Finally{
199+
Remove-AzCosmosDBTable -AccountName $AccountName -ResourceGroupName $rgName -Name $TableName
200+
}
164201
}

0 commit comments

Comments
 (0)