Пример #1
0
        public void CanCreateNewHDInsightCluster_LinuxComponentVersion()
        {
            string sparkClusterType = "Spark";
            var    componentVersion = new Dictionary <string, string>
            {
                { "Spark", "2.0" }
            };
            var componentVersionResponse = "[Spark, 2.0]";

            cmdlet.ClusterName               = ClusterName;
            cmdlet.ResourceGroupName         = ResourceGroupName;
            cmdlet.ClusterSizeInNodes        = ClusterSize;
            cmdlet.Location                  = Location;
            cmdlet.HttpCredential            = _httpCred;
            cmdlet.DefaultStorageAccountName = StorageName;
            cmdlet.DefaultStorageAccountKey  = StorageKey;
            cmdlet.ClusterType               = "Spark";
            cmdlet.SshCredential             = _sshCred;
            cmdlet.OSType           = OSType.Linux;
            cmdlet.ComponentVersion = componentVersion;

            var cluster = new Cluster
            {
                Id         = "id",
                Name       = ClusterName,
                Location   = Location,
                Properties = new ClusterGetProperties
                {
                    ClusterVersion    = "3.5",
                    ClusterState      = "Running",
                    ClusterDefinition = new ClusterDefinition
                    {
                        ClusterType = sparkClusterType
                    },
                    QuotaInfo = new QuotaInfo
                    {
                        CoresUsed = 24
                    },
                    OperatingSystemType = OSType.Linux
                }
            };


            cluster.Properties.ClusterDefinition.ComponentVersion = componentVersion;
            var coreConfigs = new Dictionary <string, string>
            {
                { "fs.defaultFS", "wasb://giyertestcsmv2@" + StorageName },
                {
                    "fs.azure.account.key." + StorageName,
                    StorageKey
                }
            };
            var gatewayConfigs = new Dictionary <string, string>
            {
                { "restAuthCredential.isEnabled", "true" },
                { "restAuthCredential.username", _httpCred.UserName },
                { "restAuthCredential.password", _httpCred.Password.ConvertToString() }
            };

            var configurations = new Dictionary <string, Dictionary <string, string> >
            {
                { "core-site", coreConfigs },
                { "gateway", gatewayConfigs }
            };
            var serializedConfig = JsonConvert.SerializeObject(configurations);

            cluster.Properties.ClusterDefinition.Configurations = serializedConfig;

            var getresponse = new ClusterGetResponse {
                Cluster = cluster
            };

            hdinsightManagementMock.Setup(c => c.CreateNewCluster(ResourceGroupName, ClusterName, It.Is <ClusterCreateParameters>(
                                                                      parameters =>
                                                                      parameters.ClusterSizeInNodes == ClusterSize &&
                                                                      parameters.DefaultStorageInfo as AzureStorageInfo != null &&
                                                                      ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountName == StorageName &&
                                                                      ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountKey == StorageKey &&
                                                                      parameters.Location == Location &&
                                                                      parameters.UserName == _httpCred.UserName &&
                                                                      parameters.Password == _httpCred.Password.ConvertToString() &&
                                                                      parameters.ClusterType == sparkClusterType &&
                                                                      parameters.OSType == OSType.Linux &&
                                                                      parameters.SshUserName == _sshCred.UserName &&
                                                                      parameters.SshPassword == _sshCred.Password.ConvertToString() &&
                                                                      parameters.ComponentVersion["Spark"] == componentVersion["Spark"])))
            .Returns(getresponse)
            .Verifiable();
            hdinsightManagementMock.Setup(
                c => c.CreateNewCluster(ResourceGroupName, ClusterName, It.Is <ClusterCreateParameters>(
                                            parameters =>
                                            parameters.ClusterSizeInNodes == ClusterSize &&
                                            parameters.DefaultStorageInfo as AzureStorageInfo != null &&
                                            ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountName == StorageName &&
                                            ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountKey == StorageKey &&
                                            parameters.Location == Location &&
                                            parameters.UserName == _httpCred.UserName &&
                                            parameters.Password == _httpCred.Password.ConvertToString() &&
                                            parameters.ClusterType == ClusterType &&
                                            parameters.OSType == OSType.Linux &&
                                            parameters.SshUserName == _sshCred.UserName &&
                                            parameters.SshPassword == _sshCred.Password.ConvertToString())))
            .Returns(getresponse)
            .Verifiable();

            cmdlet.ExecuteCmdlet();

            commandRuntimeMock.VerifyAll();
            commandRuntimeMock.Verify(f => f.WriteObject(It.Is <AzureHDInsightCluster>(
                                                             clusterout =>
                                                             clusterout.ClusterState == "Running" &&
                                                             clusterout.ClusterType == sparkClusterType &&
                                                             clusterout.ClusterVersion == "3.5" &&
                                                             clusterout.CoresUsed == 24 &&
                                                             clusterout.Location == Location &&
                                                             clusterout.Name == ClusterName &&
                                                             clusterout.OperatingSystemType == OSType.Linux &&
                                                             clusterout.ComponentVersion[0] == componentVersionResponse)),
                                      Times.Once);
        }
