public void GetSchemaVersionsTest() { var capabilities = new List <string> { "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_1_SDK", "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_2_SDK", "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_VERSION_3_SDK" }; var schemaVersion = SchemaVersionUtils.GetSchemaVersion(capabilities); Assert.AreEqual(schemaVersion, "3.0"); capabilities = new List <string> { "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_1_SDK", "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_2_SDK", }; schemaVersion = SchemaVersionUtils.GetSchemaVersion(capabilities); Assert.AreEqual(schemaVersion, "2.0"); capabilities = new List <string> { "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_1_SDK", "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_VERSION_4_SDK", }; schemaVersion = SchemaVersionUtils.GetSchemaVersion(capabilities); Assert.AreEqual(schemaVersion, "1.0"); }
/// <inheritdoc /> public async Task <ClusterDetails> ChangeClusterSizeAsync(string dnsName, string location, int newSize, TimeSpan timeout) { dnsName.ArgumentNotNullOrEmpty("dnsName"); newSize.ArgumentNotNull("newSize"); location.ArgumentNotNull("location"); SchemaVersionUtils.EnsureSchemaVersionSupportsResize(this.capabilities.Value); var client = this.CreateClustersPocoClient(this.capabilities.Value); var operationId = Guid.Empty; try { this.LogMessage("Sending Change Cluster Size request.", Severity.Informational, Verbosity.Detailed); operationId = await client.ChangeClusterSize(dnsName, location, newSize); } catch (Exception ex) { this.LogMessage(ex.GetFirstException().Message, Severity.Error, Verbosity.Detailed); throw ex.GetFirstException(); } if (operationId == Guid.Empty) { return(await client.ListContainer(dnsName)); } await client.WaitForOperationCompleteOrError(dnsName, location, operationId, this.PollingInterval, timeout, this.Context.CancellationToken); await client.WaitForClusterInConditionOrError(this.HandleClusterWaitNotifyEvent, dnsName, location, timeout, this.PollingInterval, this.Context, ClusterState.Operational, ClusterState.Running); this.LogMessage("Validating that the cluster didn't go into an error state.", Severity.Informational, Verbosity.Detailed); var result = await client.ListContainer(dnsName); if (result == null) { throw new Exception(string.Format("Cluster {0} could not be found.", dnsName)); } if (result.Error != null) { this.LogMessage(result.Error.Message, Severity.Informational, Verbosity.Detailed); throw new Exception(result.Error.Message); } return(result); }
public void GetSubscriptionSchemaVersionsTest() { var capabilities = new List <string> { "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_1_SDK", "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_2_SDK", "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_VERSION_3_SDK" }; var schemaVersions = SchemaVersionUtils.GetSchemaVersionsForSubscription(capabilities); Assert.AreEqual(schemaVersions.Count, 3); capabilities = new List <string> { "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_1_SDK", "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_2_SDK", "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_VERSION_3_SDK", "CAPABILITY_FEATURE_CLUSTERS_CONTRACT_VERSION_4_SDK_blah", "fake" }; schemaVersions = SchemaVersionUtils.GetSchemaVersionsForSubscription(capabilities); Assert.AreEqual(schemaVersions.Count, 3); }
public void CanListCloudServicesEmpty() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); using (var paasClustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient)) { var containersList = paasClustersPocoClient.ListContainers().Result; Assert.AreEqual(containersList.Count, 0); } }
public async Task CannotResizeClusterToLessThanOne() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); var paasClustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient); CreateCluster("testcluster", "West US"); var cluster = paasClustersPocoClient.ListContainer("testcluster").Result; var originalInstanceCount = cluster.ClusterSizeInNodes; Assert.AreEqual(cluster.ClusterSizeInNodes, originalInstanceCount); try { await paasClustersPocoClient.ChangeClusterSize("testcluster", cluster.Location, 0); } catch (ArgumentOutOfRangeException ex) { Assert.IsNotNull(ex); Assert.AreEqual(ex.ParamName, "newSize"); } }
public async Task CannotResizeClusterWithoutCapability() { var capabilities = new List <string>(); capabilities.Add("CAPABILITY_FEATURE_CLUSTERS_CONTRACT_1_SDK"); var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(capabilities)); var paasClustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, capabilities, restClient); CreateCluster("testcluster", "West US"); try { await paasClustersPocoClient.ChangeClusterSize("testcluster", "West US", 100); } catch (NotSupportedException ex) { Assert.IsNotNull(ex); } }
public async Task ResizeToSameSizeReturnsEmptyGuidOperationId() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); var paasClustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient); CreateCluster("testcluster", "West US"); var cluster = paasClustersPocoClient.ListContainer("testcluster").Result; var originalInstanceCount = cluster.ClusterSizeInNodes; var operationId = await paasClustersPocoClient.ChangeClusterSize("testcluster", cluster.Location, originalInstanceCount); Assert.AreEqual(operationId, Guid.Empty); }
/// <inheritdoc /> public async Task <Guid> ChangeClusterSize(string dnsName, string location, int newSize) { if (string.IsNullOrEmpty(dnsName)) { throw new ArgumentNullException("dnsName", "The dns name cannot be null or empty."); } if (newSize < 1) { throw new ArgumentOutOfRangeException("newSize", "The new node count must be at least 1."); } try { var clusterResult = string.IsNullOrEmpty(location) ? await this.GetCluster(dnsName) : await this.GetCluster(dnsName, location); var cloudServiceName = this.GetCloudServiceName(clusterResult.ClusterDetails.Location); var cluster = clusterResult.ResultOfGetClusterCall; SchemaVersionUtils.EnsureSchemaVersionSupportsResize(this.capabilities); if (cluster.ClusterCapabilities == null || !cluster.ClusterCapabilities.Contains(ResizeCapabilityEnabled, StringComparer.OrdinalIgnoreCase)) { throw new NotSupportedException( "This cluster does not support a change cluster size operation. Please drop and recreate the cluster to enable this operation."); } var clusterRoleCollection = cluster.ClusterRoleCollection; var workerRole = clusterRoleCollection.SingleOrDefault(role => role.FriendlyName.Equals("WorkerNodeRole")); if (workerRole == null) { throw new NullReferenceException("The cluster does not contain a worker node role."); } if (workerRole.InstanceCount == newSize) { return(Guid.Empty); } workerRole.InstanceCount = newSize; this.LogMessage("Sending passthrough request to RDFE", Severity.Informational, Verbosity.Detailed); var resp = this.SafeGetDataFromPassthroughResponse <Operation>( await this.rdfeClustersRestClient.ChangeClusterSize( this.credentials.SubscriptionId.ToString(), cloudServiceName, this.credentials.DeploymentNamespace, dnsName, ResizeRoleAction, clusterRoleCollection, this.Context.CancellationToken)); var operationId = Guid.Parse(resp.OperationId); if (resp.Status.Equals(OperationStatus.Failed)) { var message = string.Format("ChangeClusterSize operation with operation ID {0} failed with the following response:\n{1}", operationId, resp.ErrorDetails.ErrorMessage); this.LogMessage(message, Severity.Error, Verbosity.Detailed); throw new InvalidOperationException(message); } return(operationId); } catch (InvalidExpectedStatusCodeException iEx) { this.LogException(iEx); string content = iEx.Response.Content != null?iEx.Response.Content.ReadAsStringAsync().Result : string.Empty; throw new HttpLayerException(iEx.ReceivedStatusCode, content); } }
public void CanListCloudServicesWithDuplicateNames() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); using (var paasClustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient)) { CreateCluster("testcluster1", "West US"); CreateCluster("testcluster1", "East US"); var containersList = paasClustersPocoClient.ListContainers().Result; Assert.AreEqual(containersList.Count, 2); Assert.IsNotNull(containersList.SingleOrDefault(cluster => cluster.Name.Equals("testcluster1") && cluster.Location.Equals("West US"))); Assert.IsNotNull(containersList.SingleOrDefault(cluster => cluster.Name.Equals("testcluster1") && cluster.Location.Equals("East US"))); } }
public async Task ICanCreateACluster_WithVmSizes_All_Specified_NonHBase_Negative() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); var clustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient); try { var clusterCreateParameters = new HDInsight.ClusterCreateParametersV2 { Name = "ConfigActionTest", DefaultStorageAccountKey = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Key, DefaultStorageAccountName = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Name, DefaultStorageContainer = "ConfigActionTest", ClusterSizeInNodes = 2, Location = "East US", UserName = "******", Password = "******", Version = "3.1", HeadNodeSize = "ExtraLarge", DataNodeSize = "Large", ZookeeperNodeSize = "Medium", ClusterType = ClusterType.Spark, }; // Add in valid config action. clusterCreateParameters.ConfigActions.Add(new ScriptAction("TestScriptAction", new ClusterNodeType[] { ClusterNodeType.HeadNode }, new Uri("http://www.microsoft.com"), null)); await clustersPocoClient.CreateContainer(clusterCreateParameters); //this should not work for non hbase clusters Assert.Fail("Zookeeper node size should not be settable for non-hbase clusters"); } catch (ArgumentException aex) { Assert.AreEqual(aex.Message, "clusterCreateParameters.ZookeeperNodeSize must be null for Spark clusters."); } }
public async Task CanCreateRdpUserDuringClusterCreate() { Capabilities.Add("CAPABILITY_FEATURE_CLUSTERS_CONTRACT_1_SDK"); Capabilities.Add("CAPABILITY_FEATURE_CLUSTERS_CONTRACT_VERSION_3_SDK"); var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); var clusterDnsName = "rdpTestCluster"; var clustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient); var clusterCreateParameters = new HDInsight.ClusterCreateParametersV2 { Name = clusterDnsName, DefaultStorageAccountKey = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Key, DefaultStorageAccountName = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Name, DefaultStorageContainer = "EnableDisableRdpTest", ClusterSizeInNodes = 2, Location = "East US", UserName = "******", Password = "******", Version = "3.1", ClusterType = ClusterType.Hadoop, RdpUsername = "******", RdpPassword = "******", RdpAccessExpiry = DateTime.Now.AddDays(6) }; await clustersPocoClient.CreateContainer(clusterCreateParameters); var cluster = clustersPocoClient.ListContainer(clusterDnsName).Result; var rdpUsername = "******"; var actualRdpUserName = cluster.RdpUserName; Assert.AreEqual(rdpUsername, actualRdpUserName); await clustersPocoClient.DisableRdp(clusterDnsName, cluster.Location); cluster = clustersPocoClient.ListContainer(clusterDnsName).Result; Assert.IsNull(cluster.RdpUserName); await clustersPocoClient.DeleteContainer(cluster.Name, cluster.Location); }
public void CanDeleteCloudServiceWithRegionWithDuplicateNames() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); using (var paasClustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient)) { CreateCluster("testcluster1", "West US"); CreateCluster("testcluster1", "East US"); var containersList = paasClustersPocoClient.ListContainers().Result; Assert.AreEqual(containersList.Count, 2); // Now delete cluster without region name and both should be deleted paasClustersPocoClient.DeleteContainer("testcluster1", "West US"); containersList = paasClustersPocoClient.ListContainers().Result; Assert.AreEqual(containersList.Count, 1); Assert.IsNotNull(paasClustersPocoClient.ListContainer("testcluster1", "East US")); Assert.IsNotNull(paasClustersPocoClient.ListContainer("testcluster1", "East US").Result.Location.Equals("East US")); } }
public void CanDeleteCloudServicesWithDuplicateNames() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); using (var paasClustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient)) { CreateCluster("testcluster1", "West US"); CreateCluster("testcluster1", "East US"); var containersList = paasClustersPocoClient.ListContainers().Result; Assert.AreEqual(containersList.Count, 2); // Now delete cluster without region name and both should be deleted try { paasClustersPocoClient.DeleteContainer("testcluster1").Wait(); Assert.Fail("Exception not thrown"); } catch (AggregateException age) { Assert.IsTrue(age.InnerException != null, "Inner exception is not null"); Assert.IsTrue(age.InnerException is InvalidOperationException, "Exception is not InvalidOperationException"); Assert.AreEqual("Multiple clusters found with dnsname 'testcluster1'. Please specify dnsname and location", age.InnerException.Message, "Message not as expected"); } containersList = paasClustersPocoClient.ListContainers().Result; Assert.AreEqual(containersList.Count, 2); } }
internal PaasClustersPocoClient(IHDInsightSubscriptionCredentials credentials, bool ignoreSslErrors, IAbstractionContext context, List <string> capabilities) : this(credentials, ignoreSslErrors, context, capabilities, ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>().Create(credentials, context, ignoreSslErrors, SchemaVersionUtils.GetSchemaVersion(capabilities))) { }
public async Task CanCreateClusterWithHwxPrivateVersion() { Capabilities.Add("CAPABILITY_FEATURE_CLUSTERS_CONTRACT_1_SDK"); Capabilities.Add("CAPABILITY_FEATURE_CLUSTERS_CONTRACT_VERSION_3_SDK"); var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); var clustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient); var clusterCreateParameters = new HDInsight.ClusterCreateParametersV2 { Name = "HwxVersionTest", DefaultStorageAccountKey = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Key, DefaultStorageAccountName = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Name, DefaultStorageContainer = "HwxVersionTest", ClusterSizeInNodes = 2, Location = "East US", UserName = "******", Password = "******", Version = "3.2-hwx-trunk", ClusterType = ClusterType.Hadoop, }; await clustersPocoClient.CreateContainer(clusterCreateParameters); var containersList = clustersPocoClient.ListContainers().Result; Assert.AreEqual(containersList.Count, 1); Assert.IsNotNull(containersList.SingleOrDefault(cluster => cluster.Name.Equals("HwxVersionTest"))); }
public async Task ICanCreateACluster_WithOldVmSizes_All_Specified() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); var clustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient); try { var clusterCreateParameters = new HDInsight.ClusterCreateParametersV2 { Name = "ConfigActionTest", DefaultStorageAccountKey = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Key, DefaultStorageAccountName = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Name, DefaultStorageContainer = "ConfigActionTest", ClusterSizeInNodes = 2, Location = "East US", UserName = "******", Password = "******", Version = "3.1", HeadNodeSize = "ExtraLarge", DataNodeSize = "Large", ZookeeperNodeSize = "Medium", ClusterType = ClusterType.HBase, }; // Add in valid config action. clusterCreateParameters.ConfigActions.Add(new ScriptAction("TestScriptAction", new ClusterNodeType[] { ClusterNodeType.HeadNode }, new Uri("http://www.microsoft.com"), null)); await clustersPocoClient.CreateContainer(clusterCreateParameters); } catch (NotSupportedException ex) { Assert.IsNotNull(ex); } }
public async Task CanCannotClusterCreateWithInvalidRdpCredentials() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); var clusterDnsName = "rdpTestCluster"; var clustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient); var clusterCreateParameters = new HDInsight.ClusterCreateParametersV2 { Name = clusterDnsName, DefaultStorageAccountKey = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Key, DefaultStorageAccountName = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Name, DefaultStorageContainer = "EnableDisableRdpTest", ClusterSizeInNodes = 2, Location = "East US", UserName = "******", Password = "******", Version = "3.1", ClusterType = ClusterType.Hadoop, RdpUsername = "", RdpPassword = "******", RdpAccessExpiry = DateTime.Now.AddDays(6) }; try { await clustersPocoClient.CreateContainer(clusterCreateParameters); throw new Exception("CreateContainer should have thrown an ArgumentException"); } catch (ArgumentException exp) { Assert.AreEqual(exp.Message, @"clusterCreateParameters.RdpUsername cannot be null or empty in case either RdpPassword or RdpAccessExpiry is specified Parameter name: clusterCreateParameters"); } clusterCreateParameters.RdpUsername = "******"; clusterCreateParameters.RdpPassword = ""; try { await clustersPocoClient.CreateContainer(clusterCreateParameters); throw new Exception("CreateContainer should have thrown an ArgumentException"); } catch (ArgumentException exp) { Assert.AreEqual(exp.Message, @"clusterCreateParameters.RdpPassword cannot be null or empty in case either RdpUsername or RdpAccessExpiry is specified Parameter name: clusterCreateParameters"); } clusterCreateParameters.RdpPassword = "******"; clusterCreateParameters.RdpAccessExpiry = null; try { await clustersPocoClient.CreateContainer(clusterCreateParameters); throw new Exception("CreateContainer should have thrown an ArgumentException"); } catch (ArgumentException exp) { Assert.AreEqual(exp.Message, @"clusterCreateParameters.RdpAccessExpiry cannot be null or empty in case either RdpUsername or RdpPassword is specified Parameter name: clusterCreateParameters"); } clusterCreateParameters.RdpAccessExpiry = DateTime.MinValue; try { await clustersPocoClient.CreateContainer(clusterCreateParameters); throw new Exception("CreateContainer should have thrown an ArgumentException"); } catch (ArgumentException exp) { Assert.AreEqual(exp.Message, @"clusterCreateParameters.RdpAccessExpiry should be a time in future. Parameter name: clusterCreateParameters"); } }
public async Task CanCreateIaasClusterWithD12Headnode() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); var clustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient); var clusterCreateParameters = new HDInsight.ClusterCreateParametersV2 { Name = "D12HeadnodeCreationTest", DefaultStorageAccountKey = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Key, DefaultStorageAccountName = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Name, DefaultStorageContainer = "D12HeadnodeCreationTest", ClusterSizeInNodes = 2, Location = "East US", UserName = "******", Password = "******", OSType = OSType.Linux, Version = "3.2", ClusterType = ClusterProvisioning.Data.ClusterType.Hadoop, HeadNodeSize = "Standard_D12" }; await clustersPocoClient.CreateContainer(clusterCreateParameters); var containersList = clustersPocoClient.ListContainers().Result; Assert.AreEqual(containersList.Count, 1); Assert.IsNotNull(containersList.SingleOrDefault(cluster => cluster.Name.Equals("D12HeadnodeCreationTest"))); }
public void CanCreatePocoClient() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); Assert.IsNotNull(restClient); using (var paasClustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient)) { Assert.IsNotNull(paasClustersPocoClient); } }
public async Task CanResizeCluster() { var restClient = ServiceLocator.Instance.Locate <IRdfeClustersResourceRestClientFactory>() .Create(this.DefaultHandler, this.HdInsightCertCred, this.Context, false, SchemaVersionUtils.GetSchemaVersion(Capabilities)); var paasClustersPocoClient = new PaasClustersPocoClient(this.HdInsightCertCred, false, this.Context, Capabilities, restClient); CreateCluster("testcluster", "West US"); var cluster = paasClustersPocoClient.ListContainer("testcluster").Result; var originalInstanceCount = cluster.ClusterSizeInNodes; var expectedNewCount = originalInstanceCount * 2; Assert.AreEqual(cluster.ClusterSizeInNodes, originalInstanceCount); await paasClustersPocoClient.ChangeClusterSize("testcluster", cluster.Location, expectedNewCount); cluster = paasClustersPocoClient.ListContainer("testcluster").Result; var actualNewCount = cluster.ClusterSizeInNodes; Assert.AreEqual(expectedNewCount, actualNewCount); }
/// <summary> /// Creates the container. /// </summary> /// <param name="clusterCreateParameters">The cluster create parameters.</param> /// <returns>A task.</returns> public async Task CreateContainer(HDInsight.ClusterCreateParametersV2 clusterCreateParameters) { if (clusterCreateParameters == null) { throw new ArgumentNullException("clusterCreateParameters"); } if (string.IsNullOrEmpty(clusterCreateParameters.Name)) { throw new ArgumentException("ClusterCreateParameters.Name cannot be null or empty", "clusterCreateParameters"); } if (string.IsNullOrEmpty(clusterCreateParameters.Location)) { throw new ArgumentException("ClusterCreateParameters.Location cannot be null or empty", "clusterCreateParameters"); } if (clusterCreateParameters.ClusterSizeInNodes < 1) { throw new ArgumentException("clusterCreateParameters.ClusterSizeInNodes must be > 0"); } //allow zookeeper to be specified only for Hbase and Storm clusters if (clusterCreateParameters.ZookeeperNodeSize != null) { if (clusterCreateParameters.ClusterType != ClusterType.HBase && clusterCreateParameters.ClusterType != ClusterType.Storm) { throw new ArgumentException( string.Format("clusterCreateParameters.ZookeeperNodeSize must be null for {0} clusters.", clusterCreateParameters.ClusterType)); } } try { //Validate AsvValidationHelper.ValidateAndResolveAsvAccountsAndPrep(clusterCreateParameters); // Validates config action component. if (clusterCreateParameters.ConfigActions != null && clusterCreateParameters.ConfigActions.Count > 0) { this.LogMessage("Validating parameters for config actions.", Severity.Informational, Verbosity.Detailed); if (!HasClusterConfigActionCapability(this.capabilities) || !HasCorrectSchemaVersionForConfigAction(this.capabilities)) { throw new NotSupportedException("Your subscription does not support config actions."); } this.LogMessage("Validating URIs for config actions.", Severity.Informational, Verbosity.Detailed); // Validates that the config actions' Uris are downloadable. UriEndpointValidator.ValidateAndResolveConfigActionEndpointUris(clusterCreateParameters); } //Validate if new vm sizes are used and if the schema is on. if (CreateHasNewVMSizesSpecified(clusterCreateParameters) && !HasCorrectSchemaVersionForNewVMSizes(this.capabilities)) { throw new NotSupportedException("Your subscription does not support new VM sizes."); } var rdfeCapabilitiesClient = ServiceLocator.Instance.Locate <IRdfeServiceRestClientFactory>().Create(this.credentials, this.Context, this.ignoreSslErrors); var capabilities = await rdfeCapabilitiesClient.GetResourceProviderProperties(); // Validates the region for the cluster creation var locationClient = ServiceLocator.Instance.Locate <ILocationFinderClientFactory>().Create(this.credentials, this.Context, this.ignoreSslErrors); var availableLocations = locationClient.ListAvailableLocations(capabilities); if (!availableLocations.Contains(clusterCreateParameters.Location, StringComparer.OrdinalIgnoreCase)) { throw new InvalidOperationException(string.Format( "Cannot create a cluster in '{0}'. Available Locations for your subscription are: {1}", clusterCreateParameters.Location, string.Join(",", availableLocations))); } await this.RegisterSubscriptionIfExistsAsync(); await this.CreateCloudServiceAsyncIfNotExists(clusterCreateParameters.Location); var wireCreateParameters = PayloadConverterClusters.CreateWireClusterCreateParametersFromUserType(clusterCreateParameters); var rdfeResourceInputFromWireInput = PayloadConverterClusters.CreateRdfeResourceInputFromWireInput(wireCreateParameters, SchemaVersionUtils.GetSchemaVersion(this.capabilities)); await this.rdfeClustersRestClient.CreateCluster( this.credentials.SubscriptionId.ToString(), this.GetCloudServiceName(clusterCreateParameters.Location), this.credentials.DeploymentNamespace, clusterCreateParameters.Name, rdfeResourceInputFromWireInput, this.Context.CancellationToken); } catch (InvalidExpectedStatusCodeException iEx) { string content = iEx.Response.Content != null?iEx.Response.Content.ReadAsStringAsync().Result : string.Empty; throw new HttpLayerException(iEx.ReceivedStatusCode, content); } }