diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj index 7dd9b8dea66c..85494aaf6eb3 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj +++ b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj @@ -52,7 +52,7 @@ False - ..\..\..\packages\Microsoft.Azure.Management.HDInsight.1.0.10-preview\lib\net40\Microsoft.Azure.Management.HDInsight.dll + ..\..\..\packages\Microsoft.Azure.Management.HDInsight.1.0.12-preview\lib\net40\Microsoft.Azure.Management.HDInsight.dll False @@ -163,6 +163,7 @@ + PreserveNewest diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/ScenarioTests/HDInsightConfigurationTests.ps1 b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/ScenarioTests/HDInsightConfigurationTests.ps1 index 7cca948a14d5..bbcd3ec8d246 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/ScenarioTests/HDInsightConfigurationTests.ps1 +++ b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/ScenarioTests/HDInsightConfigurationTests.ps1 @@ -18,9 +18,10 @@ Tests pipelining with creating the config #> function Test-ConfigurationPipelining{ - #test New-AzureRmHDInsightClusterConfig - $config = New-AzureRmHDInsightClusterConfig -ClusterType Hadoop + #test New-AzureRmHDInsightClusterConfig + $config = New-AzureRmHDInsightClusterConfig -ClusterType Hadoop -ClusterTier Standard Assert-NotNull $config.ClusterType + Assert-NotNull $config.ClusterTier #test Add-AzureRmHDInsightStorage Assert-AreEqual $config.AdditionalStorageAccounts.Count 0 diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/UnitTests/PremiumClusterTests.cs b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/UnitTests/PremiumClusterTests.cs new file mode 100644 index 000000000000..8b80c5d41ce9 --- /dev/null +++ b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/UnitTests/PremiumClusterTests.cs @@ -0,0 +1,140 @@ +// ---------------------------------------------------------------------------------- +// +// 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 System.Collections.Generic; +using System.Management.Automation; +using Microsoft.Azure.Commands.HDInsight.Models; +using Microsoft.Azure.Management.HDInsight.Models; +using Microsoft.WindowsAzure.Commands.Common; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Moq; +using Newtonsoft.Json; +using Xunit; + +namespace Microsoft.Azure.Commands.HDInsight.Test +{ + public class PremiumClusterTests : HDInsightTestBase + { + private NewAzureHDInsightClusterCommand cmdlet; + private const string StorageName = "PlaceStorageName"; + private const string StorageKey = "PlaceStorageKey"; + private const int ClusterSize = 4; + + private readonly PSCredential _httpCred; + + public PremiumClusterTests() + { + base.SetupTestsForManagement(); + _httpCred = new PSCredential("hadoopuser", string.Format("Password1!").ConvertToSecureString()); + cmdlet = new NewAzureHDInsightClusterCommand + { + CommandRuntime = commandRuntimeMock.Object, + HDInsightManagementClient = hdinsightManagementMock.Object + }; + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void CanCreateNewPremiumHDInsightCluster() + { + cmdlet.ClusterName = ClusterName; + cmdlet.ResourceGroupName = ResourceGroupName; + cmdlet.ClusterSizeInNodes = ClusterSize; + cmdlet.Location = Location; + cmdlet.HttpCredential = _httpCred; + cmdlet.DefaultStorageAccountName = StorageName; + cmdlet.DefaultStorageAccountKey = StorageKey; + cmdlet.ClusterType = ClusterType; + cmdlet.OSType = OSType.Linux; + cmdlet.ClusterTier = Tier.Premium; + cmdlet.SshCredential = _httpCred; + var cluster = new Cluster + { + Id = "id", + Name = ClusterName, + Location = Location, + Properties = new ClusterGetProperties + { + ClusterVersion = "3.2", + ClusterState = "Running", + ClusterDefinition = new ClusterDefinition + { + ClusterType = ClusterType + }, + QuotaInfo = new QuotaInfo + { + CoresUsed = 24 + }, + OperatingSystemType = OSType.Linux, + ClusterTier = Tier.Premium + } + }; + var coreConfigs = new Dictionary + { + {"fs.defaultFS", "wasb://giyertestcsmv2@" + StorageName}, + { + "fs.azure.account.key." + StorageName, + StorageKey + } + }; + var gatewayConfigs = new Dictionary + { + {"restAuthCredential.isEnabled", "true"}, + {"restAuthCredential.username", _httpCred.UserName}, + {"restAuthCredential.password", _httpCred.Password.ConvertToString()} + }; + + var configurations = new Dictionary> + { + {"core-site", coreConfigs}, + {"gateway", gatewayConfigs} + }; + var serializedConfig = JsonConvert.SerializeObject(configurations); + cluster.Properties.ClusterDefinition.Configurations = serializedConfig; + + var getresponse = new ClusterGetResponse {Cluster = cluster}; + + hdinsightManagementMock.Setup(c => c.CreateNewCluster(ResourceGroupName, ClusterName, It.Is( + parameters => + parameters.ClusterSizeInNodes == ClusterSize && + parameters.DefaultStorageAccountName == StorageName && + parameters.DefaultStorageAccountKey == StorageKey && + parameters.Location == Location && + parameters.UserName == _httpCred.UserName && + parameters.Password == _httpCred.Password.ConvertToString() && + parameters.SshUserName == _httpCred.UserName && + parameters.SshPassword == _httpCred.Password.ConvertToString() && + parameters.ClusterType == ClusterType && + parameters.OSType == OSType.Linux && + parameters.ClusterTier == Tier.Premium))) + .Returns(getresponse) + .Verifiable(); + + cmdlet.ExecuteCmdlet(); + + commandRuntimeMock.VerifyAll(); + commandRuntimeMock.Verify(f => f.WriteObject(It.Is( + clusterout => + clusterout.ClusterState == "Running" && + clusterout.ClusterType == ClusterType && + clusterout.ClusterVersion == "3.2" && + clusterout.CoresUsed == 24 && + clusterout.Location == Location && + clusterout.Name == ClusterName && + clusterout.OperatingSystemType == OSType.Linux && + clusterout.ClusterTier == Tier.Premium)), + Times.Once); + } + } +} diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config index a1beb06b0385..7d6b4ee1d8bc 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config +++ b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config @@ -6,7 +6,7 @@ - + diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj b/src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj index 1d2d6f3c37a5..21b54d9e3be6 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj @@ -123,7 +123,7 @@ False - ..\..\..\packages\Microsoft.Azure.Management.HDInsight.1.0.10-preview\lib\net40\Microsoft.Azure.Management.HDInsight.dll + ..\..\..\packages\Microsoft.Azure.Management.HDInsight.1.0.12-preview\lib\net40\Microsoft.Azure.Management.HDInsight.dll False diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/NewAzureHDInsightClusterCommand.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/NewAzureHDInsightClusterCommand.cs index 0f3aa9e5e652..aaaad6bb13cf 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/NewAzureHDInsightClusterCommand.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/NewAzureHDInsightClusterCommand.cs @@ -108,6 +108,7 @@ public AzureHDInsightConfig Config var result = new AzureHDInsightConfig { ClusterType = parameters.ClusterType, + ClusterTier = parameters.ClusterTier, DefaultStorageAccountName = parameters.DefaultStorageAccountName, DefaultStorageAccountKey = parameters.DefaultStorageAccountKey, WorkerNodeSize = parameters.WorkerNodeSize, @@ -140,6 +141,7 @@ var storageAccount in set { parameters.ClusterType = value.ClusterType; + parameters.ClusterTier = value.ClusterTier; if (parameters.DefaultStorageAccountName == null) { parameters.DefaultStorageAccountName = value.DefaultStorageAccountName; @@ -197,9 +199,9 @@ public string DefaultStorageContainer get { return parameters.DefaultStorageContainer; } set { parameters.DefaultStorageContainer = value; } } - + [Parameter(HelpMessage = "Gets or sets the version of the HDInsight cluster.")] - public string Version + public string Version { get { return parameters.Version; } set { parameters.Version = value; } @@ -213,7 +215,7 @@ public string HeadNodeSize } [Parameter(HelpMessage = "Gets or sets the size of the Data Node.")] - public string WorkerNodeSize + public string WorkerNodeSize { get { return parameters.WorkerNodeSize; } set { parameters.WorkerNodeSize = value; } @@ -254,6 +256,13 @@ public OSType OSType set { parameters.OSType = value; } } + [Parameter(HelpMessage = "Gets or sets the cluster tier for this HDInsight cluster.")] + public Tier ClusterTier + { + get { return parameters.ClusterTier; } + set { parameters.ClusterTier = value; } + } + [Parameter(HelpMessage = "Gets or sets SSH credential.")] public PSCredential SshCredential { get; set; } diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/NewAzureHDInsightClusterConfigCommand.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/NewAzureHDInsightClusterConfigCommand.cs index fff5f1dad2ae..a7e6f6f9c40b 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/NewAzureHDInsightClusterConfigCommand.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/NewAzureHDInsightClusterConfigCommand.cs @@ -32,7 +32,8 @@ public class NewAzureHDInsightClusterConfigCommand : HDInsightCmdletBase #region Input Parameter Definitions [Parameter(HelpMessage = "Gets or sets the StorageName for the default Azure Storage Account.")] - public string DefaultStorageAccountName { + public string DefaultStorageAccountName + { get { return _config.DefaultStorageAccountName; } set { _config.DefaultStorageAccountName = value; } } @@ -86,6 +87,14 @@ public string ClusterType set { _config.ClusterType = value; } } + [Parameter(HelpMessage = "Gets or sets the cluster tier for this HDInsight cluster.")] + public Tier ClusterTier + { + get { return _config.ClusterTier; } + set { _config.ClusterTier = value; } + } + + [Parameter(HelpMessage = "Gets or sets the Service Principal Object Id for accessing Azure Data Lake.")] public Guid ObjectId { diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Microsoft.Azure.Commands.HDInsight.dll-help.xml b/src/ResourceManager/HDInsight/Commands.HDInsight/Microsoft.Azure.Commands.HDInsight.dll-help.xml index 063ebebfe4cc..bffce5ba0f1f 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Microsoft.Azure.Commands.HDInsight.dll-help.xml +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Microsoft.Azure.Commands.HDInsight.dll-help.xml @@ -3065,6 +3065,13 @@ String + + ClusterTier + + The HDInsight cluster tier. By default, this is Standard. The Premium tier can only be used with Linux clusters, and it enables the use of some new features. + + Tier + VirtualNetworkId @@ -3387,6 +3394,13 @@ + + ClusterTier + + The HDInsight cluster tier. By default, this is Standard. The Premium tier can only be used with Linux clusters, and it enables the use of some new features. + + Tier + VirtualNetworkId @@ -3671,6 +3685,13 @@ String + + ClusterTier + + The HDInsight cluster tier. By default, this is Standard. The Premium tier can only be used with Linux clusters, and it enables the use of some new features. + + Tier + ObjectId @@ -3812,6 +3833,13 @@ + + ClusterTier + + The HDInsight cluster tier. By default, this is Standard. The Premium tier can only be used with Linux clusters, and it enables the use of some new features. + + Tier + ObjectId diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs index fc83c2d6f431..a111e95efcdb 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs @@ -29,6 +29,7 @@ public AzureHDInsightCluster(Cluster cluster) Location = cluster.Location; ClusterVersion = cluster.Properties.ClusterVersion; OperatingSystemType = cluster.Properties.OperatingSystemType; + ClusterTier = cluster.Properties.ClusterTier; ClusterState = cluster.Properties.ClusterState; ClusterType = cluster.Properties.ClusterDefinition.ClusterType; CoresUsed = cluster.Properties.QuotaInfo.CoresUsed; @@ -80,6 +81,11 @@ public AzureHDInsightCluster(Cluster cluster, IDictionary cluste /// public OSType OperatingSystemType { get; set; } + /// + /// Gets or sets the cluster tier. + /// + public Tier ClusterTier { get; set; } + /// /// The state of the cluster. /// @@ -123,6 +129,6 @@ public AzureHDInsightCluster(Cluster cluster, IDictionary cluste /// /// Additional storage accounts for this cluster /// - public List AdditionalStorageAccounts { get; set; } + public List AdditionalStorageAccounts { get; set; } } } diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightConfig.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightConfig.cs index d9e56704d13f..bcca5552896d 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightConfig.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightConfig.cs @@ -56,7 +56,12 @@ public class AzureHDInsightConfig /// Gets or sets the flavor for a cluster. /// public string ClusterType { get; set; } - + + /// + /// Gets or sets the cluster tier. + /// + public Tier ClusterTier { get; set; } + /// /// Gets or sets the database to store the metadata for Oozie. /// @@ -86,7 +91,7 @@ public class AzureHDInsightConfig /// Gets AAD tenant uri of the service principal /// public Guid AADTenantId { get; set; } - + /// /// Gets the configurations of this HDInsight cluster. /// diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/packages.config b/src/ResourceManager/HDInsight/Commands.HDInsight/packages.config index b6d866bda03f..06842e3d772e 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/packages.config +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/packages.config @@ -5,7 +5,7 @@ - +