Skip to content

Commit 865af59

Browse files
aim-for-betterZhenyu Zhou
andauthored
[HDInsight] Support HDI Autoscale Feature (#12858)
* HDInsight Support Autoscale: 1. Add a new parameter to existing cmdlet New-AzHDInsightCluster 2. Add 5 cmdlets: - New-AzHDInsightClusterAutoscaleScheduleCondition - New-AzHDInsightClusterAutoscaleConfiguration - Get-AzHDInsightClusterAutoscaleConfiguration - Set-AzHDInsightClusterAutoscaleConfiguration - Remove-AzHDInsightClusterAutoscaleConfiguration * update cred scan suppression file * Add statistic analysis exception by modifing SignatureIssues.csv file * Change Days to Day * Update parameter set in Get/Remove-AzHDInsightClusterAutoscaleConfiguration * Add -Schedule parameter to schedule related parameter sets Co-authored-by: Zhenyu Zhou <[email protected]>
1 parent 2012dd9 commit 865af59

File tree

46 files changed

+14782
-576
lines changed

Some content is hidden

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

46 files changed

+14782
-576
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.ServiceManagement.Common.Models;
16+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17+
using System;
18+
using System.Collections.Generic;
19+
using System.Text;
20+
using Xunit;
21+
using Xunit.Abstractions;
22+
23+
namespace Commands.HDInsight.Test.ScenarioTests
24+
{
25+
public class HDInsightAutoscaleTests : TestController
26+
{
27+
public XunitTracingInterceptor _logger;
28+
29+
public HDInsightAutoscaleTests(ITestOutputHelper output)
30+
{
31+
_logger = new XunitTracingInterceptor(output);
32+
XunitTracingInterceptor.AddToContext(_logger);
33+
}
34+
35+
[Fact]
36+
[Trait(Category.AcceptanceType, Category.CheckIn)]
37+
public void TestAutoscaleRelatedCommands()
38+
{
39+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AutoscaleRelatedCommands");
40+
}
41+
}
42+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 Enable, Disable autoscale of HDInsight cluster.
18+
#>
19+
function Test-AutoscaleRelatedCommands{
20+
21+
# Create some resources that will be used throughout test
22+
try
23+
{
24+
# prepare parameter for creating parameter
25+
$params= Prepare-ClusterCreateParameterForWASB
26+
27+
# test create cluster
28+
$cluster = New-AzHDInsightCluster -Location $params.location -ResourceGroupName $params.resourceGroupName `
29+
-ClusterName $params.clusterName -ClusterSizeInNodes $params.clusterSizeInNodes -ClusterType $params.clusterType `
30+
-DefaultStorageAccountName $params.storageAccountName -DefaultStorageAccountKey $params.storageAccountKey `
31+
-HttpCredential $params.httpCredential -SshCredential $params.sshCredential `
32+
-MinSupportedTlsVersion $params.minSupportedTlsVersion
33+
34+
Assert-NotNull $cluster
35+
36+
# test Set-AzHDInsightClusterAutoscaleConfiguration: enable Load-based autoscale
37+
$loadAutoscaleCluster=Set-AzHDInsightClusterAutoscaleConfiguration -ResourceGroupName $cluster.ResourceGroup `
38+
-ClusterName $cluster.Name -MinWorkerNodeCount 4 -MaxWorkerNodeCount 5
39+
40+
Assert-NotNull $loadAutoscaleCluster
41+
Assert-NotNull $loadAutoscaleCluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Capacity
42+
Assert-Null $loadAutoscaleCluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Recurrence
43+
44+
# test Get-AzHDInsightClusterAutoscaleConfiguration
45+
$autoscale = Get-AzHDInsightClusterAutoscaleConfiguration -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup
46+
Assert-AreEqual $autoscale.Capacity.MinInstanceCount 4
47+
Assert-AreEqual $autoscale.Capacity.MaxInstanceCount 5
48+
49+
Start-Sleep -s 20
50+
# test Remove-AzHDInsightClusterAutoscaleConfiguration
51+
Remove-AzHDInsightClusterAutoscaleConfiguration -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup
52+
53+
# test Set-AzHDInsightClusterAutoscaleConfiguration: enable Schedule-based autoscale
54+
# test New-AzHDInsightAutoscaleScheduleCondition
55+
$condition1=New-AzHDInsightClusterAutoscaleScheduleCondition -Time 09:00 -WorkerNodeCount 5 -Day Monday,Tuesday
56+
$condition2=New-AzHDInsightClusterAutoscaleScheduleCondition -Time 08:00 -WorkerNodeCount 4 -Day Friday
57+
58+
$scheduleAutoscaleCluster=Set-AzHDInsightClusterAutoscaleConfiguration -ResourceGroupName $cluster.ResourceGroup `
59+
-ClusterName $cluster.Name -Schedule -TimeZone "Pacific Standard Time" -Condition $condition1,$condition2
60+
61+
Assert-AreEqual $scheduleAutoscaleCluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Recurrence.TimeZone "Pacific Standard Time"
62+
Assert-AreEqual $scheduleAutoscaleCluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Recurrence.Condition[0].WorkerNodeCount 5
63+
}
64+
finally
65+
{
66+
# Delete cluster and resource group
67+
Remove-AzHDInsightCluster -ClusterName $cluster.Name
68+
Remove-AzResourceGroup -ResourceGroupName $cluster.ResourceGroup
69+
}
70+
}

src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightClusterTests.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,21 @@ public void TestCreateClusterWithPrivateLink()
6161
[Trait(Category.AcceptanceType, Category.CheckIn)]
6262
public void TestCreateClusterWithEncryptionAtHost()
6363
{
64-
TestController.NewInstance.RunPowerShellTest(_logger, "Test-TestCreateClusterWithEncryptionAtHost");
64+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateClusterWithEncryptionAtHost");
65+
}
66+
67+
[Fact]
68+
[Trait(Category.AcceptanceType, Category.CheckIn)]
69+
public void TestCreateClusterWithLoadBasedAutoscale()
70+
{
71+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateClusterWithLoadBasedAutoscale");
72+
}
73+
74+
[Fact]
75+
[Trait(Category.AcceptanceType, Category.CheckIn)]
76+
public void TestCreateClusterWithScheduleBasedAutoscale()
77+
{
78+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateClusterWithScheduleBasedAutoscale");
6579
}
6680
}
6781
}

