Skip to content

Commit e3baf35

Browse files
committed
Adding support for migration through power shell commands.
1 parent 2afe8b3 commit e3baf35

File tree

32 files changed

+1654
-5194
lines changed

32 files changed

+1654
-5194
lines changed

src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@
155155
<Compile Include="ScenarioTests\DatabaseBackupTests.cs" />
156156
<Compile Include="ScenarioTests\DatabaseCrudTests.cs" />
157157
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
158+
<None Include="ScenarioTests\ServiceTierAdvisorTests.ps1">
159+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
160+
</None>
158161
<None Include="ScenarioTests\DatabaseActivationTests.ps1">
159162
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
160163
</None>
@@ -167,6 +170,7 @@
167170
<None Include="ScenarioTests\ElasticPoolCrudTests.ps1">
168171
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
169172
</None>
173+
<Compile Include="ScenarioTests\ServiceTierAdvisorTests.cs" />
170174
<Compile Include="ScenarioTests\RecommendedElasticPoolTests.cs" />
171175
<Compile Include="ScenarioTests\ElasticPoolCrudTests.cs" />
172176
<Compile Include="ScenarioTests\SecurityTests.cs" />
@@ -181,6 +185,7 @@
181185
<Compile Include="UnitTests\AzureSqlDatabaseServerFirewallRuleAttributeTests.cs" />
182186
<Compile Include="UnitTests\AzureSqlDatabaseServerAttributeTests.cs" />
183187
<Compile Include="UnitTests\AzureSqlServerUpgradeAttributeTests.cs" />
188+
<Compile Include="UnitTests\AzureSqlServiceTierAdvisorAttributeTests.cs" />
184189
<Compile Include="UnitTests\AzureSqlDatabaseBackupAttributeTests.cs" />
185190
<Compile Include="Utilities\UnitTestHelper.cs" />
186191
</ItemGroup>
@@ -377,25 +382,25 @@
377382
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolUpdate.json">
378383
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
379384
</None>
380-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.RecommendedElasticPoolTests\TestRecommendedElasticPoolGet.json">
385+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.RecommendedElasticPoolTests\ListRecommendedElasticPools.json">
381386
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
382387
</None>
383-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.RecommendedElasticPoolTests\TestRecommendedElasticPoolGetDatabase.json">
388+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerCreate.json">
384389
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
385390
</None>
386-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.RecommendedElasticPoolTests\TestRecommendedElasticPoolGetMetrics.json">
391+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerGet.json">
387392
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
388393
</None>
389-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.RecommendedElasticPoolTests\TestRecommendedElasticPoolList.json">
394+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerRemove.json">
390395
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
391396
</None>
392-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.RecommendedElasticPoolTests\TestRecommendedElasticPoolListDatabase.json">
397+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerUpdate.json">
393398
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
394399
</None>
395-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerCreate.json">
400+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServiceTierAdvisorTests\GetUpgradeDatabaseHint.json">
396401
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
397402
</None>
398-
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerGet.json">
403+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServiceTierAdvisorTests\GetUpgradeServerHint.json">
399404
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
400405
</None>
401406
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerRemove.json">

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/RecommendedElasticPoolTests.cs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,11 @@ namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
2020
{
2121
public class RecommendedElasticPoolTests : SqlTestsBase
2222
{
23-
[Fact(Skip="Test needs to be regenerated. Will be done by recommendations team.")]
24-
[Trait(Category.Sql, Category.CheckIn)]
25-
public void TestRecommendedElasticPoolList()
26-
{
27-
RunPowerShellTest("Test-ListRecommendedElasticPools");
28-
}
29-
30-
[Fact]
31-
[Trait(Category.Sql, Category.CheckIn)]
32-
public void TestRecommendedElasticPoolGet()
33-
{
34-
RunPowerShellTest("Test-GetRecommendedElasticPool");
35-
}
36-
37-
[Fact]
38-
[Trait(Category.Sql, Category.CheckIn)]
39-
public void TestRecommendedElasticPoolListDatabase()
40-
{
41-
RunPowerShellTest("Test-ListRecommendedElasticPoolDatabases");
42-
}
43-
44-
[Fact]
45-
[Trait(Category.Sql, Category.CheckIn)]
46-
public void TestRecommendedElasticPoolGetDatabase()
47-
{
48-
RunPowerShellTest("Test-GetRecommendedElasticPoolDatabase");
49-
}
50-
5123
[Fact]
5224
[Trait(Category.Sql, Category.CheckIn)]
53-
public void TestRecommendedElasticPoolGetMetrics()
25+
public void ListRecommendedElasticPools()
5426
{
55-
RunPowerShellTest("Test-GetRecommendedElasticPoolMetrics");
27+
RunPowerShellTest("Test-ElasticPoolRecommendation");
5628
}
5729
}
5830
}

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/RecommendedElasticPoolTests.ps1

