Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -476,5 +476,53 @@ public void TestResizeCluster()
workerNode = cluster.Properties.ComputeProfile.Roles.First(role => role.Name == "workernode");
Assert.Equal(workerNodeParams.TargetInstanceCount.Value + 1, workerNode.TargetInstanceCount);
}

[Fact]
public void TestGetOrUpdateGatewaySettings()
{
TestInitialize();

string clusterName = TestUtilities.GenerateName("hdisdk-gateway");
var createParams = CommonData.PrepareClusterCreateParamsForWasb();
var cluster = HDInsightClient.Clusters.Create(CommonData.ResourceGroupName, clusterName, createParams);
ValidateCluster(clusterName, createParams, cluster);

string expectedUserName = CommonData.ClusterUserName;
string expectedPassword = CommonData.ClusterPassword;
var gatewaySettings = HDInsightClient.Clusters.GetGatewaySettings(CommonData.ResourceGroupName, clusterName);
ValidateGatewaySettings(expectedUserName, expectedPassword, gatewaySettings);

// Disable gateway settings is not allowed.
var updateParams = new UpdateGatewaySettingsParameters
{
IsCredentialEnabled = false
};

try
{
HDInsightClient.Clusters.UpdateGatewaySettings(CommonData.ResourceGroupName, clusterName, updateParams);
Assert.True(false, "Disable gateway settings should fail");
}
catch(ErrorResponseException ex)
{
Assert.Equal(HttpStatusCode.MethodNotAllowed, ex.Response.StatusCode);
}

// Make sure anything stay unchanged after attempting to disable gateway settings.
gatewaySettings = HDInsightClient.Clusters.GetGatewaySettings(CommonData.ResourceGroupName, clusterName);
ValidateGatewaySettings(expectedUserName, expectedPassword, gatewaySettings);

string newExpectedPassword = "NewPassword1!";
updateParams = new UpdateGatewaySettingsParameters
{
IsCredentialEnabled = true,
UserName = expectedUserName,
Password = newExpectedPassword
};

HDInsightClient.Clusters.UpdateGatewaySettings(CommonData.ResourceGroupName, clusterName, updateParams);
gatewaySettings = HDInsightClient.Clusters.GetGatewaySettings(CommonData.ResourceGroupName, clusterName);
ValidateGatewaySettings(expectedUserName, newExpectedPassword, gatewaySettings);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void TestGetConfigurations()
{
TestInitialize();

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

var gateway = HDInsightClient.Configurations.Get(CommonData.ResourceGroupName, clusterName, ConfigurationKey.Gateway);
Assert.Equal(3, gateway.Count);

var core = HDInsightClient.Configurations.Get(CommonData.ResourceGroupName, clusterName, ConfigurationKey.CoreSite);
Assert.Equal(2, core.Count);
Assert.True(core.ContainsKey(Constants.StorageConfigurations.DefaultFsKey));
Assert.Contains(core, c => c.Key.StartsWith("fs.azure.account.key."));
}

[Fact]
public void TestHttpExtended()
{
TestInitialize();

string clusterName = TestUtilities.GenerateName("hdisdk-http");
var createParams = CommonData.PrepareClusterCreateParamsForWasb();
var cluster = HDInsightClient.Clusters.Create(CommonData.ResourceGroupName, clusterName, createParams);
ValidateCluster(clusterName, createParams, cluster);

string expectedUserName = CommonData.ClusterUserName;
string expectedPassword = CommonData.ClusterPassword;
var httpSettings = HDInsightClient.Configurations.Get(CommonData.ResourceGroupName, clusterName, ConfigurationKey.Gateway);
ValidateHttpSettings(expectedUserName, expectedPassword, httpSettings);

string newExpectedPassword = "NewPassword1!";
var updateParams = new Dictionary<string, string>
{
{ "restAuthCredential.isEnabled", "true" },
{ "restAuthCredential.username", expectedUserName },
{ "restAuthCredential.password", newExpectedPassword }
};

HDInsightClient.Configurations.Update(CommonData.ResourceGroupName, clusterName, ConfigurationKey.Gateway, updateParams);
httpSettings = HDInsightClient.Configurations.Get(CommonData.ResourceGroupName, clusterName, ConfigurationKey.Gateway);
ValidateHttpSettings(expectedUserName, newExpectedPassword, httpSettings);
var configs = HDInsightClient.Configurations.List(CommonData.ResourceGroupName, clusterName);
Assert.NotNull(configs);
Assert.Equal(hiveConfig, configs.Configurations[ConfigurationKey.HiveSite]);
Assert.Equal(mapredConfig, configs.Configurations[ConfigurationKey.MapRedSite]);
Assert.Equal(yarnConfig, configs.Configurations[ConfigurationKey.YarnSite]);
Assert.Equal(configurations[ConfigurationKey.Gateway], configs.Configurations[ConfigurationKey.Gateway]);
Assert.Equal(2, core.Count);
Assert.True(core.ContainsKey(Constants.StorageConfigurations.DefaultFsKey));
Assert.Contains(core, c => c.Key.StartsWith("fs.azure.account.key."));
}
}
}
Loading