Skip to content

Commit 157bf62

Browse files
author
Anil Kumar Yelam
committed
Addressed first iteration comments. Added tests setup for Advisors tests, not possible for recommended actions tests. Finished help documentation for the cmdlets.
1 parent 12a3d53 commit 157bf62

28 files changed

+18101
-15409
lines changed

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

Lines changed: 256 additions & 120 deletions
Large diffs are not rendered by default.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
16+
# ============================================================
17+
# A NOTE ON (LACK OF) TEST SETUP FOR RECOMMENDED ACTIONS TESTS
18+
# ============================================================
19+
# Recommended actions are generated based on database workload and new database won't get any recommended actions.
20+
# It's hard to generate mock recommendations on a new server, database or elastic pool from this code as well, as the process is Microsoft Internal.
21+
# For now, Tests have to use recorded responses on some specific database that already has recommended actions.
22+
1523
<#
1624
.SYNOPSIS
1725
Tests listing Server recommended actions

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestGetDatabaseAdvisor.json

Lines changed: 972 additions & 12 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestGetElasticPoolAdvisor.json

Lines changed: 842 additions & 11 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestGetServerAdvisor.json

Lines changed: 614 additions & 12 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestListDatabaseAdvisors.json

Lines changed: 972 additions & 12 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestListDatabaseAdvisorsExpanded.json

Lines changed: 963 additions & 12 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestListElasticPoolAdvisors.json

Lines changed: 843 additions & 12 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestListElasticPoolAdvisorsExpanded.json

Lines changed: 896 additions & 11 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestListServerAdvisors.json

Lines changed: 614 additions & 12 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestListServerAdvisorsExpanded.json

Lines changed: 668 additions & 12 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestUpdateDatabaseAdvisor.json

Lines changed: 1085 additions & 68 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestUpdateElasticPoolAdvisor.json

Lines changed: 999 additions & 111 deletions
Large diffs are not rendered by default.

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.AdvisorTests/TestUpdateServerAdvisor.json

Lines changed: 771 additions & 112 deletions
Large diffs are not rendered by default.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
namespace Microsoft.Azure.Commands.Sql.Advisor.Cmdlet
17+
{
18+
/// <summary>
19+
/// Allowed values for updating Advisor Auto-execute Status
20+
/// </summary>
21+
public enum AdvisorAutoExecuteStatusValues
22+
{
23+
/// <summary>
24+
/// To explicitly enable auto-execute on the current resource for this advisor
25+
/// </summary>
26+
Enabled,
27+
28+
/// <summary>
29+
/// To explicity disable auto-execute on the current resource for this advisor
30+
/// </summary>
31+
Disabled,
32+
33+
/// <summary>
34+
/// To clear the explicit value previously set and inherit the default value from the parent of the current resource.
35+
/// </summary>
36+
Default
37+
}
38+
}

src/ResourceManager/Sql/Commands.Sql/Advisor/Cmdlet/SetAzureSqlDatabaseAdvisorAutoExecuteStatus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class SetAzureSqlDatabaseAdvisorAutoExecuteStatus : AzureSqlDatabaseAdvis
4242
ValueFromPipelineByPropertyName = true,
4343
HelpMessage = "The new auto-execute status of Azure SQL Database Advisor.")]
4444
[ValidateNotNullOrEmpty]
45-
public string AutoExecuteStatus { get; set; }
45+
public AdvisorAutoExecuteStatusValues AutoExecuteStatus { get; set; }
4646

4747
/// <summary>
4848
/// Gets entities from the service.
@@ -69,7 +69,7 @@ protected override IEnumerable<AzureSqlDatabaseAdvisorModel> ApplyUserInputToMod
6969
ServerName = ServerName,
7070
DatabaseName = DatabaseName,
7171
AdvisorName = AdvisorName,
72-
AutoExecuteStatus = AutoExecuteStatus
72+
AutoExecuteStatus = AutoExecuteStatus.ToString()
7373
});
7474

7575
return newEntity;

src/ResourceManager/Sql/Commands.Sql/Advisor/Cmdlet/SetAzureSqlElasticPoolAdvisorAutoExecuteStatus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class SetAzureSqlElasticPoolAdvisorAutoExecuteStatus : AzureSqlElasticPoo
4242
ValueFromPipelineByPropertyName = true,
4343
HelpMessage = "The new auto-execute status of Azure SQL Elastic Pool Advisor.")]
4444
[ValidateNotNullOrEmpty]
45-
public string AutoExecuteStatus { get; set; }
45+
public AdvisorAutoExecuteStatusValues AutoExecuteStatus { get; set; }
4646

