예제 #1
0
        public void CanCreateNewHDInsightCluster()
        {
            cmdlet.ClusterName               = ClusterName;
            cmdlet.ResourceGroupName         = ResourceGroupName;
            cmdlet.ClusterSizeInNodes        = ClusterSize;
            cmdlet.Location                  = Location;
            cmdlet.HttpCredential            = _httpCred;
            cmdlet.DefaultStorageAccountName = StorageName;
            cmdlet.DefaultStorageAccountKey  = StorageKey;
            cmdlet.ClusterType               = ClusterType;

            var cluster = new Cluster(id: "id", name: ClusterName)
            {
                Location   = Location,
                Properties = new ClusterGetProperties
                {
                    ClusterVersion    = "3.6",
                    ClusterState      = "Running",
                    ClusterDefinition = new ClusterDefinition
                    {
                        Kind = ClusterType
                    },
                    QuotaInfo = new QuotaInfo
                    {
                        CoresUsed = 24
                    },
                    OsType = OSType.Linux
                }
            };
            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;

            hdinsightManagementMock.Setup(c => c.CreateNewCluster(ResourceGroupName, ClusterName, OSType.Linux, 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), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool?>()))
            .Returns(cluster)
            .Verifiable();

            cmdlet.ExecuteCmdlet();

            commandRuntimeMock.VerifyAll();
            commandRuntimeMock.Verify(f => f.WriteObject(It.Is <AzureHDInsightCluster>(
                                                             clusterout =>
                                                             clusterout.ClusterState == "Running" &&
                                                             clusterout.ClusterType == ClusterType &&
                                                             clusterout.ClusterVersion == "3.6" &&
                                                             clusterout.CoresUsed == 24 &&
                                                             clusterout.Location == Location &&
                                                             clusterout.Name == ClusterName &&
                                                             clusterout.OperatingSystemType == OSType.Linux)),
                                      Times.Once);
        }
        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 = ClusterType
                    },
                    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 == ClusterType &&
                                            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 == ClusterType &&
                                                             clusterout.ClusterVersion == "3.2" &&
                                                             clusterout.CoresUsed == 24 &&
                                                             clusterout.Location == Location &&
                                                             clusterout.Name == ClusterName &&
                                                             clusterout.OperatingSystemType == OSType.Windows)),
                                      Times.Once);
        }