Skip to content

Commit 9d76b1e

Browse files
aim-for-betterZhenyu Zhou
andauthored
[HDInsight] Support new azure monitor feature (#15068)
* Support new azure monitor feature * Change the cmdlet name Get/Enable/Disable-AzHDInsightMonitor to Get/Enable/Disable-AzHDInsightAzureMonitor * Update the help doc and sdk version and add tests * Add online version link * Add related test * Change setbynameparameterset to bynameparameterset * Change the parameter set names to verb+ByName|ResourceId|InputObject style Co-authored-by: Zhenyu Zhou <[email protected]>
1 parent 2bdfadd commit 9d76b1e

21 files changed

+4766
-8
lines changed

src/HDInsight/HDInsight.Test/HDInsight.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5" />
15-
<PackageReference Include="Microsoft.Azure.Management.HDInsight" Version="6.2.0" />
15+
<PackageReference Include="Microsoft.Azure.Management.HDInsight" Version="7.0.0" />
1616
<PackageReference Include="Microsoft.Azure.Management.HDInsight.Job" Version="2.0.7" />
1717
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
1818
<PackageReference Include="Microsoft.Azure.Management.ManagedServiceIdentity" Version="0.11.0" />
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 HDInsightAzureMonitorTests
26+
{
27+
public XunitTracingInterceptor _logger;
28+
29+
public HDInsightAzureMonitorTests(ITestOutputHelper output)
30+
{
31+
_logger = new XunitTracingInterceptor(output);
32+
XunitTracingInterceptor.AddToContext(_logger);
33+
}
34+
35+
//[Fact(Skip = "test case cannot be re-recorded properly, need help from service team")]
36+
[Fact]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
38+
public void TestAzureMonitorRelatedCommands()
39+
{
40+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AzureMonitorRelatedCommands");
41+
}
42+
}
43+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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 Get,Enable or Disable Azure Monitor in Azure HDInsight Cluster
18+
#>
19+
function Test-AzureMonitorRelatedCommands{
20+
21+
# Create some resources that will be used throughout test
22+
try
23+
{
24+
$location = "East US"
25+
26+
# prepare parameter for creating parameter
27+
$params= Prepare-ClusterCreateParameter -location $location
28+
29+
# create cluster that will be used throughout test
30+
$cluster = New-AzHDInsightCluster -Location $params.location -ResourceGroupName $params.resourceGroupName `
31+
-ClusterName $params.clusterName -ClusterSizeInNodes $params.clusterSizeInNodes -ClusterType $params.clusterType `
32+
-StorageAccountResourceId $params.storageAccountResourceId -StorageAccountKey $params.storageAccountKey `
33+
-HttpCredential $params.httpCredential -SshCredential $params.sshCredential `
34+
-MinSupportedTlsVersion $params.minSupportedTlsVersion
35+
Assert-NotNull $cluster
36+
37+
$workspaceName = Generate-Name("workspace-ps-test")
38+
$resourceGroupName = $cluster.ResourceGroup
39+
40+
#create a new Log Analytics Workspace
41+
$sku = "pernode"
42+
$workspace = New-AzOperationalInsightsWorkspace -Location $location -Name $workspaceName -ResourceGroupName $resourceGroupName -Sku $sku
43+
44+
#get workspace's primaryKey
45+
$keys = Get-AzOperationalInsightsWorkspaceSharedKey -ResourceGroupName $resourceGroupName -Name $workspace.Name
46+
Assert-NotNull $keys
47+
#test Get-AzHDInsightAzureMonitor
48+
$result = Get-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup
49+
Assert-Null $result.WorkspaceId
50+
51+
#test Enable-AzHDInsightAzureMonitor
52+
$workspaceId = $workspace.CustomerId
53+
$primaryKey = $keys.PrimarySharedKey
54+
55+
Assert-NotNull $workspaceId
56+
Assert-NotNull $primaryKey
57+
Enable-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroup $cluster.ResourceGroup -WorkspaceId $workspaceId -Primary $primaryKey
58+
59+
$result = Get-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup
60+
Assert-True {$result.ClusterMonitoringEnabled}
61+
Assert-AreEqual $result.WorkspaceId $workspaceId
62+
63+
#test Disable-AzHDInsightAzureMonitor
64+
Disable-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup
65+
$result = Get-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup
66+
Assert-False {$result.ClusterMonitoringEnabled}
67+
Assert-Null $result.WorkspaceId
68+
}
69+
finally
70+
{
71+
# Delete cluster and resource group
72+
Remove-AzHDInsightCluster -ClusterName $cluster.Name
73+
Remove-AzResourceGroup -ResourceGroupName $cluster.ResourceGroup
74+
}
75+
}

0 commit comments

Comments
 (0)