|
20 | 20 | using Moq;
|
21 | 21 | using Newtonsoft.Json;
|
22 | 22 | using System.Collections.Generic;
|
| 23 | +using System.Linq; |
23 | 24 | using System.Management.Automation;
|
24 | 25 | using Xunit;
|
25 | 26 |
|
@@ -438,6 +439,141 @@ public void CanCreateNewHDInsightCluster_LinuxComponentVersion()
|
438 | 439 | Times.Once);
|
439 | 440 | }
|
440 | 441 |
|
| 442 | + [Fact] |
| 443 | + [Trait(Category.AcceptanceType, Category.CheckIn)] |
| 444 | + public void CanCreateNewHDInsightCluster_DataDisksGroups() |
| 445 | + { |
| 446 | + var kafkaClusterType = "Kafka"; |
| 447 | + var hdiVersion = "3.6"; |
| 448 | + var coresUsed = 24; |
| 449 | + var expectedClusterState = "Running"; |
| 450 | + var dataDisksGroup = new DataDisksGroupProperties() |
| 451 | + { |
| 452 | + DisksPerNode = 8 |
| 453 | + }; |
| 454 | + var workerNodeDataDisksGroups = new List<DataDisksGroupProperties>() |
| 455 | + { |
| 456 | + dataDisksGroup |
| 457 | + }; |
| 458 | + |
| 459 | + cmdlet.ClusterName = ClusterName; |
| 460 | + cmdlet.ResourceGroupName = ResourceGroupName; |
| 461 | + cmdlet.ClusterSizeInNodes = ClusterSize; |
| 462 | + cmdlet.Location = Location; |
| 463 | + cmdlet.HttpCredential = _httpCred; |
| 464 | + cmdlet.DefaultStorageAccountName = StorageName; |
| 465 | + cmdlet.DefaultStorageAccountKey = StorageKey; |
| 466 | + cmdlet.ClusterType = kafkaClusterType; |
| 467 | + cmdlet.SshCredential = _sshCred; |
| 468 | + cmdlet.OSType = OSType.Linux; |
| 469 | + cmdlet.WorkerNodeDataDisksGroups = workerNodeDataDisksGroups; |
| 470 | + |
| 471 | + var cluster = new Cluster |
| 472 | + { |
| 473 | + Id = "id", |
| 474 | + Name = ClusterName, |
| 475 | + Location = Location, |
| 476 | + Properties = new ClusterGetProperties |
| 477 | + { |
| 478 | + ClusterVersion = hdiVersion, |
| 479 | + ClusterState = expectedClusterState, |
| 480 | + ClusterDefinition = new ClusterDefinition |
| 481 | + { |
| 482 | + ClusterType = kafkaClusterType |
| 483 | + }, |
| 484 | + QuotaInfo = new QuotaInfo |
| 485 | + { |
| 486 | + CoresUsed = coresUsed |
| 487 | + }, |
| 488 | + OperatingSystemType = OSType.Linux, |
| 489 | + ComputeProfile = new ComputeProfile() |
| 490 | + { |
| 491 | + Roles = new List<Role>() |
| 492 | + } |
| 493 | + } |
| 494 | + }; |
| 495 | + |
| 496 | + cluster.Properties.ComputeProfile.Roles.Add(new Role() |
| 497 | + { |
| 498 | + Name = "workernode", |
| 499 | + DataDisksGroups = workerNodeDataDisksGroups |
| 500 | + }); |
| 501 | + |
| 502 | + var coreConfigs = new Dictionary<string, string> |
| 503 | + { |
| 504 | + {"fs.defaultFS", "wasb://giyertestcsmv2@" + StorageName}, |
| 505 | + { |
| 506 | + "fs.azure.account.key." + StorageName, |
| 507 | + StorageKey |
| 508 | + } |
| 509 | + }; |
| 510 | + var gatewayConfigs = new Dictionary<string, string> |
| 511 | + { |
| 512 | + {"restAuthCredential.isEnabled", "true"}, |
| 513 | + {"restAuthCredential.username", _httpCred.UserName}, |
| 514 | + {"restAuthCredential.password", _httpCred.Password.ConvertToString()} |
| 515 | + }; |
| 516 | + |
| 517 | + var configurations = new Dictionary<string, Dictionary<string, string>> |
| 518 | + { |
| 519 | + {"core-site", coreConfigs}, |
| 520 | + {"gateway", gatewayConfigs} |
| 521 | + }; |
| 522 | + var serializedConfig = JsonConvert.SerializeObject(configurations); |
| 523 | + cluster.Properties.ClusterDefinition.Configurations = serializedConfig; |
| 524 | + |
| 525 | + var getresponse = new ClusterGetResponse { Cluster = cluster }; |
| 526 | + |
| 527 | + hdinsightManagementMock.Setup(c => c.CreateNewCluster(ResourceGroupName, ClusterName, It.Is<ClusterCreateParameters>( |
| 528 | + parameters => |
| 529 | + parameters.ClusterSizeInNodes == ClusterSize && |
| 530 | + parameters.DefaultStorageInfo as AzureStorageInfo != null && |
| 531 | + ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountName == StorageName && |
| 532 | + ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountKey == StorageKey && |
| 533 | + parameters.Location == Location && |
| 534 | + parameters.UserName == _httpCred.UserName && |
| 535 | + parameters.Password == _httpCred.Password.ConvertToString() && |
| 536 | + parameters.ClusterType == kafkaClusterType && |
| 537 | + parameters.OSType == OSType.Linux && |
| 538 | + parameters.SshUserName == _sshCred.UserName && |
| 539 | + parameters.SshPassword == _sshCred.Password.ConvertToString() && |
| 540 | + parameters.WorkerNodeDataDisksGroups.First().DisksPerNode == dataDisksGroup.DisksPerNode))) |
| 541 | + .Returns(getresponse) |
| 542 | + .Verifiable(); |
| 543 | + hdinsightManagementMock.Setup( |
| 544 | + c => c.CreateNewCluster(ResourceGroupName, ClusterName, It.Is<ClusterCreateParameters>( |
| 545 | + parameters => |
| 546 | + parameters.ClusterSizeInNodes == ClusterSize && |
| 547 | + parameters.DefaultStorageInfo as AzureStorageInfo != null && |
| 548 | + ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountName == StorageName && |
| 549 | + ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountKey == StorageKey && |
| 550 | + parameters.Location == Location && |
| 551 | + parameters.UserName == _httpCred.UserName && |
| 552 | + parameters.Password == _httpCred.Password.ConvertToString() && |
| 553 | + parameters.ClusterType == ClusterType && |
| 554 | + parameters.OSType == OSType.Linux && |
| 555 | + parameters.SshUserName == _sshCred.UserName && |
| 556 | + parameters.SshPassword == _sshCred.Password.ConvertToString()))) |
| 557 | + .Returns(getresponse) |
| 558 | + .Verifiable(); |
| 559 | + |
| 560 | + cmdlet.ExecuteCmdlet(); |
| 561 | + |
| 562 | + commandRuntimeMock.VerifyAll(); |
| 563 | + |
| 564 | + |
| 565 | + commandRuntimeMock.Verify(f => f.WriteObject(It.Is<AzureHDInsightCluster>( |
| 566 | + clusterout => |
| 567 | + clusterout.ClusterState == expectedClusterState && |
| 568 | + clusterout.ClusterType == kafkaClusterType && |
| 569 | + clusterout.ClusterVersion == hdiVersion && |
| 570 | + clusterout.CoresUsed == coresUsed && |
| 571 | + clusterout.Location == Location && |
| 572 | + clusterout.Name == ClusterName && |
| 573 | + clusterout.OperatingSystemType == OSType.Linux)), |
| 574 | + Times.Once); |
| 575 | + } |
| 576 | + |
441 | 577 | [Fact]
|
442 | 578 | [Trait(Category.AcceptanceType, Category.CheckIn)]
|
443 | 579 | public void TestStorageAccountTypeDefaultsToAzureStorage()
|
|
0 commit comments