1+ # ----------------------------------------------------------------------------------
2+ #
3+ # Copyright Microsoft Corporation
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ # Unless required by applicable law or agreed to in writing, software
9+ # distributed under the License is distributed on an "AS IS" BASIS,
10+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+ # See the License for the specific language governing permissions and
12+ # limitations under the License.
13+ # ----------------------------------------------------------------------------------
14+
15+ <#
16+ . SYNOPSIS
17+ Test pasuing and resuming database.
18+ #>
19+ function Test-DatabasePauseResume
20+ {
21+ # Setup
22+ $location = " Southeast Asia"
23+ $serverVersion = " 12.0" ;
24+ $rg = Create- ResourceGroupForTest
25+ $server = Create- ServerForTest $rg $serverVersion $location
26+
27+ # Create data warehouse database with all parameters.
28+ $databaseName = Get-DatabaseName
29+ $collationName = " SQL_Latin1_General_CP1_CI_AS"
30+ $maxSizeBytes = 250 GB
31+ $dwdb = New-AzureSqlDatabase - ResourceGroupName $rg.ResourceGroupName - ServerName $server.ServerName - DatabaseName $databaseName `
32+ - CollationName $collationName - MaxSizeBytes $maxSizeBytes - Edition DataWarehouse - RequestedServiceObjectiveName DW100
33+
34+ try
35+ {
36+ # Pause the database. Make sure the database specs remain the same and its Status is Paused.
37+ $dwdb2 = Suspend-AzureSqlDatabase - ResourceGroupName $rg.ResourceGroupName - ServerName $server.ServerName - DatabaseName $dwdb.DatabaseName
38+ Assert-AreEqual $dwdb2.DatabaseName $databaseName
39+ Assert-AreEqual $dwdb2.MaxSizeBytes $maxSizeBytes
40+ Assert-AreEqual $dwdb2.Edition DataWarehouse
41+ Assert-AreEqual $dwdb2.CurrentServiceObjectiveName DW100
42+ Assert-AreEqual $dwdb2.CollationName $collationName
43+ Assert-AreEqual $dwdb2.Status " Paused"
44+
45+ # Resume the database. Make sure the database specs remain the same and its Status is Online.
46+ $dwdb3 = Resume-AzureSqlDatabase - ResourceGroupName $rg.ResourceGroupName - ServerName $server.ServerName - DatabaseName $dwdb.DatabaseName
47+ Assert-AreEqual $dwdb3.DatabaseName $databaseName
48+ Assert-AreEqual $dwdb3.MaxSizeBytes $maxSizeBytes
49+ Assert-AreEqual $dwdb3.Edition DataWarehouse
50+ Assert-AreEqual $dwdb3.CurrentServiceObjectiveName DW100
51+ Assert-AreEqual $dwdb3.CollationName $collationName
52+ Assert-AreEqual $dwdb3.Status " Online"
53+ }
54+ finally
55+ {
56+ Remove-ResourceGroupForTest $rg
57+ }
58+ }
59+
60+ <#
61+ . SYNOPSIS
62+ Test pasuing and resuming database via piped cmdlets.
63+ #>
64+ function Test-DatabasePauseResumePiped
65+ {
66+ # Setup
67+ $location = " Japan East"
68+ $serverVersion = " 12.0" ;
69+ $rg = Create- ResourceGroupForTest
70+
71+ try
72+ {
73+ $server = Create- ServerForTest $rg $serverVersion $location
74+
75+ # Create data warehouse database with all parameters.
76+ $databaseName = Get-DatabaseName
77+ $collationName = " SQL_Latin1_General_CP1_CI_AS"
78+ $maxSizeBytes = 250 GB
79+ $dwdb = New-AzureSqlDatabase - ResourceGroupName $rg.ResourceGroupName - ServerName $server.ServerName - DatabaseName $databaseName `
80+ - CollationName $collationName - MaxSizeBytes $maxSizeBytes - Edition DataWarehouse - RequestedServiceObjectiveName DW100
81+
82+
83+ # Pause the database. Make sure the database specs remain the same and its Status is Paused.
84+ $dwdb2 = $dwdb | Suspend-AzureSqlDatabase
85+ Assert-AreEqual $dwdb2.DatabaseName $databaseName
86+ Assert-AreEqual $dwdb2.MaxSizeBytes $maxSizeBytes
87+ Assert-AreEqual $dwdb2.Edition DataWarehouse
88+ Assert-AreEqual $dwdb2.CurrentServiceObjectiveName DW100
89+ Assert-AreEqual $dwdb2.CollationName $collationName
90+ Assert-AreEqual $dwdb2.Status " Paused"
91+
92+ # Resume the database. Make sure the database specs remain the same and its Status is Online.
93+ $dwdb3 = $dwdb2 | Resume-AzureSqlDatabase
94+ Assert-AreEqual $dwdb3.DatabaseName $databaseName
95+ Assert-AreEqual $dwdb3.MaxSizeBytes $maxSizeBytes
96+ Assert-AreEqual $dwdb3.Edition DataWarehouse
97+ Assert-AreEqual $dwdb3.CurrentServiceObjectiveName DW100
98+ Assert-AreEqual $dwdb3.CollationName $collationName
99+ Assert-AreEqual $dwdb3.Status " Online"
100+ }
101+ finally
102+ {
103+ Remove-ResourceGroupForTest $rg
104+ }
105+ }
0 commit comments