Example #1
0
        public void CanListJobsForAValidClusterWithJobId()
        {
            ClusterDetails cluster       = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
            PSCredential   psCredentials = GetPSCredential(cluster.HttpUserName, cluster.HttpPassword);
            IGetAzureHDInsightJobCommand getJobsCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGetJobs();

            getJobsCommand.Credential = psCredentials;
            getJobsCommand.Cluster    = cluster.ConnectionUrl;
            getJobsCommand.EndProcessing();

            if (!getJobsCommand.Output.Any())
            {
                return;
            }

            AzureHDInsightJob jobDetail = getJobsCommand.Output.First();

            IGetAzureHDInsightJobCommand getJobWithIdCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGetJobs();

            getJobWithIdCommand.Credential = psCredentials;
            getJobWithIdCommand.Cluster    = cluster.ConnectionUrl;
            getJobWithIdCommand.JobId      = jobDetail.JobId;
            getJobWithIdCommand.EndProcessing();

            Assert.AreEqual(1, getJobWithIdCommand.Output.Count, "Should have only one jobDetails when called with jobId.");
            Assert.AreEqual(jobDetail.JobId, getJobsCommand.Output.First().JobId, "Should get jobDetails with the same jobId as the one requested.");
        }
Example #2
0
        public void CanGetTaskLogsForCompletedJob()
        {
            ClusterDetails cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
            IGetAzureHDInsightJobCommand getJobsCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGetJobs();

            getJobsCommand.Credential = GetPSCredential(cluster.HttpUserName, cluster.HttpPassword);
            getJobsCommand.Cluster    = cluster.ConnectionUrl;
            getJobsCommand.EndProcessing();

            AzureHDInsightJob jobWithStatusDirectory = getJobsCommand.Output.First(j => !string.IsNullOrEmpty(j.StatusDirectory));
            string            logDirectoryPath       = Path.Combine(System.Environment.CurrentDirectory, Guid.NewGuid().ToString());
            IGetAzureHDInsightJobOutputCommand getJobOutputCommand =
                ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGetJobOutput();

            getJobOutputCommand.CurrentSubscription = GetCurrentSubscription();
            getJobOutputCommand.Cluster             = cluster.Name;
            getJobOutputCommand.OutputType          = JobOutputType.TaskLogs;
            getJobOutputCommand.TaskLogsDirectory   = logDirectoryPath;
            getJobOutputCommand.JobId = jobWithStatusDirectory.JobId;
            getJobOutputCommand.EndProcessing();

            IEnumerable <string> logFiles = Directory.EnumerateFiles(logDirectoryPath);

            Assert.IsTrue(logFiles.Any());
        }
Example #3
0
        public void CanListJobsForAValidCluster()
        {
            ClusterDetails cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
            IGetAzureHDInsightJobCommand getJobsCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGetJobs();

            getJobsCommand.Credential = GetPSCredential(cluster.HttpUserName, cluster.HttpPassword);
            getJobsCommand.Cluster    = cluster.ConnectionUrl;
            getJobsCommand.EndProcessing();

            JobList history = GetJobHistory(getJobsCommand.Cluster);

            Assert.AreEqual(history.Jobs.Count, getJobsCommand.Output.Count, "Should have {0} jobs.", history.Jobs.Count);
            foreach (AzureHDInsightJob job in getJobsCommand.Output)
            {
                Assert.IsFalse(string.IsNullOrEmpty(job.PercentComplete));
            }
        }
Example #4
0
        public void CanGetJobOutputForCompletedJob()
        {
            ClusterDetails cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
            IGetAzureHDInsightJobCommand getJobsCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGetJobs();

            getJobsCommand.Credential = GetPSCredential(cluster.HttpUserName, cluster.HttpPassword);
            getJobsCommand.Cluster    = cluster.ConnectionUrl;
            getJobsCommand.EndProcessing();

            AzureHDInsightJob jobWithStatusDirectory = getJobsCommand.Output.First(j => !string.IsNullOrEmpty(j.StatusDirectory));

            IGetAzureHDInsightJobOutputCommand getJobOutputCommand =
                ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGetJobOutput();

            getJobOutputCommand.CurrentSubscription = GetCurrentSubscription();
            getJobOutputCommand.Cluster             = cluster.Name;
            getJobOutputCommand.JobId = jobWithStatusDirectory.JobId;
            getJobOutputCommand.EndProcessing();

            Stream outputStream = getJobOutputCommand.Output.First();

            Assert.IsTrue(outputStream.Length > 0);
        }
 /// <summary>
 ///     Initializes a new instance of the GetAzureHDInsightJobCmdlet class.
 /// </summary>
 public GetAzureHDInsightJobCmdlet()
 {
     this.command = ServiceLocator.Instance.Locate<IAzureHDInsightCommandFactory>().CreateGetJobs();
 }
 /// <summary>
 ///     Initializes a new instance of the GetAzureHDInsightJobCmdlet class.
 /// </summary>
 public GetAzureHDInsightJobCmdlet()
 {
     this.command = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateGetJobs();
 }