Example #1
0
 public void CanConnectToValidClustersMoreThanOnce()
 {
     using (IRunspace runspace = this.GetPowerShellRunspace())
     {
         IHDInsightCertificateCredential creds = GetValidCredentials();
         IPipelineResult results =
             runspace.NewPipeline()
             .AddCommand(CmdletConstants.GetAzureHDInsightCluster)
             .WithParameter(CmdletConstants.Name, TestCredentials.WellKnownCluster.DnsName)
             .Invoke();
         IEnumerable <AzureHDInsightCluster> clusters = results.Results.ToEnumerable <AzureHDInsightCluster>();
         foreach (AzureHDInsightCluster cluster in clusters)
         {
             IUseAzureHDInsightClusterCommand connectCommand =
                 ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateUseCluster();
             connectCommand.CurrentSubscription = GetCurrentSubscription();
             connectCommand.Name = cluster.Name;
             connectCommand.EndProcessing();
             Assert.AreEqual(1, connectCommand.Output.Count);
             AzureHDInsightClusterConnection currentCluster = connectCommand.Output.First();
             Assert.IsNotNull(currentCluster);
             ValidateGetCluster(cluster, currentCluster.Cluster);
         }
     }
 }
        private static AzureHDInsightClusterConnection ConnectToCluster(IRunspace runspace, IHDInsightCertificateCredential creds)
        {
            IUseAzureHDInsightClusterCommand connectCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateUseCluster();

            connectCommand.CurrentSubscription = GetCurrentSubscription();
            connectCommand.Name = TestCredentials.WellKnownCluster.DnsName;
            connectCommand.EndProcessing();
            Assert.AreEqual(1, connectCommand.Output.Count);
            AzureHDInsightClusterConnection currentCluster = connectCommand.Output.First();

            ValidateGetCluster(currentCluster.Cluster);
            return(currentCluster);
        }
Example #3
0
        public void CanConnectToValidCluster()
        {
            IHDInsightCertificateCredential  creds          = GetValidCredentials();
            IUseAzureHDInsightClusterCommand connectCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateUseCluster();

            connectCommand.CurrentSubscription = GetCurrentSubscription();
            connectCommand.Name = TestCredentials.WellKnownCluster.DnsName;
            connectCommand.EndProcessing();

            Assert.AreEqual(1, connectCommand.Output.Count);
            AzureHDInsightClusterConnection currentCluster = connectCommand.Output.First();

            Assert.IsNotNull(currentCluster);
            ValidateGetCluster(currentCluster.Cluster);
        }
Example #4
0
        public void CannotConnectToInvalidCluster()
        {
            IHDInsightCertificateCredential creds = GetValidCredentials();
            string errorMessage   = string.Empty;
            string invalidCluster = Guid.NewGuid().ToString();

            try
            {
                IUseAzureHDInsightClusterCommand connectCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateUseCluster();
                connectCommand.CurrentSubscription = GetCurrentSubscription();
                connectCommand.Certificate         = creds.Certificate;
                connectCommand.Name = invalidCluster;
                connectCommand.EndProcessing().Wait();
            }
            catch (AggregateException aex)
            {
                errorMessage = aex.InnerExceptions.FirstOrDefault().Message;
            }

            Assert.AreEqual("Failed to connect to cluster :" + invalidCluster, errorMessage);
        }
 /// <summary>
 ///     Initializes a new instance of the UseAzureHDInsightClusterCmdlet class.
 /// </summary>
 public UseAzureHDInsightClusterCmdlet()
 {
     this.command = ServiceLocator.Instance.Locate<IAzureHDInsightCommandFactory>().CreateUseCluster();
 }
Example #6
0
 /// <summary>
 ///     Initializes a new instance of the UseAzureHDInsightClusterCmdlet class.
 /// </summary>
 public UseAzureHDInsightClusterCmdlet()
 {
     this.command = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateUseCluster();
 }