Exemplo n.º 1
0
        public void ICanCreateAClusterUsingPowerShellAndConfig_New_Set__EnableHeadNodeHA()
        {
            AzureTestCredentials creds = GetCredentials(TestCredentialsNames.Default);
            string dnsName             = this.GetRandomClusterName();

            using (IRunspace runspace = this.GetPowerShellRunspace())
            {
                IGetAzureHDInsightClusterCommand getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand.CurrentSubscription = GetCurrentSubscription();

                getCommand.EndProcessing();
                int expected = getCommand.Output.Count();

                IPipelineResult results = runspace.NewPipeline().AddCommand(CmdletConstants.NewAzureHDInsightCluster)
                                          // Ensure that the subscription Id can be accepted as a string as well as a guid.
                                          .WithParameter(CmdletConstants.Name, dnsName)
                                          .WithParameter(CmdletConstants.Location, CmdletConstants.EastUs)
                                          .WithParameter(
                    CmdletConstants.DefaultStorageAccountName,
                    TestCredentials.Environments[0].DefaultStorageAccount.Name)
                                          .WithParameter(
                    CmdletConstants.DefaultStorageAccountKey,
                    TestCredentials.Environments[0].DefaultStorageAccount.Key)
                                          .WithParameter(
                    CmdletConstants.DefaultStorageContainerName,
                    TestCredentials.Environments[0].DefaultStorageAccount.Container)
                                          .WithParameter(CmdletConstants.Credential, GetPSCredential("hadoop", this.GetRandomValidPassword()))
                                          .WithParameter(CmdletConstants.EnableHeadNodeHighAvailibility, null)
                                          .WithParameter(CmdletConstants.ClusterSizeInNodes, 5)
                                          .Invoke();

                ClusterCreateParameters request = AzureHDInsightClusterManagementClientSimulator.LastCreateRequest;
                Assert.IsTrue(request.EnsureHighAvailability);

                var testCluster = results.Results.ToEnumerable <AzureHDInsightCluster>().FirstOrDefault();
                Assert.IsNotNull(testCluster);
                Assert.AreEqual(dnsName, testCluster.Name);
                Assert.AreEqual(7, testCluster.ClusterSizeInNodes);

                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);

                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.EndProcessing();
                Assert.AreEqual(expected, getCommand.Output.Count);
            }
        }
Exemplo n.º 2
0
        public void ICanCreateAClusterUsingPowerShellAndConfig_New_Set_Add_Hive_Oozie_And_CoreConfig()
        {
            AzureTestCredentials creds = GetCredentials(TestCredentialsNames.Default);

            string dnsName = this.GetRandomClusterName();

            using (IRunspace runspace = this.GetPowerShellRunspace())
            {
                IGetAzureHDInsightClusterCommand getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand.CurrentSubscription = GetCurrentSubscription();

                getCommand.EndProcessing();
                int expected = getCommand.Output.Count();

                IPipelineResult results =
                    runspace.NewPipeline()
                    .AddCommand(CmdletConstants.NewAzureHDInsightClusterConfig)
                    .WithParameter(CmdletConstants.ClusterSizeInNodes, 3)
                    .AddCommand(CmdletConstants.SetAzureHDInsightDefaultStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, creds.Environments[0].DefaultStorageAccount.Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, creds.Environments[0].DefaultStorageAccount.Key)
                    .WithParameter(CmdletConstants.StorageContainerName, creds.Environments[0].DefaultStorageAccount.Container)
                    .AddCommand(CmdletConstants.AddAzureHDInsightStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, creds.Environments[0].AdditionalStorageAccounts[0].Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, creds.Environments[0].AdditionalStorageAccounts[0].Key)
                    .AddCommand(CmdletConstants.AddAzureHDInsightMetastore)
                    .WithParameter(CmdletConstants.SqlAzureServerName, creds.Environments[0].HiveStores[0].SqlServer)
                    .WithParameter(CmdletConstants.DatabaseName, creds.Environments[0].HiveStores[0].Database)
                    .WithParameter(CmdletConstants.Credential, GetPSCredential(creds.AzureUserName, creds.AzurePassword))
                    .WithParameter(CmdletConstants.MetastoreType, AzureHDInsightMetastoreType.HiveMetastore)
                    .AddCommand(CmdletConstants.AddAzureHDInsightMetastore)
                    .WithParameter(CmdletConstants.SqlAzureServerName, creds.Environments[0].OozieStores[0].SqlServer)
                    .WithParameter(CmdletConstants.DatabaseName, creds.Environments[0].OozieStores[0].Database)
                    .WithParameter(CmdletConstants.Credential, GetPSCredential(creds.AzureUserName, creds.AzurePassword))
                    .WithParameter(CmdletConstants.MetastoreType, AzureHDInsightMetastoreType.OozieMetastore)
                    .AddCommand(CmdletConstants.NewAzureHDInsightCluster)
                    .WithParameter(CmdletConstants.Name, dnsName)
                    .WithParameter(CmdletConstants.Location, CmdletConstants.EastUs)
                    .WithParameter(CmdletConstants.Credential, GetPSCredential("hadoop", this.GetRandomValidPassword()))
                    .Invoke();

                ClusterCreateParameters request = AzureHDInsightClusterManagementClientSimulator.LastCreateRequest;
                Assert.IsNotNull(request.HiveMetastore);
                Assert.IsNotNull(request.OozieMetastore);

                Assert.AreEqual(1, results.Results.Count);
                Assert.AreEqual(dnsName, results.Results.ToEnumerable <AzureHDInsightCluster>().First().Name);
                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);

                results = runspace.NewPipeline().AddCommand(CmdletConstants.RemoveAzureHDInsightCluster)
                          .WithParameter(CmdletConstants.Name, dnsName)
                          .Invoke();

                Assert.AreEqual(0, results.Results.Count);
                getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand.CurrentSubscription = GetCurrentSubscription();

                getCommand.EndProcessing();
                Assert.AreEqual(expected, getCommand.Output.Count);
            }
        }