Пример #2
0
        public void CanCreateNewHDInsightDataLakeStoreCluster()
        {
            cmdlet.ClusterName               = ClusterName;
            cmdlet.ResourceGroupName         = ResourceGroupName;
            cmdlet.ClusterSizeInNodes        = ClusterSize;
            cmdlet.Location                  = Location;
            cmdlet.HttpCredential            = _httpCred;
            cmdlet.DefaultStorageAccountName = StorageName;
            cmdlet.DefaultStorageAccountKey  = StorageKey;
            cmdlet.AadTenantId               = AadTenantId;
            cmdlet.ObjectId                  = ObjectId;
            cmdlet.CertificateFilePath       = Certificate;
            cmdlet.CertificatePassword       = CertificatePassword;

            var cluster = new Cluster
            {
                Id         = "id",
                Name       = ClusterName,
                Location   = Location,
                Properties = new ClusterGetProperties
                {
                    ClusterVersion    = "3.2",
                    ClusterState      = "Running",
                    ClusterDefinition = new ClusterDefinition
                    {
                        ClusterType = "Hadoop"
                    },
                    QuotaInfo = new QuotaInfo
                    {
                        CoresUsed = 24
                    },
                    OperatingSystemType = OSType.Windows
                }
            };
            var coreConfigs = new Dictionary <string, string>
            {
                { "fs.defaultFS", "wasb://dummycsmv2@" + StorageName },
                {
                    "fs.azure.account.key." + StorageName,
                    StorageKey
                }
            };
            var gatewayConfigs = new Dictionary <string, string>
            {
                { "restAuthCredential.isEnabled", "true" },
                { "restAuthCredential.username", _httpCred.UserName },
                { "restAuthCredential.password", _httpCred.Password.ConvertToString() }
            };
            var datalakeStoreConfigs = new Dictionary <string, string>
            {
                { "clusterIdentity.applicationId", ObjectId.ToString() },
                { "clusterIdentity.certificate", Certificate },
                { "clusterIdentity.certificatePassword", CertificatePassword },
                { "clusterIdentity.aadTenantId", AadTenantId.ToString() }
            };
            var configurations = new Dictionary <string, Dictionary <string, string> >
            {
                { "core-site", coreConfigs },
                { "gateway", gatewayConfigs },
                { "clusterIdentity", datalakeStoreConfigs }
            };
            var serializedConfig = JsonConvert.SerializeObject(configurations);

            cluster.Properties.ClusterDefinition.Configurations = serializedConfig;

            var getresponse = new ClusterGetResponse {
                Cluster = cluster
            };

            hdinsightManagementMock.Setup(
                c => c.CreateNewCluster(ResourceGroupName, ClusterName, It.Is <ClusterCreateParameters>(
                                            parameters =>
                                            parameters.ClusterSizeInNodes == ClusterSize &&
                                            parameters.DefaultStorageAccountName == StorageName &&
                                            parameters.DefaultStorageAccountKey == StorageKey &&
                                            parameters.Location == Location &&
                                            parameters.UserName == _httpCred.UserName &&
                                            parameters.Password == _httpCred.Password.ConvertToString() &&
                                            parameters.ClusterType == HDInsightClusterType.Hadoop &&
                                            parameters.OSType == OSType.Windows)))
            .Returns(getresponse)
            .Verifiable();

            cmdlet.ExecuteCmdlet();

            commandRuntimeMock.VerifyAll();
            commandRuntimeMock.Verify(f => f.WriteObject(It.Is <AzureHDInsightCluster>(
                                                             clusterout =>
                                                             clusterout.ClusterState == "Running" &&
                                                             clusterout.ClusterType == HDInsightClusterType.Hadoop &&
                                                             clusterout.ClusterVersion == "3.2" &&
                                                             clusterout.CoresUsed == 24 &&
                                                             clusterout.Location == Location &&
                                                             clusterout.Name == ClusterName &&
                                                             clusterout.OperatingSystemType == OSType.Windows)),
                                      Times.Once);
        }