4747
/// <summary>
4848
/// Gets entities from the service.
@@ -69,7 +69,7 @@ protected override IEnumerable<AzureSqlElasticPoolAdvisorModel> ApplyUserInputTo
6969
ServerName = ServerName,
7070
ElasticPoolName = ElasticPoolName,
7171
AdvisorName = AdvisorName,
72-
AutoExecuteStatus = AutoExecuteStatus
72+
AutoExecuteStatus = AutoExecuteStatus.ToString()
7373
});
7474

7575
return newEntity;

src/ResourceManager/Sql/Commands.Sql/Advisor/Cmdlet/SetAzureSqlServerAdvisorAutoExecuteStatus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class SetAzureSqlServerAdvisorAutoExecuteStatus : AzureSqlServerAdvisorCm
4242
ValueFromPipelineByPropertyName = true,
4343
HelpMessage = "The new auto-execute status of Azure SQL Server Advisor.")]
4444
[ValidateNotNullOrEmpty]
45-
public string AutoExecuteStatus { get; set; }
45+
public AdvisorAutoExecuteStatusValues AutoExecuteStatus { get; set; }
4646

4747
/// <summary>
4848
/// Gets entities from the service.
@@ -68,7 +68,7 @@ protected override IEnumerable<AzureSqlServerAdvisorModel> ApplyUserInputToModel
6868
ResourceGroupName = ResourceGroupName,
6969
ServerName = ServerName,
7070
AdvisorName = AdvisorName,
71-
AutoExecuteStatus = AutoExecuteStatus
71+
AutoExecuteStatus = AutoExecuteStatus.ToString()
7272
});
7373

7474
return newEntity;

src/ResourceManager/Sql/Commands.Sql/Advisor/Model/AzureSqlElasticPoolAdvisor.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/ResourceManager/Sql/Commands.Sql/Advisor/Service/AzureSqlAdvisorCommunicatorBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ protected SqlManagementClient GetCurrentSqlClient(string clientRequestId)
6969
{
7070
SqlClient = AzureSession.ClientFactory.CreateClient<SqlManagementClient>(Context, AzureEnvironment.Endpoint.ResourceManager);
7171
}
72+
7273
SqlClient.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
7374
SqlClient.HttpClient.DefaultRequestHeaders.Add(Constants.ClientRequestIdHeaderName, clientRequestId);
7475
return SqlClient;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@
5151
<Prefer32Bit>false</Prefer32Bit>
5252
</PropertyGroup>
5353
<ItemGroup>
54+
<Compile Include="Advisor\Cmdlet\AdvisorAutoExecuteStatusValues.cs" />
5455
<Compile Include="RecommendedAction\Cmdlet\AzureSqlDatabaseRecommendedActionCmdletBase.cs" />
5556
<Compile Include="RecommendedAction\Cmdlet\AzureSqlElasticPoolRecommendedActionCmdletBase.cs" />
5657
<Compile Include="RecommendedAction\Cmdlet\AzureSqlServerRecommendedActionCmdletBase.cs" />
5758
<Compile Include="RecommendedAction\Cmdlet\GetAzureSqlDatabaseRecommendedActions.cs" />
5859
<Compile Include="RecommendedAction\Cmdlet\GetAzureSqlElasticPoolRecommendedActions.cs" />
5960
<Compile Include="RecommendedAction\Cmdlet\GetAzureSqlServerRecommendedActions.cs" />
61+
<Compile Include="RecommendedAction\Cmdlet\RecommendedActionStateValues.cs" />
6062
<Compile Include="RecommendedAction\Cmdlet\SetAzureSqlDatabaseRecommendedActionState.cs" />
6163
<Compile Include="RecommendedAction\Cmdlet\SetAzureSqlElasticPoolRecommendedActionState.cs" />
6264
<Compile Include="RecommendedAction\Cmdlet\SetAzureSqlServerRecommendedActionState.cs" />
@@ -354,7 +356,7 @@
354356
</Reference>
355357
<Reference Include="Microsoft.Azure.Management.Sql, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
356358
<SpecificVersion>False</SpecificVersion>
357-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.49.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
359+
<HintPath>G:\GitHub2\azure-powershell\src\packages\Microsoft.Azure.Management.Sql.0.49.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
358360
<Private>True</Private>
359361
</Reference>
360362
<Reference Include="Microsoft.Azure.Management.Storage">

0 commit comments

Comments
 (0)