Skip to content

Commit fbeb471

Browse files
authored
Merge pull request #10322 from aim-for-better/Az.HDInsight-preview
[HDInsight] Update hdinsight sdk from hyak to swagger
2 parents 58694bd + 9488b6f commit fbeb471

File tree

77 files changed

+16474
-1179
lines changed

Some content is hidden

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

77 files changed

+16474
-1179
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Azure.Management.HDInsight" Version="2.1.0" />
14+
<PackageReference Include="Microsoft.Azure.Management.HDInsight" Version="5.1.0" />
1515
<PackageReference Include="Microsoft.Azure.Management.HDInsight.Job" Version="2.0.7" />
16+
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.19.0-preview" />
1617
</ItemGroup>
1718

1819
<ItemGroup>

src/HDInsight/HDInsight.Test/HDInsightTestBase.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Hyak.Common;
16+
using Microsoft.Azure.Commands.Common.Authentication;
17+
using Microsoft.Azure.Commands.Common.Authentication.Factories;
1618
using Microsoft.Azure.Commands.HDInsight.Models;
1719
using Microsoft.Azure.Management.HDInsight.Models;
1820
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
@@ -44,6 +46,9 @@ public virtual void SetupTestsForManagement()
4446

4547
public virtual void SetupTestsForData()
4648
{
49+
//This is because job test need to use ClientFactory,however scenario test will create a MockClientFactory
50+
AzureSession.Instance.ClientFactory = new ClientFactory();
51+
4752
hdinsightManagementMock = new Mock<AzureHdInsightManagementClient>();
4853
var cred = new BasicAuthenticationCloudCredentials { Username = "username", Password = "Password1!" };
4954
hdinsightJobManagementMock = new Mock<AzureHdInsightJobManagementClient>(ClusterName, cred);
@@ -53,29 +58,29 @@ public virtual void SetupTestsForData()
5358
public virtual void SetupManagementClientForJobTests()
5459
{
5560
// Update HDInsight Management properties for Job.
56-
var cluster1 = new Cluster
61+
var cluster1 = new Cluster(
62+
id: $"/subscriptions/{Guid.NewGuid()}/resourceGroups/{ResourceGroupName}/providers/Microsoft.HDInsight/clusters/{ClusterName}",
63+
name: ClusterName)
5764
{
58-
Id = "/subscriptions/" + Guid.NewGuid() + "/resourceGroups/" + ResourceGroupName + "/providers/Microsoft.HDInsight/clusters/" + ClusterName,
59-
Name = ClusterName,
6065
Location = Location,
6166
Properties = new ClusterGetProperties
6267
{
63-
ClusterVersion = "3.2",
68+
ClusterVersion = "3.6",
6469
ClusterState = "Running",
6570
ClusterDefinition = new ClusterDefinition
6671
{
67-
ClusterType = ClusterType
72+
Kind = ClusterType
6873
},
6974
QuotaInfo = new QuotaInfo
7075
{
7176
CoresUsed = 24
7277
},
73-
OperatingSystemType = OSType.Windows,
78+
OsType = OSType.Linux,
7479
ConnectivityEndpoints = new List<ConnectivityEndpoint> { new ConnectivityEndpoint { Location = ClusterName, Name = "HTTPS" } }
7580
}
7681
};
7782

78-
var listresponse = new ClusterListResponse { Clusters = new[] { cluster1 } };
83+
var listresponse = new[] { cluster1 };
7984
hdinsightManagementMock.Setup(c => c.ListClusters())
8085
.Returns(listresponse)
8186
.Verifiable();
@@ -92,15 +97,12 @@ public virtual void SetupManagementClientForJobTests()
9297
.Returns(configurationResponse)
9398
.Verifiable();
9499

95-
var listConfigurationsResponse = new ClusterListConfigurationsResponse
100+
var listConfigurationsResponse = new ClusterConfigurations
96101
{
97-
Configurations = new Dictionary<string, ClusterConfiguration>
102+
Configurations = new Dictionary<string, IDictionary<string, string>>
98103
{
99104
{
100-
"core-site", new ClusterConfiguration
101-
{
102-
Configuration=configurationResponse
103-
}
105+
"core-site", configurationResponse
104106
}
105107
}
106108
};
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
Generate the name for cluster,resource group,script action,workspace etc.
18+
#>
19+
function Generate-Name([string] $prefix="hdi-ps-test"){
20+
return getAssetName($prefix)
21+
}
22+
23+
<#
24+
.SYNOPSIS
25+
Generate storage account name
26+
#>
27+
function Generate-StorageAccountName([string] $prefix="psstorage"){
28+
return getAssetName($prefix)
29+
}
30+
31+
<#
32+
.SYNOPSIS
33+
Create cluster
34+
#>
35+
function Create-Cluster{
36+
param(
37+
[string] $clusterName="hdi-ps-test",
38+
[string] $location="West US",
39+
[string] $resourceGroupName="group-ps-test",
40+
[string] $clusterType="Spark",
41+
[string] $storageAccountName="storagepstest"
42+
)
43+
44+
$clusterName=Generate-Name($clusterName)
45+
$resourceGroupName=Generate-Name($resourceGroupName)
46+
47+
$resourceGroup=New-AzResourceGroup -Name $resourceGroupName -Location $location
48+
49+
$storageAccountName=Generate-StorageAccountName($storageAccountName)
50+
51+
$storageAccount= New-AzStorageAccount -ResourceGroupName $resourceGroupName -Location $location -Name $storageAccountName -TypeString "Standard_RAGRS"
52+
53+
$storageAccountKey=Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountName
54+
$storageAccountKey=$storageAccountKey[0].Value
55+
56+
$httpUser="admin"
57+
$textPassword= "YourPw!00953"
58+
$httpPassword=ConvertTo-SecureString $textPassword -AsPlainText -Force
59+
$sshUser="sshuser"
60+
$sshPassword=$httpPassword
61+
$httpCredential=New-Object System.Management.Automation.PSCredential($httpUser, $httpPassword)
62+
$sshCredential=New-Object System.Management.Automation.PSCredential($sshUser, $sshPassword)
63+
64+
$clusterSizeInNodes=2
65+
66+
$cluster=New-AzHDInsightCluster -Location $location -ResourceGroupName $resourceGroup.ResourceGroupName -ClusterName $clusterName `
67+
-ClusterSizeInNodes $clusterSizeInNodes -ClusterType $clusterType -DefaultStorageAccountName $storageAccountName `
68+
-DefaultStorageAccountKey $storageAccountKey -HttpCredential $httpCredential -SshCredential $sshCredential
69+
70+
return $cluster
71+
}
72+
73+
<#
74+
.SYNOPSIS
75+
Asserts if two tags are equal
76+
#>
77+
function Assert-Tags($tags1, $tags2)
78+
{
79+
if($tags1.count -ne $tags2.count)
80+
{
81+
throw "Tag size not equal. Tag1: $tags1.count Tag2: $tags2.count"
82+
}
83+
84+
foreach($key in $tags1.Keys)
85+
{
86+
if($tags1[$key] -ne $tags2[$key])
87+
{
88+
throw "Tag content not equal. Key:$key Tags1:" + $tags1[$key] + "Tags2:" + $tags2[$key]
89+
}
90+
}
91+
}
92+
93+
<#
94+
.SYNOPSIS
95+
Asserts if two compression types are equal
96+
#>
97+
function Assert-CompressionTypes($types1, $types2)
98+
{
99+
if($types1.Count -ne $types1.Count)
100+
{
101+
throw "Array size not equal. Types1: $types1.count Types2: $types2.count"
102+
}
103+
104+
foreach($value1 in $types1)
105+
{
106+
$found = $false
107+
foreach($value2 in $types2)
108+
{
109+
if($value1.CompareTo($value2) -eq 0)
110+
{
111+
$found = $true
112+
break
113+
}
114+
}
115+
if(-Not($found))
116+
{
117+
throw "Compression content not equal. " + $value1 + " cannot be found in second array"
118+
}
119+
}
120+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 Xunit;
18+
using Xunit.Abstractions;
19+
20+
namespace Commands.HDInsight.Test.ScenarioTests
21+
{
22+
public class HDInsightClusterTests : TestController
23+
{
24+
public XunitTracingInterceptor _logger;
25+
26+
public HDInsightClusterTests(ITestOutputHelper output)
27+
{
28+
_logger = new XunitTracingInterceptor(output);
29+
XunitTracingInterceptor.AddToContext(_logger);
30+
}
31+
32+
[Fact]
33+
[Trait(Category.AcceptanceType, Category.CheckIn)]
34+
public void TestClusterRelatedCommands()
35+
{
36+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ClusterRelatedCommands");
37+
}
38+
}
39+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 Create and resize Azure HDInsight Cluster
18+
#>
19+
20+
function Test-ClusterRelatedCommands{
21+
22+
# Create some resources that will be used throughout test
23+
try
24+
{
25+
# test create cluster
26+
$cluster = Create-Cluster
27+
Assert-NotNull $cluster
28+
29+
#test Get-AzHDInsightCluster
30+
$resultCluster = Get-AzHDInsightCluster -ClusterName $cluster.Name
31+
Assert-AreEqual $resultCluster.Name $cluster.Name
32+
33+
#test Set-AzHDInsightClusterSize
34+
$resizeCluster = Set-AzHDInsightClusterSize -ClusterName $cluster.Name -ResourceGroupName $cluster.ResourceGroup `
35+
-TargetInstanceCount 3
36+
Assert-AreEqual $resizeCluster.CoresUsed 20
37+
}
38+
finally
39+
{
40+
# Delete cluster and resource group
41+
Remove-AzHDInsightCluster -ClusterName $cluster.Name
42+
Remove-AzResourceGroup -ResourceGroupName $cluster.ResourceGroup
43+
}
44+
45+
}

src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightConfigurationTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Commands.HDInsight.Test.ScenarioTests;
1516
using Microsoft.Azure.ServiceManagement.Common.Models;
1617
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1718
using Xunit;
19+
using Xunit.Abstractions;
1820

19-
namespace Microsoft.Azure.Commands.HDInsight.Test
21+
namespace Commands.HDInsight.Test.ScenarioTests
2022
{
21-
public class HDInsightConfigurationTests : HDInsightScenarioTestsBase
23+
public class HDInsightConfigurationTests
2224
{
2325
public XunitTracingInterceptor _logger;
2426

25-
public HDInsightConfigurationTests(Xunit.Abstractions.ITestOutputHelper output)
27+
public HDInsightConfigurationTests(ITestOutputHelper output)
2628
{
2729
_logger = new XunitTracingInterceptor(output);
2830
XunitTracingInterceptor.AddToContext(_logger);
@@ -32,7 +34,7 @@ public HDInsightConfigurationTests(Xunit.Abstractions.ITestOutputHelper output)
3234
[Trait(Category.AcceptanceType, Category.CheckIn)]
3335
public void TestConfigurationPipelining()
3436
{
35-
NewInstance.RunPsTest(_logger, "Test-ConfigurationPipelining");
37+
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ConfigurationPipelining");
3638
}
3739
}
3840
}

src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightConfigurationTests.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,32 @@
6868
$config = $config | Set-AzHDInsightDefaultStorage -StorageAccountName fakedefaultaccount -StorageAccountKey DEFAULTACCOUNTKEY==
6969
Assert-NotNull $config.DefaultStorageAccountName
7070
Assert-NotNull $config.DefaultStorageAccountKey
71+
72+
#test Add-AzHDInsightComponentVersion
73+
$componentName="Spark"
74+
$componentVersion="2.3"
75+
$config=$config | Add-AzHDInsightComponentVersion -ComponentName $componentName -ComponentVersion $componentVersion
76+
Assert-AreEqual $config.ComponentVersion[$componentName] $componentVersion
77+
78+
#test Add-AzHDInsightClusterIdentity
79+
$objectId=New-Guid
80+
$certificateFilePath="testhost:/testpath/"
81+
$certificatePassword="testpassword123@"
82+
$aadTenantId=New-Guid
83+
$config=$config | Add-AzHDInsightClusterIdentity -ObjectId $objectId -CertificateFilePath $certificateFilePath `
84+
-CertificatePassword $certificatePassword -AadTenantId $aadTenantId
85+
Assert-AreEqual $config.CertificatePassword $certificatePassword
86+
87+
#test Add-AzHDInsightSecurityProfile
88+
Assert-Null $config.SecurityProfile
89+
$domain = "sampledomain.onmicrosoft.com"
90+
$domainUser = "[email protected]"
91+
$domainPassword = ConvertTo-SecureString "domainPassword" -AsPlainText -Force
92+
$domainUserCredential = New-Object System.Management.Automation.PSCredential($domainUser, $domainPassword)
93+
$organizationalUnitDN = "ou=testunitdn"
94+
$ldapsUrls = ("ldaps://sampledomain.onmicrosoft.com:636","ldaps://sampledomain.onmicrosoft.com:389")
95+
$clusterUsersGroupDNs = ("groupdn1","groupdn2")
96+
$config = $config | Add-AzHDInsightSecurityProfile -Domain $domain -DomainUserCredential $domainUserCredential -OrganizationalUnitDN $organizationalUnitDN -LdapsUrls $ldapsUrls -ClusterUsersGroupDNs $clusterUsersGroupDNs
97+
Assert-AreEqual $config.SecurityProfile.Domain $domain
98+
Assert-NotNull $config.SecurityProfile.LdapsUrls
7199
}

0 commit comments

Comments
 (0)