@@ -1257,7 +1257,7 @@ function Test-SqlMaterializedViewCmdlets
1257
1257
1258
1258
Try {
1259
1259
$resourceGroup = New-AzResourceGroup - ResourceGroupName $rgName - Location $location
1260
- $cosmosDBAccount = New-AzCosmosDBAccount - ResourceGroupName $rgName - LocationObject $locations - Name $AccountName - ApiKind $apiKind - DefaultConsistencyLevel $consistencyLevel - EnableMaterializedViews 1
1260
+ $cosmosDBAccount = New-AzCosmosDBAccount - ResourceGroupName $rgName - LocationObject $locations - Name $AccountName - ApiKind $apiKind - DefaultConsistencyLevel $consistencyLevel - EnableMaterializedViews 1 - BackupPolicyType Continuous
1261
1261
1262
1262
$NewDatabase = New-AzCosmosDBSqlDatabase - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName - Throughput $ThroughputValue
1263
1263
$Throughput = Get-AzCosmosDBSqlDatabaseThroughput - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName
@@ -2063,4 +2063,114 @@ function Test-SqlDatabaseMergeCmdlet
2063
2063
Remove-AzCosmosDBSqlContainer - AccountName $AccountName - ResourceGroupName $rgName - DatabaseName $DatabaseName - Name $ContainerName
2064
2064
Remove-AzCosmosDBSqlDatabase - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName
2065
2065
}
2066
- }
2066
+ }
2067
+
2068
+ # This test requires subscription 074d02eb-4d74-486a-b299-b262264d1536 to run
2069
+ <#
2070
+ . SYNOPSIS
2071
+ Tests SQL throughput buckets cmdlets
2072
+ #>
2073
+ function Test-SqlThroughputBucketsCmdlets
2074
+ {
2075
+ $AccountName = " throughput-bucketing-rp-test"
2076
+ $rgName = " throughput-bucketing-rg"
2077
+ $DatabaseName = " dbName3"
2078
+ $ContainerName = " containerName"
2079
+
2080
+ $PartitionKeyPathValue = " /foo/bar"
2081
+ $PartitionKeyKindValue = " Hash"
2082
+
2083
+ $ThroughputValue = 1200
2084
+ $UpdatedThroughputValue = 1100
2085
+ $UpdatedThroughputValue2 = 1000
2086
+ $UpdatedThroughputValue3 = 900
2087
+
2088
+ $ContainerThroughputValue = 800
2089
+ $UpdatedContainerThroughputValue = 700
2090
+ $UpdatedContainerThroughputValue2 = 600
2091
+ $UpdatedContainerThroughputValue3 = 500
2092
+
2093
+ $DatabaseName2 = " dbName4"
2094
+ $ContainerName2 = " containerName3"
2095
+ $AutoscaleContainerThroughput = 5000
2096
+ $AutoscaleUpdatedContainerThroughput = 10000
2097
+ $AutoscaleDatabaseThroughput = 8000
2098
+ $AutoscaleUpdatedDatabaseThroughput = 12000
2099
+ $location = " East US"
2100
+ $apiKind = " Sql"
2101
+ $consistencyLevel = " BoundedStaleness"
2102
+ $locations = @ ()
2103
+ $locations += New-AzCosmosDBLocationObject - LocationName " East Us" - FailoverPriority 0 - IsZoneRedundant 0
2104
+
2105
+ $ThroughputBucket1 = New-AzCosmosDBThroughputBucketObject - Id 1 - MaxThroughputPercentage 20
2106
+ $ThroughputBucket2 = New-AzCosmosDBThroughputBucketObject - Id 2 - MaxThroughputPercentage 30
2107
+
2108
+ Try {
2109
+ $NewDatabase = New-AzCosmosDBSqlDatabase - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName - Throughput $ThroughputValue
2110
+ $Throughput = Get-AzCosmosDBSqlDatabaseThroughput - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName
2111
+ Assert-AreEqual $Throughput.Throughput $ThroughputValue
2112
+
2113
+ $UpdatedThroughput = Update-AzCosmosDBSqlDatabaseThroughput - InputObject $NewDatabase - Throughput $UpdatedThroughputValue
2114
+ Assert-AreEqual $UpdatedThroughput.Throughput $UpdatedThroughputValue
2115
+
2116
+ $UpdatedThroughput = Update-AzCosmosDBSqlDatabaseThroughput - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName - Throughput $UpdatedThroughputValue2
2117
+ Assert-AreEqual $UpdatedThroughput.Throughput $UpdatedThroughputValue2
2118
+
2119
+ $CosmosDBAccount = Get-AzCosmosDBAccount - ResourceGroupName $rgName - Name $AccountName
2120
+ $UpdatedThroughput = Update-AzCosmosDBSqlDatabaseThroughput - ParentObject $CosmosDBAccount - Name $DatabaseName - Throughput $UpdatedThroughputValue3
2121
+ Assert-AreEqual $UpdatedThroughput.Throughput $UpdatedThroughputValue3
2122
+
2123
+ $NewContainer = New-AzCosmosDBSqlContainer - AccountName $AccountName - ResourceGroupName $rgName - DatabaseName $DatabaseName - Throughput $ContainerThroughputValue - Name $ContainerName - PartitionKeyPath $PartitionKeyPathValue - PartitionKeyKind $PartitionKeyKindValue
2124
+ $ContainerThroughput = Get-AzCosmosDBSqlContainerThroughput - AccountName $AccountName - ResourceGroupName $rgName - DatabaseName $DatabaseName - Name $ContainerName
2125
+ Assert-AreEqual $ContainerThroughput.Throughput $ContainerThroughputValue
2126
+
2127
+ $UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput - AccountName $AccountName - ResourceGroupName $rgName - DatabaseName $DatabaseName - Name $ContainerName - Throughput $UpdatedContainerThroughputValue
2128
+ Assert-AreEqual $UpdatedContainerThroughput.Throughput $UpdatedContainerThroughputValue
2129
+
2130
+ $UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput - InputObject $NewContainer - Throughput $UpdatedContainerThroughputValue2
2131
+ Assert-AreEqual $UpdatedContainerThroughput.Throughput $UpdatedContainerThroughputValue2
2132
+
2133
+ $UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput - ParentObject $NewDatabase - Name $ContainerName - Throughput $UpdatedContainerThroughputValue3
2134
+ Assert-AreEqual $UpdatedContainerThroughput.Throughput $UpdatedContainerThroughputValue3
2135
+
2136
+ # Throughput bucketing scenario
2137
+ $UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput - ResourceGroupName $rgName - AccountName $AccountName - DatabaseName $DatabaseName - Name $ContainerName - Throughput $ContainerThroughputValue - ThroughputBucketsObject @ ($ThroughputBucket1 , $ThroughputBucket2 )
2138
+ Assert-AreEqual $UpdatedContainerThroughput.Throughput $ContainerThroughputValue
2139
+ Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject.Count 2
2140
+ Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject [0 ].Id 1
2141
+ Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject [0 ].MaxThroughputPercentage 20
2142
+ Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject [1 ].Id 2
2143
+ Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject [1 ].MaxThroughputPercentage 30
2144
+
2145
+ $UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput - ResourceGroupName $rgName - AccountName $AccountName - DatabaseName $DatabaseName - Name $ContainerName - Throughput $ContainerThroughputValue - ThroughputBucketsObject @ ()
2146
+ Assert-AreEqual $UpdatedContainerThroughput.Throughput $ContainerThroughputValue
2147
+ Assert-AreEqual $UpdatedContainerThroughput.ThroughputBucketsObject.Count 0
2148
+
2149
+ # autoscale scenarios
2150
+ $AutoscaleDatabase = New-AzCosmosDBSqlDatabase - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName2 - AutoscaleMaxThroughput $AutoscaleDatabaseThroughput
2151
+ $Throughput = Get-AzCosmosDBSqlDatabaseThroughput - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName2
2152
+ Assert-AreEqual $Throughput.AutoscaleSettings.MaxThroughput $AutoscaleDatabaseThroughput
2153
+
2154
+ $AutoscaleContainer = New-AzCosmosDBSqlContainer - AccountName $AccountName - ResourceGroupName $rgName - DatabaseName $DatabaseName2 - AutoscaleMaxThroughput $AutoscaleContainerThroughput - Name $ContainerName2 - PartitionKeyPath $PartitionKeyPathValue - PartitionKeyKind $PartitionKeyKindValue
2155
+ $ContainerThroughput = Get-AzCosmosDBSqlContainerThroughput - InputObject $AutoscaleContainer
2156
+ Assert-AreEqual $ContainerThroughput.AutoscaleSettings.MaxThroughput $AutoscaleContainerThroughput
2157
+
2158
+ $UpdatedContainerThroughput = Update-AzCosmosDBSqlContainerThroughput - AccountName $AccountName - ResourceGroupName $rgName - DatabaseName $DatabaseName2 - Name $ContainerName2 - AutoscaleMaxThroughput $AutoscaleUpdatedContainerThroughput
2159
+ Assert-AreEqual $UpdatedContainerThroughput.AutoscaleSettings.MaxThroughput $AutoscaleUpdatedContainerThroughput
2160
+
2161
+ # can only update throughput of database if it has atleast one container with shared throughput
2162
+ # $UpdatedThroughput = Update-AzCosmosDBSqlDatabaseThroughput -InputObject $AutoscaleDatabase -AutoscaleMaxThroughput $AutoscaleUpdatedDatabaseThroughput
2163
+ # Assert-AreEqual $UpdatedThroughput.AutoscaleSettings.MaxThroughput $AutoscaleUpdatedDatabaseThroughput
2164
+
2165
+ Remove-AzCosmosDBSqlContainer - InputObject $NewContainer
2166
+ Remove-AzCosmosDBSqlDatabase - InputObject $NewDatabase
2167
+ Remove-AzCosmosDBSqlContainer - InputObject $AutoscaleContainer
2168
+ Remove-AzCosmosDBSqlDatabase - InputObject $AutoscaleDatabase
2169
+ }
2170
+ Finally {
2171
+ Remove-AzCosmosDBSqlContainer - AccountName $AccountName - ResourceGroupName $rgName - DatabaseName $DatabaseName - Name $ContainerName
2172
+ Remove-AzCosmosDBSqlDatabase - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName
2173
+ Remove-AzCosmosDBSqlContainer - AccountName $AccountName - ResourceGroupName $rgName - DatabaseName $DatabaseName2 - Name $ContainerName2
2174
+ Remove-AzCosmosDBSqlDatabase - AccountName $AccountName - ResourceGroupName $rgName - Name $DatabaseName2
2175
+ }
2176
+ }
0 commit comments