Beispiel #1
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());
        }
Beispiel #2
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.");
        }
Beispiel #3
0
        private static void TestJobLifecycle(AzureHDInsightJobDefinition mapReduceJobDefinition)
        {
            ClusterDetails    testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
            AzureHDInsightJob startedJob  = TestJobStart(mapReduceJobDefinition, testCluster);

            TestJobStop(testCluster, startedJob.JobId);
        }
Beispiel #4
0
        public void GetClientWithoutCredentialsorSubscriptionCertificateThrows()
        {
            ClusterDetails cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();

            using (var cmd = new GetAzureHDInsightJobCommand())
            {
                cmd.Cluster = cluster.Name;

                cmd.GetClient(cmd.Cluster);
            }
        }
        private static AzureHDInsightJob TestJobStart(AzureHDInsightJobDefinition mapReduceJobDefinition)
        {
            ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
            IStartAzureHDInsightJobCommand startJobCommand = ServiceLocator.Instance.Locate <IAzureHDInsightCommandFactory>().CreateStartJob();

            startJobCommand.Cluster       = testCluster.ConnectionUrl;
            startJobCommand.Credential    = GetPSCredential(testCluster.HttpUserName, testCluster.HttpPassword);
            startJobCommand.JobDefinition = mapReduceJobDefinition;
            startJobCommand.EndProcessing().Wait();
            AzureHDInsightJob jobCreationResults = startJobCommand.Output.ElementAt(0);

            Assert.IsNotNull(jobCreationResults.JobId, "Should get a non-null jobDetails id");
            Assert.IsNotNull(jobCreationResults.StatusDirectory, "StatusDirectory should be set on jobDetails");
            return(jobCreationResults);
        }
Beispiel #6
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));
            }
        }
Beispiel #7
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);
        }
Beispiel #8
0
        private static AzureHDInsightJob TestJobStart(AzureHDInsightJobDefinition mapReduceJobDefinition)
        {
            ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();

            return(TestJobStart(mapReduceJobDefinition, testCluster));
        }
Beispiel #9
0
        public void CannotStopNonExistingJob()
        {
            ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();

            TestJobStop(testCluster, Guid.NewGuid().ToString());
        }