Lines changed: 13 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -16,140 +16,18 @@
1616
.SYNOPSIS
1717
Tests listing all recommended elastic pools for server
1818
#>
19-
function Test-ListRecommendedElasticPools
19+
function Test-ElasticPoolRecommendation
2020
{
21-
# Setup
22-
$rg = Create-ResourceGroupForTest
23-
$server = Create-ServerForTest $rg "Japan East"
24-
25-
try
26-
{
27-
$response = Get-AzureSqlElasticPoolRecommendation -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName
28-
Assert-NotNull $response
29-
Assert-AreEqual 2 $response.Count
30-
31-
Assert-AreEqual "ElasticPool1" $response[0].RecommendedElasticPoolName
32-
Assert-AreEqual "Standard" $response[0].DatabaseEdition
33-
Assert-AreEqual 1000 $response[0].Dtu
34-
Assert-AreEqual 100.6 $response[0].DatabaseDtuMin
35-
Assert-AreEqual 200.5 $response[0].DatabaseDtuMax
36-
Assert-AreEqual 1000.3 $response[0].StorageMB
37-
Assert-AreEqual '11/01/2014 00:00:00' $response[0].ObservationPeriodStart
38-
Assert-AreEqual '11/15/2014 00:00:00' $response[0].ObservationPeriodEnd
39-
Assert-AreEqual 900.2 $response[0].MaxObservedDtu
40-
Assert-AreEqual 350 $response[0].MaxObservedStorageMB
41-
}
42-
finally
43-
{
44-
Remove-ResourceGroupForTest $rg
45-
}
46-
}
47-
48-
<#
49-
.SYNOPSIS
50-
Tests getting recommended elastic pool by name
51-
#>
52-
function Test-GetRecommendedElasticPool
53-
{
54-
# Setup
55-
$rg = Create-ResourceGroupForTest
56-
$server = Create-ServerForTest $rg "Japan East"
57-
58-
try
59-
{
60-
$response = Get-AzureSqlElasticPoolRecommendation -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -ElasticPoolRecommendation "ElasticPool1"
61-
Assert-NotNull $response
62-
63-
Assert-AreEqual "ElasticPool1" $response.RecommendedElasticPoolName
64-
Assert-AreEqual "Standard" $response.DatabaseEdition
65-
Assert-AreEqual 1000 $response.Dtu
66-
Assert-AreEqual 100.6 $response.DatabaseDtuMin
67-
Assert-AreEqual 200.5 $response.DatabaseDtuMax
68-
Assert-AreEqual 1000.3 $response.StorageMB
69-
Assert-AreEqual '11/01/2014 00:00:00' $response.ObservationPeriodStart
70-
Assert-AreEqual '11/15/2014 00:00:00' $response.ObservationPeriodEnd
71-
Assert-AreEqual 900.2 $response.MaxObservedDtu
72-
Assert-AreEqual 350 $response.MaxObservedStorageMB
73-
}
74-
finally
75-
{
76-
Remove-ResourceGroupForTest $rg
77-
}
78-
}
79-
80-
<#
81-
.SYNOPSIS
82-
Tests listing all databases in recommended elastic pool
83-
#>
84-
function Test-ListRecommendedElasticPoolDatabases
85-
{
86-
# Setup
87-
$rg = Create-ResourceGroupForTest
88-
$server = Create-ServerForTest $rg "Japan East"
89-
90-
try
91-
{
92-
$response = Get-AzureSqlElasticPoolRecommendationDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -ElasticPoolRecommendation "ElasticPool1"
93-
Assert-NotNull $response
94-
Assert-AreEqual 1 $response.Count
95-
96-
Assert-AreEqual 'TestDb1' $response[0].DatabaseName
97-
Assert-AreEqual '28acaef5-d228-4660-bb67-546ec8482496' $response[0].DatabaseId
98-
Assert-AreEqual 'Online' $response[0].Status
99-
}
100-
finally
101-
{
102-
Remove-ResourceGroupForTest $rg
103-
}
104-
}
105-
106-
<#
107-
.SYNOPSIS
108-
Tests getting database by name for specific recommended elastic pool
109-
#>
110-
function Test-GetRecommendedElasticPoolDatabase
111-
{
112-
# Setup
113-
$rg = Create-ResourceGroupForTest
114-
$server = Create-ServerForTest $rg "Japan East"
115-
116-
try
117-
{
118-
$response = Get-AzureSqlElasticPoolRecommendationDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -ElasticPoolRecommendation "ElasticPool1" -DatabaseName "TestDb1"
119-
Assert-NotNull $response
120-
121-
Assert-AreEqual 'TestDb1' $response.DatabaseName
122-
Assert-AreEqual '28acaef5-d228-4660-bb67-546ec8482496' $response.DatabaseId
123-
Assert-AreEqual 'Online' $response.Status
124-
}
125-
finally
126-
{
127-
Remove-ResourceGroupForTest $rg
128-
}
129-
}
130-
131-
<#
132-
.SYNOPSIS
133-
Tests listing metrics for specific recommended elastic pool
134-
#>
135-
function Test-GetRecommendedElasticPoolMetrics
136-
{
137-
# Setup
138-
$rg = Create-ResourceGroupForTest
139-
$server = Create-ServerForTest $rg "Japan East"
140-
141-
try
142-
{
143-
$response = Get-AzureSqlElasticPoolRecommendationMetrics -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -ElasticPoolRecommendation "ElasticPool1"
144-
Assert-NotNull $response
145-
Assert-AreEqual 3 $response.Count
146-
147-
Assert-AreEqual '04/01/2015 00:00:00' $response[0].DateTime
148-
Assert-AreEqual 100.5 $response[0].Dtu
149-
Assert-AreEqual 15.4 $response[0].SizeGB
150-
}
151-
finally
152-
{
153-
Remove-ResourceGroupForTest $rg
154-
}
21+
$response = Get-AzureSqlElasticPoolRecommendation -ResourceGroupName TestRg -ServerName test-srv-v1
22+
Assert-NotNull $response
23+
Assert-AreEqual 2 $response.Count
24+
25+
Assert-AreEqual "ElasticPool2" $response[1].Name
26+
Assert-AreEqual "Standard" $response[1].Edition
27+
Assert-AreEqual 1000 $response[1].Dtu
28+
Assert-AreEqual 100 $response[1].DatabaseDtuMin
29+
Assert-AreEqual 200 $response[1].DatabaseDtuMax
30+
Assert-AreEqual 0 $response[1].IncludeAllDatabases
31+
Assert-AreEqual 1 $response[1].DatabaseCollection.Count
32+
Assert-AreEqual master $response[1].DatabaseCollection[0]
15533
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
using Microsoft.Azure.Commands.ScenarioTest.SqlTests;
16+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17+
using Xunit;
18+
19+
namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
20+
{
21+
public class ServiceTierAdvisorTests : SqlTestsBase
22+
{
23+
[Fact]
24+
[Trait(Category.Sql, Category.CheckIn)]
25+
public void GetUpgradeDatabaseHint()
26+
{
27+
RunPowerShellTest("Test-GetUpgradeDatabaseHint");
28+
}
29+
30+
[Fact]
31+
[Trait(Category.Sql, Category.CheckIn)]
32+
public void GetUpgradeServerHint()
33+
{
34+
RunPowerShellTest("Test-GetUpgradeServerHint");
35+
}
36+
}
37+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
Tests getting database upgrade hints
18+
#>
19+
function Test-GetUpgradeDatabaseHint
20+
{
21+
$response = Get-AzureSqlDatabaseUpgradeHint -ResourceGroupName TestRg -ServerName test-srv-v1
22+
Assert-NotNull $response
23+
Assert-AreEqual 1 $response.Count
24+
Assert-AreEqual test-db-v1 $response[0].Name
25+
Assert-AreEqual Premium $response[0].TargetEdition
26+
Assert-AreEqual P2 $response[0].TargetServiceLevelObjective
27+
28+
$response = Get-AzureSqlDatabaseUpgradeHint -ResourceGroupName TestRg -ServerName test-srv-v1 -DatabaseName test-db-v1
29+
Assert-NotNull $response
30+
Assert-AreEqual 1 $response.Count
31+
Assert-AreEqual test-db-v1 $response[0].Name
32+
Assert-AreEqual Standard $response[0].TargetEdition
33+
Assert-AreEqual S0 $response[0].TargetServiceLevelObjective
34+
35+
$response = Get-AzureSqlDatabaseUpgradeHint -ResourceGroupName TestRg -ServerName test-srv-v1 -ExcludeElasticPoolCandidates 1
36+
Assert-NotNull $response
37+
Assert-AreEqual 1 $response.Count
38+
Assert-AreEqual test-db-v1 $response[0].Name
39+
Assert-AreEqual Premium $response[0].TargetEdition
40+
Assert-AreEqual P2 $response[0].TargetServiceLevelObjective
41+
42+
$response = Get-AzureSqlDatabaseUpgradeHint -ResourceGroupName TestRg -ServerName test-srv-v1 -DatabaseName test-db-v1 -ExcludeElasticPoolCandidates 1
43+
Assert-NotNull $response
44+
Assert-AreEqual 1 $response.Count
45+
Assert-AreEqual test-db-v1 $response[0].Name
46+
Assert-AreEqual Standard $response[0].TargetEdition
47+
Assert-AreEqual S0 $response[0].TargetServiceLevelObjective
48+
}
49+
50+
<#
51+
.SYNOPSIS
52+
Tests getting server upgrade hint
53+
#>
54+
function Test-GetUpgradeServerHint
55+
{
56+
$response = Get-AzureSqlServerUpgradeHint -ResourceGroupName TestRg -ServerName test-srv-v1
57+
Assert-NotNull $response
58+
Assert-AreEqual 1 $response.Databases.Count
59+
Assert-AreEqual test-db-v1 $response.Databases[0].Name
60+
Assert-AreEqual Standard $response.Databases[0].TargetEdition
61+
Assert-AreEqual S0 $response.Databases[0].TargetServiceLevelObjective
62+
63+
$response = Get-AzureSqlServerUpgradeHint -ResourceGroupName TestRg -ServerName test-srv-v1 -ExcludeElasticPools 1
64+
Assert-NotNull $response
65+
Assert-AreEqual 1 $response.Databases.Count
66+
Assert-AreEqual test-db-v1 $response.Databases[0].Name
67+
Assert-AreEqual Standard $response.Databases[0].TargetEdition
68+
Assert-AreEqual S0 $response.Databases[0].TargetServiceLevelObjective
69+
}

0 commit comments

Comments
 (0)