Skip to content

Commit 213d06c

Browse files
idear1203mentat9
authored andcommitted
[HDInsight] - Update configurations (Azure#5683)
1 parent 78204c6 commit 213d06c

25 files changed

+1997
-890
lines changed

src/SDKs/HDInsight/Management/Management.HDInsight.Tests/ScenarioTests/ClusterOperationTests.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,5 +476,53 @@ public void TestResizeCluster()
476476
workerNode = cluster.Properties.ComputeProfile.Roles.First(role => role.Name == "workernode");
477477
Assert.Equal(workerNodeParams.TargetInstanceCount.Value + 1, workerNode.TargetInstanceCount);
478478
}
479+
480+
[Fact]
481+
public void TestGetOrUpdateGatewaySettings()
482+
{
483+
TestInitialize();
484+
485+
string clusterName = TestUtilities.GenerateName("hdisdk-gateway");
486+
var createParams = CommonData.PrepareClusterCreateParamsForWasb();
487+
var cluster = HDInsightClient.Clusters.Create(CommonData.ResourceGroupName, clusterName, createParams);
488+
ValidateCluster(clusterName, createParams, cluster);
489+
490+
string expectedUserName = CommonData.ClusterUserName;
491+
string expectedPassword = CommonData.ClusterPassword;
492+
var gatewaySettings = HDInsightClient.Clusters.GetGatewaySettings(CommonData.ResourceGroupName, clusterName);
493+
ValidateGatewaySettings(expectedUserName, expectedPassword, gatewaySettings);
494+
495+
// Disable gateway settings is not allowed.
496+
var updateParams = new UpdateGatewaySettingsParameters
497+
{
498+
IsCredentialEnabled = false
499+
};
500+
501+
try
502+
{
503+
HDInsightClient.Clusters.UpdateGatewaySettings(CommonData.ResourceGroupName, clusterName, updateParams);
504+
Assert.True(false, "Disable gateway settings should fail");
505+
}
506+
catch(ErrorResponseException ex)
507+
{
508+
Assert.Equal(HttpStatusCode.MethodNotAllowed, ex.Response.StatusCode);
509+
}
510+
511+
// Make sure anything stay unchanged after attempting to disable gateway settings.
512+
gatewaySettings = HDInsightClient.Clusters.GetGatewaySettings(CommonData.ResourceGroupName, clusterName);
513+
ValidateGatewaySettings(expectedUserName, expectedPassword, gatewaySettings);
514+
515+
string newExpectedPassword = "NewPassword1!";
516+
updateParams = new UpdateGatewaySettingsParameters
517+
{
518+
IsCredentialEnabled = true,
519+
UserName = expectedUserName,
520+
Password = newExpectedPassword
521+
};
522+
523+
HDInsightClient.Clusters.UpdateGatewaySettings(CommonData.ResourceGroupName, clusterName, updateParams);
524+
gatewaySettings = HDInsightClient.Clusters.GetGatewaySettings(CommonData.ResourceGroupName, clusterName);
525+
ValidateGatewaySettings(expectedUserName, newExpectedPassword, gatewaySettings);
526+
}
479527
}
480528
}

src/SDKs/HDInsight/Management/Management.HDInsight.Tests/ScenarioTests/ConfigurationOperationTests.cs

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void TestGetConfigurations()
1717
{
1818
TestInitialize();
1919

20-
string clusterName = TestUtilities.GenerateName("hdisdk-humboldt");
20+
string clusterName = TestUtilities.GenerateName("hdisdk-configs");
2121
var createParams = CommonData.PrepareClusterCreateParamsForWasb();
2222
var hiveConfig = new Dictionary<string, string>
2323
{
@@ -54,41 +54,20 @@ public void TestGetConfigurations()
5454
var yarn = HDInsightClient.Configurations.Get(CommonData.ResourceGroupName, clusterName, ConfigurationKey.YarnSite);
5555
Assert.Equal(yarnConfig, yarn);
5656

57-
var gateway = HDInsightClient.Configurations.Get(CommonData.ResourceGroupName, clusterName, ConfigurationKey.Gateway);
58-
Assert.Equal(3, gateway.Count);
59-
6057
var core = HDInsightClient.Configurations.Get(CommonData.ResourceGroupName, clusterName, ConfigurationKey.CoreSite);
6158
Assert.Equal(2, core.Count);
6259
Assert.True(core.ContainsKey(Constants.StorageConfigurations.DefaultFsKey));
6360
Assert.Contains(core, c => c.Key.StartsWith("fs.azure.account.key."));
64-
}
6561

66-
[Fact]
67-
public void TestHttpExtended()
68-
{
69-
TestInitialize();
70-
71-
string clusterName = TestUtilities.GenerateName("hdisdk-http");
72-
var createParams = CommonData.PrepareClusterCreateParamsForWasb();
73-
var cluster = HDInsightClient.Clusters.Create(CommonData.ResourceGroupName, clusterName, createParams);
74-
ValidateCluster(clusterName, createParams, cluster);
75-
76-
string expectedUserName = CommonData.ClusterUserName;
77-
string expectedPassword = CommonData.ClusterPassword;
78-
var httpSettings = HDInsightClient.Configurations.Get(CommonData.ResourceGroupName, clusterName, ConfigurationKey.Gateway);
79-
ValidateHttpSettings(expectedUserName, expectedPassword, httpSettings);
80-
81-
string newExpectedPassword = "NewPassword1!";
82-
var updateParams = new Dictionary<string, string>
83-
{
84-
{ "restAuthCredential.isEnabled", "true" },
85-
{ "restAuthCredential.username", expectedUserName },
86-
{ "restAuthCredential.password", newExpectedPassword }
87-
};
88-
89-
HDInsightClient.Configurations.Update(CommonData.ResourceGroupName, clusterName, ConfigurationKey.Gateway, updateParams);
90-
httpSettings = HDInsightClient.Configurations.Get(CommonData.ResourceGroupName, clusterName, ConfigurationKey.Gateway);
91-
ValidateHttpSettings(expectedUserName, newExpectedPassword, httpSettings);
62+
var configs = HDInsightClient.Configurations.List(CommonData.ResourceGroupName, clusterName);
63+
Assert.NotNull(configs);
64+
Assert.Equal(hiveConfig, configs.Configurations[ConfigurationKey.HiveSite]);
65+
Assert.Equal(mapredConfig, configs.Configurations[ConfigurationKey.MapRedSite]);
66+
Assert.Equal(yarnConfig, configs.Configurations[ConfigurationKey.YarnSite]);
67+
Assert.Equal(configurations[ConfigurationKey.Gateway], configs.Configurations[ConfigurationKey.Gateway]);
68+
Assert.Equal(2, core.Count);
69+
Assert.True(core.ContainsKey(Constants.StorageConfigurations.DefaultFsKey));
70+
Assert.Contains(core, c => c.Key.StartsWith("fs.azure.account.key."));
9271
}
9372
}
9473
}

0 commit comments

Comments
 (0)