public void HDInsightStorageContainerToStringIsAccountName()
        {
            string accountName = "storageaccountname.blob.core.windows.net";
            var storageAccount = new AzureHDInsightStorageAccount { StorageAccountKey = Guid.NewGuid().ToString(), StorageAccountName = accountName };

            Assert.AreEqual(accountName, storageAccount.ToString());
        }
        public void HDInsightStorageContainerToStringIsAccountName()
        {
            string accountName    = "storageaccountname.blob.core.windows.net";
            var    storageAccount = new AzureHDInsightStorageAccount {
                StorageAccountKey = Guid.NewGuid().ToString(), StorageAccountName = accountName
            };

            Assert.AreEqual(accountName, storageAccount.ToString());
        }
 public Task EndProcessing()
 {
     var account = new AzureHDInsightStorageAccount();
     account.StorageAccountName = this.StorageAccountName;
     account.StorageAccountKey = this.StorageAccountKey;
     this.Config.AdditionalStorageAccounts.Add(account);
     this.Output.Add(this.Config);
     return TaskEx.FromResult(0);
 }
        public Task EndProcessing()
        {
            var account = new AzureHDInsightStorageAccount();

            account.StorageAccountName = this.StorageAccountName;
            account.StorageAccountKey  = this.StorageAccountKey;
            this.Config.AdditionalStorageAccounts.Add(account);
            this.Output.Add(this.Config);
            return(TaskEx.FromResult(0));
        }
示例#5
0
        public void ICanCreateAClusterWithThreeOrMoreAsvAccountsUsingPowerShell()
        {
            string dnsName         = this.GetRandomClusterName();
            var    storageAccounts = GetWellKnownStorageAccounts().ToList();

            Assert.IsTrue(storageAccounts.Count >= 3);

            IHDInsightCertificateCredential creds = GetValidCredentials();

            using (IRunspace runspace = this.GetPowerShellRunspace())
            {
                IPipelineResult results =
                    runspace.NewPipeline()
                    .AddCommand(CmdletConstants.NewAzureHDInsightClusterConfig)
                    .WithParameter(CmdletConstants.ClusterSizeInNodes, 3)
                    .AddCommand(CmdletConstants.SetAzureHDInsightDefaultStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, TestCredentials.Environments[0].DefaultStorageAccount.Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, TestCredentials.Environments[0].DefaultStorageAccount.Key)
                    .WithParameter(CmdletConstants.StorageContainerName, TestCredentials.Environments[0].DefaultStorageAccount.Container)
                    .AddCommand(CmdletConstants.AddAzureHDInsightStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, storageAccounts[0].Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, storageAccounts[0].Key)
                    .AddCommand(CmdletConstants.AddAzureHDInsightStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, storageAccounts[1].Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, storageAccounts[1].Key)
                    .AddCommand(CmdletConstants.AddAzureHDInsightStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, storageAccounts[2].Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, storageAccounts[2].Key)
                    .AddCommand(CmdletConstants.NewAzureHDInsightCluster)
                    .WithParameter(CmdletConstants.Name, dnsName)
                    .WithParameter(CmdletConstants.Location, CmdletConstants.EastUs)
                    .WithParameter(CmdletConstants.Credential, GetPSCredential("hadoop", this.GetRandomValidPassword()))
                    .Invoke();

                AzureHDInsightCluster clusterFromPowershell = results.Results.ToEnumerable <AzureHDInsightCluster>().First();
                List <AzureHDInsightStorageAccount> storageAccountsFromPowershell = clusterFromPowershell.StorageAccounts.ToList();
                Assert.AreEqual(3, storageAccountsFromPowershell.Count);

                foreach (WabStorageAccountConfiguration storageAccount in storageAccounts)
                {
                    AzureHDInsightStorageAccount additionalStorageAccountFromOutput =
                        storageAccountsFromPowershell.FirstOrDefault(acc => acc.StorageAccountName == storageAccount.Name);
                    Assert.IsNotNull(additionalStorageAccountFromOutput, "Storage account " + storageAccount.Name + " was not found");
                    Assert.AreEqual(storageAccount.Key, additionalStorageAccountFromOutput.StorageAccountKey);
                }
            }
        }
示例#6
0
        private static void ValidateGetCluster(AzureHDInsightCluster cluster)
        {
            Assert.AreEqual(TestCredentials.WellKnownCluster.DnsName, cluster.Name);
            Assert.AreEqual(TestCredentials.WellKnownCluster.Version, cluster.Version);
            WabStorageAccountConfiguration defaultStorageAccount = GetWellKnownStorageAccounts().First();

            Assert.AreEqual(defaultStorageAccount.Key, cluster.DefaultStorageAccount.StorageAccountKey);
            Assert.AreEqual(defaultStorageAccount.Name, cluster.DefaultStorageAccount.StorageAccountName);
            Assert.AreEqual(defaultStorageAccount.Container, cluster.DefaultStorageAccount.StorageContainerName);
            foreach (WabStorageAccountConfiguration account in GetWellKnownStorageAccounts().Skip(1))
            {
                AzureHDInsightStorageAccount deserializedAccount =
                    cluster.StorageAccounts.FirstOrDefault(acc => acc.StorageAccountName == account.Name);
                Assert.IsNotNull(deserializedAccount, account.Name);
                Assert.AreEqual(account.Key, deserializedAccount.StorageAccountKey);
            }
        }
