//[Fact] public void TestInvalidResizeClusterOperations() { 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); const string dnsname = "hdisdk-resize2"; var spec = GetClusterSpecHelpers.GetPaasClusterSpec(); client.Clusters.Create(resourceGroup, dnsname, spec); ResizeWithMissingTargetInstanceCount(client, resourceGroup, dnsname); ResizeToSameInstanceCount(client, resourceGroup, dnsname); ResizeWithOngoingResize(client, resourceGroup, dnsname); } }
public void TestGetConfigCoreSiteCluster() { 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); const string dnsname = "hdisdk-configtest"; var spec = GetClusterSpecHelpers.GetPaasClusterSpec(); client.Clusters.Create(resourceGroup, dnsname, spec); var configs = client.Clusters.GetClusterConfigurations(resourceGroup, dnsname, "core-site"); Assert.Equal(2, configs.Configuration.Count); client.Clusters.Delete(resourceGroup, dnsname); } }
public void TestCreateDuplicateCluster() { 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(); const string dnsname = "hdisdk-clusterdupe"; var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster); Assert.Equal(dnsname, createresponse.Cluster.Name); try { client.Clusters.Create(resourceGroup, dnsname, cluster); } catch (CloudException ex) { Assert.Equal(ex.Response.StatusCode, HttpStatusCode.Conflict); } OperationResource result = client.Clusters.Delete(resourceGroup, dnsname); Assert.Equal(result.StatusCode, HttpStatusCode.OK); Assert.Equal(result.State, AsyncOperationState.Succeeded); } }
//[Fact] public void TestResizeCluster() { 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); const string dnsname = "hdisdk-resizetest"; var spec = GetClusterSpecHelpers.GetPaasClusterSpec(); client.Clusters.Create(resourceGroup, dnsname, spec); var cluster = client.Clusters.Get(resourceGroup, dnsname); var resizeParams = new ClusterResizeParameters { TargetInstanceCount = 2 }; client.Clusters.Resize(resourceGroup, dnsname, resizeParams); cluster = client.Clusters.Get(resourceGroup, dnsname); client.Clusters.Delete(resourceGroup, dnsname); } }
//[Fact] public void TestIaasCreateGetDeleteCluster() { 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.GetIaasClusterSpec(); const string dnsname = "hdisdk-iaascluster"; var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster); Assert.Equal(cluster.Location, createresponse.Cluster.Location); Assert.Equal(cluster.Properties.ClusterDefinition.ClusterType, createresponse.Cluster.Properties.ClusterDefinition.ClusterType); //Assert.Equal(cluster.Properties.ClusterVersion, createresponse.Cluster.Properties.ClusterVersion); Assert.Null(createresponse.Cluster.Properties.ClusterDefinition.Configurations); Assert.Equal(createresponse.StatusCode, HttpStatusCode.OK); var getresponse = client.Clusters.Get(resourceGroup, dnsname); Assert.Equal(createresponse.Cluster.Properties.ComputeProfile.Roles.Count, getresponse.Cluster.Properties.ComputeProfile.Roles.Count); Assert.Equal(createresponse.Cluster.Properties.CreatedDate, getresponse.Cluster.Properties.CreatedDate); var result = client.Clusters.Delete(resourceGroup, dnsname); Assert.Equal(result.StatusCode, HttpStatusCode.NoContent); } }
//[Fact] public void TestCustomCreateEnableDisableConnectivity() { 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.GetCustomCreateParametersPaas(); const string dnsname = "hdisdk-testcluster1"; var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster); Assert.Equal(dnsname, createresponse.Cluster.Name); var getresponse = client.Clusters.Get(resourceGroup, dnsname); client.Clusters.DisableHttp(resourceGroup, dnsname); getresponse = client.Clusters.Get(resourceGroup, dnsname); client.Clusters.EnableHttp(resourceGroup, dnsname, "hadoopuser", "Akasja2!1a"); getresponse = client.Clusters.Get(resourceGroup, dnsname); var result = client.Clusters.Delete(resourceGroup, dnsname); Assert.Equal(result.StatusCode, HttpStatusCode.OK); Assert.Equal(result.State, AsyncOperationState.Succeeded); } }
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); } }
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); } } }
public void TestAdJoinedIaasCreateGetDeleteCluster() { 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, "East US 2"); var cluster = GetClusterSpecHelpers.GetAdJoinedCreateParametersIaas(); const string dnsname = "hdisdk-adcluster"; var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster); Assert.Equal(cluster.Location, createresponse.Cluster.Location); Assert.Equal(cluster.ClusterType, createresponse.Cluster.Properties.ClusterDefinition.ClusterType); Assert.Null(createresponse.Cluster.Properties.ClusterDefinition.Configurations); Assert.Equal(createresponse.StatusCode, HttpStatusCode.OK); Assert.Equal(createresponse.Cluster.Properties.ProvisioningState, HDInsightClusterProvisioningState.Succeeded); Assert.Equal(createresponse.Cluster.Properties.ClusterState, "Running"); var getresponse = client.Clusters.Get(resourceGroup, dnsname); Assert.Equal(createresponse.Cluster.Properties.ComputeProfile.Roles.Count, getresponse.Cluster.Properties.ComputeProfile.Roles.Count); Assert.Equal(createresponse.Cluster.Properties.CreatedDate, getresponse.Cluster.Properties.CreatedDate); var result = client.Clusters.Delete(resourceGroup, dnsname); Assert.Equal(result.StatusCode, HttpStatusCode.OK); Assert.Equal(result.State, AsyncOperationState.Succeeded); } }
public void TestCreateLinuxSparkClusterWithComponentVersion() { 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.GetCustomCreateParametersSparkIaas(); cluster.ClusterTier = Tier.Standard; const string dnsname = "hdisdk-SparkLinuxClusterComponentVersionTest"; var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster); Assert.Equal(dnsname, createresponse.Cluster.Name); client.Clusters.Get(resourceGroup, dnsname); Assert.NotNull(createresponse.Cluster.Properties.ClusterDefinition.ComponentVersion); HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client); var result = client.Clusters.Delete(resourceGroup, dnsname); Assert.Equal(result.StatusCode, HttpStatusCode.OK); Assert.Equal(result.State, AsyncOperationState.Succeeded); } }
public void TestCreateHumboldtClusterWithSshUsernamePassword() { 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(); const string dnsname = "hdisdk-iaasclusternew"; var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster); Assert.Equal(dnsname, createresponse.Cluster.Name); client.Clusters.Get(resourceGroup, dnsname); var result = client.Clusters.Delete(resourceGroup, dnsname); Assert.Equal(result.StatusCode, HttpStatusCode.OK); Assert.Equal(result.State, AsyncOperationState.Succeeded); } }
public void TestDisableEnableHttpCustomCode() { 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); const string dnsname = "hdisdk-httptest3"; var spec = GetClusterSpecHelpers.GetPaasClusterSpec(); client.Clusters.Create(resourceGroup, dnsname, spec); var httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname); Assert.True(httpSettings.HttpUserEnabled); client.Clusters.DisableHttp(resourceGroup, dnsname); httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname); Assert.False(httpSettings.HttpUserEnabled); client.Clusters.EnableHttp(resourceGroup, dnsname, "admin", "Password1!"); httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname); Assert.True(httpSettings.HttpUserEnabled); client.Clusters.Delete(resourceGroup, dnsname); } }
private ClusterCreateParameters CreateClusterToValidateScriptActions(string resourceGroup, string dnsName, HDInsightManagementClient client) { var clusterCreateParams = GetClusterSpecHelpers.GetCustomCreateParametersIaas(); client.Clusters.Create(resourceGroup, dnsName, clusterCreateParams); HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsName, client); // upload only in record mode if (HDInsightManagementTestUtilities.IsRecordMode()) { //upload failing script to the cluster default storage account var defaultStorageAccount = clusterCreateParams.DefaultStorageInfo as AzureStorageInfo; var storageAccountName = defaultStorageAccount.StorageAccountName.Split('.')[0]; var creds = new StorageCredentials(storageAccountName, defaultStorageAccount.StorageAccountKey); var storageAccount = new CloudStorageAccount(creds, true); var blobClient = storageAccount.CreateCloudBlobClient(); var container = blobClient.GetContainerReference(FailingScriptLocationContainer); container.CreateIfNotExists(); var blockBlob = container.GetBlockBlobReference("failingscriptaction.sh"); using (var fileStream = System.IO.File.OpenRead(@"TestData/FailingScriptAction.sh")) { blockBlob.UploadFromStream(fileStream); } } return(clusterCreateParams); }
/// <summary> /// ClusterCreateParameters used for DataLake additional FS /// </summary> /// <returns></returns> private ClusterCreateParameters GetDataLakeClusterParameters() { var clusterCreateParams = GetClusterSpecHelpers.GetCustomCreateParametersPaas(); clusterCreateParams.Principal = new ServicePrincipal(new Guid(ApplicationId), new Guid(AadTenantId), CertificateFileBytes, CertificatePassword); return(clusterCreateParams); }
public void TestEnableDisableDisableHttp() { 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); const string dnsname = "hdisdk-httptest3"; var spec = GetClusterSpecHelpers.GetPaasClusterSpec(); var cluster = client.Clusters.Create(resourceGroup, dnsname, spec); string errorMessage = cluster.Cluster.Properties.ErrorInfos.Any() ? cluster.Cluster.Properties.ErrorInfos[0].Message : String.Empty; Assert.True(cluster.Cluster.Properties.ClusterState.Equals("Running", StringComparison.OrdinalIgnoreCase), String.Format("Cluster Creation Failed ErrorInfo: {0}", errorMessage)); HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client); var httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname); Assert.True(httpSettings.HttpUserEnabled); var httpParams = new HttpSettingsParameters { HttpUserEnabled = false, }; client.Clusters.ConfigureHttpSettings(resourceGroup, dnsname, httpParams); httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname); Assert.False(httpSettings.HttpUserEnabled); client.Clusters.ConfigureHttpSettings(resourceGroup, dnsname, httpParams); httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname); Assert.False(httpSettings.HttpUserEnabled); client.Clusters.Delete(resourceGroup, dnsname); } }
public void TestCreateLinuxDevSkuCluster() { string clusterName = "hdisdk-SandboxLinuxClusterTest"; var clusterCreateParams = GetClusterSpecHelpers.GetCustomCreateParametersIaas(); clusterCreateParams.ClusterType = "Sandbox"; clusterCreateParams.Version = "3.5"; ClusterOperations op = new ClusterOperations(new HDInsightManagementClient()); var extendedParams = op.GetExtendedClusterCreateParameters(clusterName, clusterCreateParams); Assert.Equal(extendedParams.Properties.ComputeProfile.Roles.Count, 1); Assert.Equal(extendedParams.Properties.ComputeProfile.Roles[0].HardwareProfile.VmSize, "Standard_D13_V2"); Assert.Equal(extendedParams.Properties.ComputeProfile.Roles[0].Name, "headnode"); Assert.Equal(extendedParams.Properties.ComputeProfile.Roles[0].TargetInstanceCount, 1); }
private ClusterCreateParametersExtended GetDataLakeClusterParametersExtended() { var cluster = GetClusterSpecHelpers.GetPaasClusterSpec(); var dataLakeConfigs = new Dictionary <string, string> { { "clusterIdentity.applicationId", ApplicationId }, { "clusterIdentity.aadTenantId", AadTenantId }, { "clusterIdentity.certificate", Convert.ToBase64String(CertificateFileBytes) }, { "clusterIdentity.certificatePassword", CertificatePassword }, { "clusterIdentity.resourceUri", ResourceUri } }; var spec = GetClusterSpecHelpers.AddConfigurations(cluster, ConfigurationKey.ClusterIdentity, dataLakeConfigs); return(spec); }
public void TestCreateRserverEdgeNodeSpecified() { const string edgeNodeSizeToTest = "Standard_D12_v2"; var clusterCreateParams = GetClusterSpecHelpers.GetCustomCreateParametersIaas(); clusterCreateParams.ClusterType = "RServer"; clusterCreateParams.EdgeNodeSize = edgeNodeSizeToTest; clusterCreateParams.Version = "3.5"; ClusterOperations op = new ClusterOperations(new HDInsightManagementClient()); var extendedParams = op.GetExtendedClusterCreateParameters("hdisdk-RServerClusterEdgeNodeSpecifiedTest", clusterCreateParams); List <Role> roles = new List <Role>(extendedParams.Properties.ComputeProfile.Roles); ValidateRole(roles, "edgenode", edgeNodeSizeToTest, 1); }
public void TestEnableEnableHttp() { 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); const string dnsname = "hdisdk-httptest3"; var spec = GetClusterSpecHelpers.GetPaasClusterSpec(); client.Clusters.Create(resourceGroup, dnsname, spec); var httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname); Assert.True(httpSettings.HttpUserEnabled); var httpParams = new HttpSettingsParameters { HttpUserEnabled = true, HttpUsername = "******", HttpPassword = "******" }; try { client.Clusters.ConfigureHttpSettings(resourceGroup, dnsname, httpParams); } catch (CloudException ex) { Assert.Equal(ex.Response.StatusCode, HttpStatusCode.Conflict); } httpSettings = client.Clusters.GetConnectivitySettings(resourceGroup, dnsname); Assert.True(httpSettings.HttpUserEnabled); var result = client.Clusters.Delete(resourceGroup, dnsname); //Assert.Equal(result.StatusCode, HttpStatusCode.NoContent); } }
public void TestDisableEnableRdpCustomCode() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (var context = UndoContext.Current) { context.Start(); //get clients var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler); var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler); //create resourcegroup var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient); //set variables const string dnsname = "hdisdk-rdpcluster0"; var spec = GetClusterSpecHelpers.GetPaasClusterSpec(); //test var cluster = client.Clusters.Create(resourceGroup, dnsname, spec); Assert.True( cluster.Cluster.Properties.ConnectivityEndpoints.Any( c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase))); HDInsightManagementTestUtilities.WaitForClusterToMoveToRunning(resourceGroup, dnsname, client); client.Clusters.DisableRdp(resourceGroup, dnsname); cluster = client.Clusters.Get(resourceGroup, dnsname); Assert.False( cluster.Cluster.Properties.ConnectivityEndpoints.Any( c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase))); client.Clusters.EnableRdp(resourceGroup, dnsname, "rdpuser", "Password1!", new DateTime(2018, 10, 12)); cluster = client.Clusters.Get(resourceGroup, dnsname); Assert.True( cluster.Cluster.Properties.ConnectivityEndpoints.Any( c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase))); client.Clusters.Delete(resourceGroup, dnsname); } }
public void TestCreateRserverDefaultNodeSizesValues() { var clusterCreateParams = GetClusterSpecHelpers.GetCustomCreateParametersIaas(); clusterCreateParams.ClusterType = "RServer"; clusterCreateParams.Version = "3.5"; clusterCreateParams.WorkerNodeSize = null; clusterCreateParams.HeadNodeSize = null; ClusterOperations op = new ClusterOperations(new HDInsightManagementClient()); var extendedParams = op.GetExtendedClusterCreateParameters("hdisdk-RServerClusterEdgeNodeDefaultTest", clusterCreateParams); List <Role> roles = new List <Role>(extendedParams.Properties.ComputeProfile.Roles); ValidateRole(roles, "headnode", "Standard_D12_v2"); ValidateRole(roles, "workernode", "Standard_D4_v2", clusterCreateParams.ClusterSizeInNodes); ValidateRole(roles, "edgenode", "Standard_D4_v2", 1); ValidateRole(roles, "zookeepernode", "Medium"); }
//[Fact] public void TestListClustersByResourceGroup() { 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 resourceGroup1 = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient); var resourceGroup2 = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient); const string dnsname1 = "hdisdk-paas01"; const string dnsname2 = "hdisdk-paas02"; const string dnsname3 = "hdisdk-paas03"; var paasSpec = GetClusterSpecHelpers.GetPaasClusterSpec(); Parallel.Invoke( () => client.Clusters.Create(resourceGroup1, dnsname1, paasSpec), () => client.Clusters.Create(resourceGroup1, dnsname2, paasSpec), () => client.Clusters.Create(resourceGroup2, dnsname3, paasSpec) ); var listresponse1 = client.Clusters.ListByResourceGroup(resourceGroup1); //Assert.Equal(listresponse1.Clusters.Count, 2); //Assert.True(listresponse1.Clusters.Any(c => c.Name.Equals(dnsname1))); //Assert.True(listresponse1.Clusters.Any(c => c.Name.Equals(dnsname2))); var listresponse2 = client.Clusters.ListByResourceGroup(resourceGroup2); //Assert.Equal(listresponse2.Clusters.Count, 1); //Assert.True(listresponse2.Clusters.Any(c => c.Name.Equals(dnsname3))); client.Clusters.Delete(resourceGroup1, dnsname1); client.Clusters.Delete(resourceGroup1, dnsname2); client.Clusters.Delete(resourceGroup2, dnsname3); } }
public void TestPaasCreateGetDeleteCluster() { 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(); const string dnsname = "hdisdk-paas"; var createresponse = client.Clusters.Create(resourceGroup, dnsname, cluster); Assert.Equal(dnsname, createresponse.Cluster.Name); Assert.Equal(cluster.Location, createresponse.Cluster.Location); Assert.Equal(cluster.Properties.OperatingSystemType, createresponse.Cluster.Properties.OperatingSystemType); Assert.Equal(createresponse.Cluster.Properties.ErrorInfos.Count, 0); Assert.Equal(cluster.Properties.ClusterDefinition.ClusterType, createresponse.Cluster.Properties.ClusterDefinition.ClusterType); Assert.Equal(cluster.Properties.ClusterVersion, createresponse.Cluster.Properties.ClusterVersion.Substring(0, 3)); Assert.Null(createresponse.Cluster.Properties.ClusterDefinition.Configurations); var getresponse = client.Clusters.Get(resourceGroup, dnsname); Assert.Equal(createresponse.Cluster.Properties.CreatedDate, getresponse.Cluster.Properties.CreatedDate); Assert.Equal(createresponse.Cluster.Name, getresponse.Cluster.Name); var result = client.Clusters.Delete(resourceGroup, dnsname); Assert.Equal(result.StatusCode, HttpStatusCode.OK); Assert.Equal(result.State, AsyncOperationState.Succeeded); } }
public void TestDisableEnableRdp() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (var context = UndoContext.Current) { context.Start(); //get clients var client = HDInsightManagementTestUtilities.GetHDInsightManagementClient(handler); var resourceManagementClient = HDInsightManagementTestUtilities.GetResourceManagementClient(handler); //create resourcegroup var resourceGroup = HDInsightManagementTestUtilities.CreateResourceGroup(resourceManagementClient); //set variables const string dnsname = "hdisdk-rdp1"; var spec = GetClusterSpecHelpers.GetPaasClusterSpec(); var rdpdisable = new RDPSettingsParameters { OsProfile = new OsProfile { WindowsOperatingSystemProfile = new WindowsOperatingSystemProfile { RdpSettings = null } } }; var rdpenable = new RDPSettingsParameters { OsProfile = new OsProfile { WindowsOperatingSystemProfile = new WindowsOperatingSystemProfile { RdpSettings = new RdpSettings { ExpiryDate = new DateTime(2016, 10, 20), Password = "******", UserName = "******" } } } }; //test var cluster = client.Clusters.Create(resourceGroup, dnsname, spec); //Assert.True( // cluster.Cluster.Properties.ConnectivityEndpoints.Any( // c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase))); client.Clusters.ConfigureRdpSettings(resourceGroup, dnsname, rdpdisable); cluster = client.Clusters.Get(resourceGroup, dnsname); Assert.False( cluster.Cluster.Properties.ConnectivityEndpoints.Any( c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase))); client.Clusters.ConfigureRdpSettings(resourceGroup, dnsname, rdpenable); cluster = client.Clusters.Get(resourceGroup, dnsname); Assert.True( cluster.Cluster.Properties.ConnectivityEndpoints.Any( c => c.Name.Equals("RDP", StringComparison.OrdinalIgnoreCase))); client.Clusters.Delete(resourceGroup, dnsname); } }