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);
            }
        }
Esempio n. 2
0
 private void AddStorageAccount(dynamic dynaXml, WabStorageAccountConfiguration asv, string containerName)
 {
     dynaXml.BlobContainerReference
     .b
     .AccountName(asv.Name)
     .BlobContainerName(containerName)
     .Key(asv.Key)
     .d.End();
 }
 public override void Initialize()
 {
     base.Initialize();
     base.ApplyIndividualTestMockingOnly();
     this.storageAccount = GetWellKnownStorageAccounts().First();
     this.storageClient =
         new WabStorageAbstraction(
             new WindowsAzureStorageAccountCredentials
             {
                 Key = this.storageAccount.Key,
                 Name = this.storageAccount.Name,
                 ContainerName = this.storageAccount.Container
             });
     jobSubmissionClient =
         new HDInsightHadoopClient(
             new JobSubmissionCertificateCredential(
                 Cluster.Value.SubscriptionId,
                 GetValidCredentials().Certificate,
                 Cluster.Value.Name));
     this.CleanupCluster();
 }
Esempio n. 4
0
 private void AddStorageAccount(dynamic dynaXml, WabStorageAccountConfiguration asv, string containerName)
 {
     dynaXml.BlobContainerReference
         .b
             .AccountName(asv.Name)
             .BlobContainerName(containerName)
             .Key(asv.Key)
         .d.End();
 }
 public IAzureHDInsightStorageHandler Create(WabStorageAccountConfiguration storageAccountConfiguration)
 {
     return Instance;
 }