示例#7
0
        private static void ValidateGetCluster(AzureHDInsightCluster cluster)
        {
            Assert.AreEqual(TestCredentials.WellKnownCluster.DnsName, cluster.Name);
            Assert.AreEqual(TestCredentials.HadoopUserName, cluster.HttpUserName);
            Assert.AreEqual(TestCredentials.AzurePassword, cluster.HttpPassword);
            Assert.AreEqual(ClusterState.Running, cluster.State);
            Assert.IsFalse(string.IsNullOrEmpty(cluster.ConnectionUrl));
            Assert.AreEqual(VersionStatus.Compatible.ToString(), cluster.VersionStatus);
            Assert.AreEqual(TestCredentials.WellKnownCluster.Version, cluster.Version);
            WabStorageAccountConfiguration defaultStorageAccount = GetWellKnownStorageAccounts().First();

            Assert.AreEqual(defaultStorageAccount.Key, cluster.DefaultStorageAccount.StorageAccountKey);
            Assert.AreEqual(defaultStorageAccount.Name, cluster.DefaultStorageAccount.StorageAccountName);
            Assert.AreEqual(defaultStorageAccount.Container, cluster.DefaultStorageAccount.StorageContainerName);
            foreach (WabStorageAccountConfiguration account in GetWellKnownStorageAccounts().Skip(1))
            {
                AzureHDInsightStorageAccount deserializedAccount =
                    cluster.StorageAccounts.FirstOrDefault(acc => acc.StorageAccountName == account.Name);
                Assert.IsNotNull(deserializedAccount, account.Name);
                Assert.AreEqual(account.Key, deserializedAccount.StorageAccountKey);
            }
        }
示例#8
0
        public void ICanAddMultipleStorageAccountsUsingPowerShell()
        {
            IHDInsightCertificateCredential creds = GetValidCredentials();
            string dnsName = this.GetRandomClusterName();

            using (IRunspace runspace = this.GetPowerShellRunspace())
            {
                var additionalStorageAccount = new WabStorageAccountConfiguration(
                    TestCredentials.Environments[0].AdditionalStorageAccounts[0].Name,
                    TestCredentials.Environments[0].AdditionalStorageAccounts[0].Key);
                IPipelineResult results =
                    runspace.NewPipeline()
                    .AddCommand(CmdletConstants.NewAzureHDInsightClusterConfig)
                    .WithParameter(CmdletConstants.ClusterSizeInNodes, 3)
                    .AddCommand(CmdletConstants.SetAzureHDInsightDefaultStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, TestCredentials.Environments[0].DefaultStorageAccount.Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, TestCredentials.Environments[0].DefaultStorageAccount.Key)
                    .WithParameter(CmdletConstants.StorageContainerName, TestCredentials.Environments[0].DefaultStorageAccount.Container)
                    .AddCommand(CmdletConstants.AddAzureHDInsightStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, additionalStorageAccount.Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, additionalStorageAccount.Key)
                    .AddCommand(CmdletConstants.NewAzureHDInsightCluster)
                    .WithParameter(CmdletConstants.Name, dnsName)
                    .WithParameter(CmdletConstants.Location, CmdletConstants.EastUs)
                    .WithParameter(CmdletConstants.Credential, GetPSCredential("hadoop", this.GetRandomValidPassword()))
                    .Invoke();

                Assert.AreEqual(1, results.Results.Count);
                Assert.AreEqual(dnsName, results.Results.ToEnumerable <AzureHDInsightCluster>().First().Name);

                IGetAzureHDInsightClusterCommand getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand.CurrentSubscription = GetCurrentSubscription();
                getCommand.Name = dnsName;

                getCommand.EndProcessing();
                Assert.AreEqual(1, getCommand.Output.Count);
                Assert.AreEqual(dnsName, getCommand.Output.ElementAt(0).Name);

                List <AzureHDInsightStorageAccount> storageAccounts = getCommand.Output.Last().StorageAccounts.ToList();
                Assert.AreEqual(storageAccounts.Count, 1);

                AzureHDInsightStorageAccount additionalStorageAccountFromOutput =
                    storageAccounts.FirstOrDefault(acc => acc.StorageAccountName == additionalStorageAccount.Name);
                Assert.IsNotNull(additionalStorageAccountFromOutput);
                Assert.AreEqual(additionalStorageAccount.Key, additionalStorageAccountFromOutput.StorageAccountKey);

                results = runspace.NewPipeline().AddCommand(CmdletConstants.RemoveAzureHDInsightCluster)
                          // Ensure that subscription id can be accepted as a sting as well as a guid.
                          .WithParameter(CmdletConstants.Name, dnsName)
                          .Invoke();

                Assert.AreEqual(0, results.Results.Count);


                getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand.CurrentSubscription = GetCurrentSubscription();
                getCommand.Name = dnsName;
                getCommand.EndProcessing();
                Assert.AreEqual(0, getCommand.Output.Count);
            }
        }