Skip to content

Commit

Permalink
Merge pull request #1858 from ahosnyms/master
Browse files Browse the repository at this point in the history
Add ClusterTier to cluster create parameters
  • Loading branch information
Hovsep committed Mar 19, 2016
2 parents 1876eb0 + 741c650 commit d840494
Show file tree
Hide file tree
Showing 35 changed files with 19,466 additions and 6,086 deletions.
Expand Up @@ -35,6 +35,18 @@
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateHumboldtClusterWithSshUsernamePassword.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateLinuxClusterWithPremiumTier.json" >
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateLinuxClusterWithStandardTier.json" >
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateWindowsClusterWithPremiumTier.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateWindowsClusterWithStandardTier.json" >
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\HDInsight.Tests.CreateClusterTests\TestCreateWithEmptyParameters.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Expand Up @@ -57,5 +57,28 @@ public static string CreateResourceGroup(ResourceManagementClient resourcesClien

return rgname;
}

public static void WaitForClusterToMoveToRunning(string resourceGroup, string dnsName, HDInsightManagementClient hdInsightClient)
{
System.TimeSpan timeout = System.TimeSpan.FromMinutes(10);

var stopwatch = System.Diagnostics.Stopwatch.StartNew();
bool createError = false;
do
{
var cluster = hdInsightClient.Clusters.Get(resourceGroup, dnsName);

if (cluster.Cluster.Properties.ClusterState == "Error")
{
createError = true;
break;
}
if (cluster.Cluster.Properties.ClusterState == "Running") { return; }
System.Threading.Thread.Sleep(2000);
}
while (stopwatch.Elapsed < timeout);

Xunit.Assert.True(!createError);
}
}
}
Expand Up @@ -168,7 +168,7 @@ public void TestCustomCreateEnableDisableConnectivity()

var cluster = GetClusterSpecHelpers.GetCustomCreateParametersPaas();
const string dnsname = "hdisdk-testcluster1";

var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
Assert.Equal(dnsname, createresponse.Cluster.Name);

Expand All @@ -187,6 +187,117 @@ public void TestCustomCreateEnableDisableConnectivity()
}
}

[Fact]
public void TestCreateLinuxClusterWithPremiumTier()
{
var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };

using (var context = UndoContext.Current)
{
context.Start();

var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

var cluster = GetClusterSpecHelpers.GetCustomCreateParametersIaas();
cluster.ClusterTier= Tier.Premium;
const string dnsname = "hdisdk-LinuxClusterPremiumTest";

var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
Assert.Equal(dnsname, createresponse.Cluster.Name);

var clusterResponse = client.Clusters.Get(resourceGroup, dnsname);
Assert.Equal(createresponse.Cluster.Properties.ClusterTier , Tier.Premium);
HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client);
var result = client.Clusters.Delete(resourceGroup, dnsname);
Assert.Equal(result.StatusCode, HttpStatusCode.OK);
Assert.Equal(result.State, AsyncOperationState.Succeeded);
}
}

[Fact]
public void TestCreateLinuxClusterWithStandardTier()
{
var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };

using (var context = UndoContext.Current)
{
context.Start();

var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

var cluster = GetClusterSpecHelpers.GetCustomCreateParametersIaas();
cluster.ClusterTier = Tier.Standard;
const string dnsname = "hdisdk-LinuxClusterStandardTest";

var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);
Assert.Equal(dnsname, createresponse.Cluster.Name);

var clusterResponse = client.Clusters.Get(resourceGroup, dnsname);
Assert.Equal(createresponse.Cluster.Properties.ClusterTier, Tier.Standard);
HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client);
var result = client.Clusters.Delete(resourceGroup, dnsname);
Assert.Equal(result.StatusCode, HttpStatusCode.OK);
Assert.Equal(result.State, AsyncOperationState.Succeeded);
}
}

[Fact]
public void TestCreateWindowsClusterWithStandardTier()
{
var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };

using (var context = UndoContext.Current)
{
context.Start();

var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);

var cluster = GetClusterSpecHelpers.GetPaasClusterSpec();
cluster.Properties.ClusterTier = Tier.Standard;
const string dnsname = "hdisdk-IaasClusterStandardTierTest";