Exemplo n.º 3
0
 public AlternativeEnvironmentIHDInsightSubscriptionCertificateCredentialsFactory()
 {
     creds = IntegrationTestBase.GetCredentialsForEnvironmentType(EnvironmentType.Current);
 }
Exemplo n.º 4
0
        public void ICanCreateAClusterUsingPowerShellAndConfig_New_Set_Add_ScriptAction()
        {
            AzureTestCredentials creds = GetCredentials(TestCredentialsNames.Default);

            string dnsName = this.GetRandomClusterName();

            using (IRunspace runspace = this.GetPowerShellRunspace())
            {
                IGetAzureHDInsightClusterCommand getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand.CurrentSubscription = GetCurrentSubscription();

                getCommand.EndProcessing();
                int expected = getCommand.Output.Count();

                IPipelineResult results =
                    runspace.NewPipeline()
                    .AddCommand(CmdletConstants.NewAzureHDInsightClusterConfig)
                    .WithParameter(CmdletConstants.ClusterSizeInNodes, 3)
                    .AddCommand(CmdletConstants.SetAzureHDInsightDefaultStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, creds.Environments[0].DefaultStorageAccount.Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, creds.Environments[0].DefaultStorageAccount.Key)
                    .WithParameter(CmdletConstants.StorageContainerName, creds.Environments[0].DefaultStorageAccount.Container)
                    .AddCommand(CmdletConstants.AddAzureHDInsightStorage)
                    .WithParameter(CmdletConstants.StorageAccountName, creds.Environments[0].AdditionalStorageAccounts[0].Name)
                    .WithParameter(CmdletConstants.StorageAccountKey, creds.Environments[0].AdditionalStorageAccounts[0].Key)
                    .AddCommand(CmdletConstants.AddAzureHDInsightScriptAction)
                    .WithParameter(CmdletConstants.ConfigActionName, "test1")
                    .WithParameter(CmdletConstants.ConfigActionClusterRoleCollection, "HeadNode")
                    .WithParameter(CmdletConstants.ScriptActionUri, "http://test1.com")
                    .WithParameter(CmdletConstants.ScriptActionParameters, "test1parameters")
                    .AddCommand(CmdletConstants.AddAzureHDInsightScriptAction)
                    .WithParameter(CmdletConstants.ConfigActionName, "test2")
                    .WithParameter(CmdletConstants.ConfigActionClusterRoleCollection, "HeadNode")
                    .WithParameter(CmdletConstants.ScriptActionUri, "http://test2.com")
                    .WithParameter(CmdletConstants.ScriptActionParameters, "test2parameters")
                    .AddCommand(CmdletConstants.NewAzureHDInsightCluster)
                    .WithParameter(CmdletConstants.Name, dnsName)
                    .WithParameter(CmdletConstants.Location, CmdletConstants.EastUs)
                    .WithParameter(CmdletConstants.Credential, GetPSCredential("hadoop", this.GetRandomValidPassword()))
                    .Invoke();

                ClusterCreateParameters request = AzureHDInsightClusterManagementClientSimulator.LastCreateRequest;
                Assert.IsTrue(request.ConfigActions != null && request.ConfigActions.Count == 2);
                Assert.IsTrue(
                    request.ConfigActions.ElementAt(0).Name == "test1" &&
                    request.ConfigActions.ElementAt(1).Name == "test2");
                Assert.IsTrue(
                    request.ConfigActions.ElementAt(0).ClusterRoleCollection.Count == 1 &&
                    request.ConfigActions.ElementAt(1).ClusterRoleCollection.Count == 1);

                Assert.AreEqual(1, results.Results.Count);
                Assert.AreEqual(dnsName, results.Results.ToEnumerable <AzureHDInsightCluster>().First().Name);
                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);

                results = runspace.NewPipeline().AddCommand(CmdletConstants.RemoveAzureHDInsightCluster)
                          .WithParameter(CmdletConstants.Name, dnsName)
                          .Invoke();

                Assert.AreEqual(0, results.Results.Count);
                getCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGet();
                getCommand.CurrentSubscription = GetCurrentSubscription();

                getCommand.EndProcessing();
                Assert.AreEqual(expected, getCommand.Output.Count);
            }
        }