src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightClusterTests.ps1

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,16 @@ function Test-CreateClusterWithPrivateLink{
166166

167167
<#
168168
.SYNOPSIS
169-
Test Create Azure HDInsight Cluster which Enalbes Encryption At Host
169+
Test Create Azure HDInsight Cluster which enalbes Encryption At Host
170170
#>
171171

172-
function Test-TestCreateClusterWithEncryptionAtHost{
172+
function Test-CreateClusterWithEncryptionAtHost{
173173

174174
# Create some resources that will be used throughout test
175175
try
176176
{
177177
# prepare parameter for creating parameter
178-
$params= Prepare-ClusterCreateParameterForWASB -Location "South Central US"
178+
$params= Prepare-ClusterCreateParameterForWASB -location "South Central US"
179179
$encryptionAtHost=$true
180180
$workerNodeSize="Standard_DS14_v2"
181181
$headNodeSize="Standard_DS14_v2"
@@ -199,3 +199,81 @@ function Test-TestCreateClusterWithEncryptionAtHost{
199199
Remove-AzResourceGroup -ResourceGroupName $cluster.ResourceGroup
200200
}
201201
}
202+
203+
<#
204+
.SYNOPSIS
205+
Test Create Azure HDInsight Cluster with Load-based autoscale
206+
#>
207+
208+
function Test-CreateClusterWithLoadBasedAutoscale{
209+
210+
# Create some resources that will be used throughout test
211+
try
212+
{
213+
# prepare parameter for creating parameter
214+
$params= Prepare-ClusterCreateParameterForWASB -location "East US"
215+
216+
# create autoscale cofiguration
217+
$autoscaleConfiguration=New-AzHDInsightClusterAutoscaleConfiguration -MinWorkerNodeCount 4 -MaxWorkerNodeCount 5
218+
219+
# create cluster with load-based autoscale
220+
$cluster=New-AzHDInsightCluster -Location $params.location -ResourceGroupName $params.resourceGroupName `
221+
-ClusterName $params.clusterName -ClusterSizeInNodes $params.clusterSizeInNodes -ClusterType $params.clusterType `
222+
-DefaultStorageAccountName $params.storageAccountName -DefaultStorageAccountKey $params.storageAccountKey `
223+
-HttpCredential $params.httpCredential -SshCredential $params.sshCredential `
224+
-MinSupportedTlsVersion $params.minSupportedTlsVersion -Version 4.0 `
225+
-AutoscaleConfiguration $autoscaleConfiguration
226+
227+
Assert-NotNull $cluster
228+
Assert-AreEqual $cluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Capacity.MinInstanceCount 4
229+
Assert-AreEqual $cluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Capacity.MaxInstanceCount 5
230+
}
231+
finally
232+
{
233+
# Delete cluster and resource group
234+
Remove-AzHDInsightCluster -ClusterName $cluster.Name
235+
Remove-AzResourceGroup -ResourceGroupName $cluster.ResourceGroup
236+
}
237+
}
238+
239+
<#
240+
.SYNOPSIS
241+
Test Create Azure HDInsight Cluster with Schedule-based autoscale
242+
#>
243+
244+
function Test-CreateClusterWithScheduleBasedAutoscale{
245+
246+
# Create some resources that will be used throughout test
247+
try
248+
{
249+
# prepare parameter for creating parameter
250+
$params= Prepare-ClusterCreateParameterForWASB -location "East US"
251+
252+
# create autoscale schedule condition
253+
$condition1=New-AzHDInsightClusterAutoscaleScheduleCondition -Time "09:00" -WorkerNodeCount 4 -Day Monday,Tuesday
254+
$condition2=New-AzHDInsightClusterAutoscaleScheduleCondition -Time "08:00" -WorkerNodeCount 5 -Day Friday
255+
256+
# create autoscale configuration
257+
$autoscaleConfiguration=New-AzHDInsightClusterAutoscaleConfiguration -TimeZone ([System.TimeZoneInfo]::Local).Id `
258+
-Condition $condition1,$condition2
259+
260+
# create cluster with schedule-based autoscale
261+
$cluster=New-AzHDInsightCluster -Location $params.location -ResourceGroupName $params.resourceGroupName `
262+
-ClusterName $params.clusterName -ClusterSizeInNodes $params.clusterSizeInNodes -ClusterType $params.clusterType `
263+
-DefaultStorageAccountName $params.storageAccountName -DefaultStorageAccountKey $params.storageAccountKey `
264+
-HttpCredential $params.httpCredential -SshCredential $params.sshCredential `
265+
-MinSupportedTlsVersion $params.minSupportedTlsVersion -Version 4.0 `
266+
-AutoscaleConfiguration $autoscaleConfiguration
267+
268+
Assert-NotNull $cluster
269+
Assert-NotNull $cluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Recurrence
270+
Assert-AreEqual $cluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Recurrence.Condition[0].WorkerNodeCount $condition1.WorkerNodeCount
271+
Assert-AreEqual $cluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Recurrence.Condition[1].WorkerNodeCount $condition2.WorkerNodeCount
272+
}
273+
finally
274+
{
275+
# Delete cluster and resource group
276+
Remove-AzHDInsightCluster -ClusterName $cluster.Name
277+
Remove-AzResourceGroup -ResourceGroupName $cluster.ResourceGroup
278+
}
279+
}

0 commit comments

Comments
 (0)