var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster);

Assert.Equal(dnsname, createresponse.Cluster.Name);
var clusterResponse = client.Clusters.Get(resourceGroup, dnsname);
Assert.Equal(createresponse.Cluster.Properties.ClusterTier, Tier.Standard);
HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client);
var result = client.Clusters.Delete(resourceGroup, dnsname);
Assert.Equal(result.StatusCode, HttpStatusCode.OK);
Assert.Equal(result.State, AsyncOperationState.Succeeded);
}
}

[Fact]
public void TestCreateWindowsClusterWithPremiumTier()
{
var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };
using (var context = UndoContext.Current)
{
context.Start();
var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler);
var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler);
var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient);
var cluster = GetClusterSpecHelpers.GetPaasClusterSpec();
cluster.Properties.ClusterTier = Tier.Premium;
const string dnsname = "hdisdk-WindowsClusterPremiumTest";
try
{
client.Clusters.Create(resourceGroup, dnsname, cluster);
}
catch (CloudException ex)
{
Assert.Equal(ex.Response.StatusCode, HttpStatusCode.BadRequest);
}
}
}

[Fact]
public void TestCreateHumboldtClusterWithSshUsernamePassword()
{
Expand Down
Expand Up @@ -33,8 +33,7 @@ public class DataLakeTests
private byte[] CertificateFileBytes = { };
private string CertificatePassword = "";
private string ResourceUri = "";



[Fact]
public void TestCreateDataLakeClusterUsingClusterCreateParametersExtended()
{
Expand Down Expand Up @@ -79,6 +78,7 @@ private ClusterCreateParametersExtended GetDataLakeClusterParametersExtended()
};

var spec = GetClusterSpecHelpers.AddConfigurations(cluster, ConfigurationKey.ClusterIdentity, dataLakeConfigs);
spec.Properties.ClusterVersion = "3.2";
return spec;
}

Expand Down
Expand Up @@ -65,7 +65,7 @@ public void TestDisableEnableRdp()
{
RdpSettings = new RdpSettings
{
ExpiryDate = new DateTime(2015, 10, 20),
ExpiryDate = new DateTime(2016, 10, 20),
Password = "Password1!",
UserName = "rdpuser"
}
Expand Down Expand Up @@ -128,7 +128,7 @@ public void TestDisableEnableRdpCustomCode()
cluster.Cluster.Properties.ConnectivityEndpoints.Any(
c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase)));

client.Clusters.EnableRdp(resourceGroup, dnsname, "rdpuser", "Password1!", new DateTime(2015, 10, 12));
client.Clusters.EnableRdp(resourceGroup, dnsname, "rdpuser", "Password1!", new DateTime(2016, 10, 12));
cluster = client.Clusters.Get(resourceGroup, dnsname);
Assert.True(
cluster.Cluster.Properties.ConnectivityEndpoints.Any(
Expand Down
Expand Up @@ -275,7 +275,7 @@ private ClusterCreateParameters CreateClusterToValidateScriptActions(string reso

client.Clusters.Create(resourceGroup, dnsName, clusterCreateParams);

WaitForClusterToMoveToRunning(resourceGroup, dnsName, client);
HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsName, client);

string storageAccountName =clusterCreateParams.DefaultStorageAccountName.Split('.')[0];

Expand All @@ -299,29 +299,7 @@ private ClusterCreateParameters CreateClusterToValidateScriptActions(string reso

return clusterCreateParams;
}

private void WaitForClusterToMoveToRunning(string resourceGroup, string dnsName, HDInsightManagementClient hdInsightClient)
{
TimeSpan timeout = TimeSpan.FromMinutes(10);

var stopwatch = Stopwatch.StartNew();
bool createError = false;
do
{
var cluster = hdInsightClient.Clusters.Get(resourceGroup, dnsName);

if (cluster.Cluster.Properties.ClusterState == "Error")
{
createError = true;
break;
}
if (cluster.Cluster.Properties.ClusterState =="Running") { return ; }
Thread.Sleep(2000);
}
while (stopwatch.Elapsed < timeout);

Assert.True(!createError);
}

}

}

0 comments on commit d840494

Please sign in to comment.