Пример #3
0
        private void CreateNewHDInsightCluster(
            bool addSecurityProfileInresponse = false,
            bool setEdgeNodeVmSize            = false,
            int workerNodeDataDisks           = 0)
        {
            // Assign cmdlet parameters
            cmdlet.ClusterName               = ClusterName;
            cmdlet.ResourceGroupName         = ResourceGroupName;
            cmdlet.ClusterSizeInNodes        = ClusterSize;
            cmdlet.Location                  = Location;
            cmdlet.HttpCredential            = _httpCred;
            cmdlet.DefaultStorageAccountName = StorageName;
            cmdlet.DefaultStorageAccountKey  = StorageKey;
            cmdlet.ClusterType               = ClusterType;
            cmdlet.SshCredential             = _sshCred;
            cmdlet.OSType             = OSType.Linux;
            cmdlet.DisksPerWorkerNode = workerNodeDataDisks;
            if (setEdgeNodeVmSize)
            {
                cmdlet.EdgeNodeSize = "edgeNodeVmSizeSetTest";
            }

            // Construct cluster Object
            var cluster = new Cluster
            {
                Id         = "id",
                Name       = ClusterName,
                Location   = Location,
                Properties = new ClusterGetProperties
                {
                    ClusterVersion    = HdiVersion,
                    ClusterState      = "Running",
                    ClusterDefinition = new ClusterDefinition
                    {
                        ClusterType = ClusterType
                    },
                    QuotaInfo = new QuotaInfo
                    {
                        CoresUsed = 24
                    },
                    OperatingSystemType = OSType.Linux,
                    ComputeProfile      = new ComputeProfile()
                    {
                        Roles = new List <Role>()
                    }
                }
            };

            if (workerNodeDataDisks > 0)
            {
                cluster.Properties.ComputeProfile.Roles.Add(new Role()
                {
                    Name            = "workernode",
                    DataDisksGroups = new List <DataDisksGroupProperties>()
                    {
                        new DataDisksGroupProperties()
                        {
                            DisksPerNode = workerNodeDataDisks
                        }
                    }
                });
            }

            if (addSecurityProfileInresponse)
            {
                cluster.Properties.SecurityProfile = new SecurityProfile()
                {
                    Domain               = "domain.com",
                    DomainUsername       = "******",
                    DomainUserPassword   = "******",
                    OrganizationalUnitDN = "OUDN",
                    LdapsUrls            = new[]
                    {
                        "ldapsurl"
                    },
                    ClusterUsersGroupDNs = new[]
                    {
                        "userGroupDn"
                    }
                };
            }

            var coreConfigs = new Dictionary <string, string>
            {
                { "fs.defaultFS", "wasb://giyertestcsmv2@" + StorageName },
                {
                    "fs.azure.account.key." + StorageName,
                    StorageKey
                }
            };
            var gatewayConfigs = new Dictionary <string, string>
            {
                { "restAuthCredential.isEnabled", "true" },
                { "restAuthCredential.username", _httpCred.UserName },
                { "restAuthCredential.password", _httpCred.Password.ConvertToString() }
            };

            var configurations = new Dictionary <string, Dictionary <string, string> >
            {
                { "core-site", coreConfigs },
                { "gateway", gatewayConfigs }
            };
            var serializedConfig = JsonConvert.SerializeObject(configurations);

            cluster.Properties.ClusterDefinition.Configurations = serializedConfig;

            var getresponse = new ClusterGetResponse {
                Cluster = cluster
            };

            // Setup Mocks and verify successfull GET response
            hdinsightManagementMock.Setup(
                c => c.CreateNewCluster(ResourceGroupName, ClusterName, It.Is <ClusterCreateParameters>(
                                            parameters =>
                                            parameters.ClusterSizeInNodes == ClusterSize &&
                                            parameters.DefaultStorageInfo as AzureStorageInfo != null &&
                                            ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountName == StorageName &&
                                            ((AzureStorageInfo)parameters.DefaultStorageInfo).StorageAccountKey == StorageKey &&
                                            parameters.Location == Location &&
                                            parameters.UserName == _httpCred.UserName &&
                                            parameters.Password == _httpCred.Password.ConvertToString() &&
                                            parameters.ClusterType == ClusterType &&
                                            parameters.OSType == OSType.Linux &&
                                            parameters.SshUserName == _sshCred.UserName &&
                                            parameters.SshPassword == _sshCred.Password.ConvertToString() &&
                                            ((!setEdgeNodeVmSize && parameters.EdgeNodeSize == null) || (setEdgeNodeVmSize && parameters.EdgeNodeSize == "edgeNodeVmSizeSetTest")) &&
                                            (workerNodeDataDisks == 0) || (workerNodeDataDisks > 0 && parameters.WorkerNodeDataDisksGroups.First().DisksPerNode == workerNodeDataDisks))))
            .Returns(getresponse)
            .Verifiable();

            // Execute Cmdlet and verify output
            cmdlet.ExecuteCmdlet();

            commandRuntimeMock.VerifyAll();
            commandRuntimeMock.Verify(f => f.WriteObject(It.Is <AzureHDInsightCluster>(
                                                             clusterout =>
                                                             clusterout.ClusterState == "Running" &&
                                                             clusterout.ClusterType == ClusterType &&
                                                             clusterout.ClusterVersion == HdiVersion &&
                                                             clusterout.CoresUsed == 24 &&
                                                             clusterout.Location == Location &&
                                                             clusterout.Name == ClusterName &&
                                                             clusterout.OperatingSystemType == OSType.Linux &&
                                                             (workerNodeDataDisks == 0) || (clusterout.WorkerNodeDataDisksGroups.First().DisksPerNode == workerNodeDataDisks))),
                                      Times.Once);
        }