-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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]>
- Loading branch information
1 parent
2bdfadd
commit 9d76b1e
Showing
21 changed files
with
4,766 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightAzureMonitorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Azure.ServiceManagement.Common.Models; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Commands.HDInsight.Test.ScenarioTests | ||
{ | ||
public class HDInsightAzureMonitorTests | ||
{ | ||
public XunitTracingInterceptor _logger; | ||
|
||
public HDInsightAzureMonitorTests(ITestOutputHelper output) | ||
{ | ||
_logger = new XunitTracingInterceptor(output); | ||
XunitTracingInterceptor.AddToContext(_logger); | ||
} | ||
|
||
//[Fact(Skip = "test case cannot be re-recorded properly, need help from service team")] | ||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestAzureMonitorRelatedCommands() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-AzureMonitorRelatedCommands"); | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightAzureMonitorTests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# ---------------------------------------------------------------------------------- | ||
# | ||
# Copyright Microsoft Corporation | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ---------------------------------------------------------------------------------- | ||
|
||
<# | ||
.SYNOPSIS | ||
Test Get,Enable or Disable Azure Monitor in Azure HDInsight Cluster | ||
#> | ||
function Test-AzureMonitorRelatedCommands{ | ||
|
||
# Create some resources that will be used throughout test | ||
try | ||
{ | ||
$location = "East US" | ||
|
||
# prepare parameter for creating parameter | ||
$params= Prepare-ClusterCreateParameter -location $location | ||
|
||
# create cluster that will be used throughout test | ||
$cluster = New-AzHDInsightCluster -Location $params.location -ResourceGroupName $params.resourceGroupName ` | ||
-ClusterName $params.clusterName -ClusterSizeInNodes $params.clusterSizeInNodes -ClusterType $params.clusterType ` | ||
-StorageAccountResourceId $params.storageAccountResourceId -StorageAccountKey $params.storageAccountKey ` | ||
-HttpCredential $params.httpCredential -SshCredential $params.sshCredential ` | ||
-MinSupportedTlsVersion $params.minSupportedTlsVersion | ||
Assert-NotNull $cluster | ||
|
||
$workspaceName = Generate-Name("workspace-ps-test") | ||
$resourceGroupName = $cluster.ResourceGroup | ||
|
||
#create a new Log Analytics Workspace | ||
$sku = "pernode" | ||
$workspace = New-AzOperationalInsightsWorkspace -Location $location -Name $workspaceName -ResourceGroupName $resourceGroupName -Sku $sku | ||
|
||
#get workspace's primaryKey | ||
$keys = Get-AzOperationalInsightsWorkspaceSharedKey -ResourceGroupName $resourceGroupName -Name $workspace.Name | ||
Assert-NotNull $keys | ||
#test Get-AzHDInsightAzureMonitor | ||
$result = Get-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup | ||
Assert-Null $result.WorkspaceId | ||
|
||
#test Enable-AzHDInsightAzureMonitor | ||
$workspaceId = $workspace.CustomerId | ||
$primaryKey = $keys.PrimarySharedKey | ||
|
||
Assert-NotNull $workspaceId | ||
Assert-NotNull $primaryKey | ||
Enable-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroup $cluster.ResourceGroup -WorkspaceId $workspaceId -Primary $primaryKey | ||
|
||
$result = Get-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup | ||
Assert-True {$result.ClusterMonitoringEnabled} | ||
Assert-AreEqual $result.WorkspaceId $workspaceId | ||
|
||
#test Disable-AzHDInsightAzureMonitor | ||
Disable-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup | ||
$result = Get-AzHDInsightAzureMonitor -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup | ||
Assert-False {$result.ClusterMonitoringEnabled} | ||
Assert-Null $result.WorkspaceId | ||
} | ||
finally | ||
{ | ||
# Delete cluster and resource group | ||
Remove-AzHDInsightCluster -ClusterName $cluster.Name | ||
Remove-AzResourceGroup -ResourceGroupName $cluster.ResourceGroup | ||
} | ||
} |
Oops, something went wrong.