internal static AzureHDInsightJob RunJobInPowershell(
            IRunspace runspace, AzureHDInsightJobDefinition mapReduceJobDefinition, ClusterDetails cluster, bool debug, string expectedLogMessage)
        {
            IPipelineResult result = null;
            if (debug)
            {
                var logWriter = new PowershellLogWriter();
                BufferingLogWriterFactory.Instance = logWriter;
                result =
                    runspace.NewPipeline()
                            .AddCommand(CmdletConstants.StartAzureHDInsightJob)
                            .WithParameter(CmdletConstants.Cluster, cluster.ConnectionUrl)
                            .WithParameter(CmdletConstants.Credential, GetPSCredential(cluster.HttpUserName, cluster.HttpPassword))
                            .WithParameter(CmdletConstants.JobDefinition, mapReduceJobDefinition)
                            .WithParameter(CmdletConstants.Debug, null)
                            .Invoke();

                Assert.IsTrue(logWriter.Buffer.Any(message => message.Contains(expectedLogMessage)));
                BufferingLogWriterFactory.Reset();
            }
            else
            {
                result =
                    runspace.NewPipeline()
                            .AddCommand(CmdletConstants.StartAzureHDInsightJob)
                            .WithParameter(CmdletConstants.Cluster, cluster.ConnectionUrl)
                            .WithParameter(CmdletConstants.Credential, GetPSCredential(cluster.HttpUserName, cluster.HttpPassword))
                            .WithParameter(CmdletConstants.JobDefinition, mapReduceJobDefinition)
                            .Invoke();
            }
            Assert.AreEqual(1, result.Results.Count);
            IEnumerable<AzureHDInsightJob> jobCreationCmdletResults = result.Results.ToEnumerable<AzureHDInsightJob>();
            AzureHDInsightJob jobCreationResults = jobCreationCmdletResults.First();
            Assert.IsNotNull(jobCreationResults.JobId, "Should get a non-null jobDetails id");

            return jobCreationResults;
        }
 protected virtual async Task<AzureHDInsightJob> StartJob(
     AzureHDInsightJobDefinition jobDefinition, AzureHDInsightClusterConnection currentConnection)
 {
     jobDefinition.ArgumentNotNull("jobDefinition");
     currentConnection.ArgumentNotNull("currentCluster");
     this.ValidateNotCanceled();
     var startJobCommand = ServiceLocator.Instance.Locate<IAzureHDInsightCommandFactory>().CreateStartJob();
     this.SetClient(startJobCommand);
     startJobCommand.Cluster = currentConnection.Cluster.Name;
     startJobCommand.Logger = this.Logger;
     startJobCommand.CurrentSubscription = this.CurrentSubscription;
     startJobCommand.JobDefinition = jobDefinition;
     this.ValidateNotCanceled();
     await startJobCommand.EndProcessing();
     return startJobCommand.Output.Last();
 }
        internal static AzureHDInsightJob RunJobInPowershell(
            IRunspace runspace, AzureHDInsightJobDefinition mapReduceJobDefinition, ClusterDetails cluster)
        {
            IPipelineResult results =
                runspace.NewPipeline()
                        .AddCommand(CmdletConstants.StartAzureHDInsightJob)
                        .WithParameter(CmdletConstants.Cluster, cluster.ConnectionUrl)
                        .WithParameter(CmdletConstants.Credential, GetPSCredential(cluster.HttpUserName, cluster.HttpPassword))
                        .WithParameter(CmdletConstants.JobDefinition, mapReduceJobDefinition)
                        .Invoke();
            Assert.AreEqual(1, results.Results.Count);
            IEnumerable<AzureHDInsightJob> jobCreationCmdletResults = results.Results.ToEnumerable<AzureHDInsightJob>();
            AzureHDInsightJob jobCreationResults = jobCreationCmdletResults.First();
            Assert.IsNotNull(jobCreationResults.JobId, "Should get a non-null jobDetails id");

            return jobCreationResults;
        }
 internal static AzureHDInsightJob RunJobInPowershell(IRunspace runspace, AzureHDInsightJobDefinition mapReduceJobDefinition)
 {
     return RunJobInPowershell(runspace, mapReduceJobDefinition, CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster());
 }
 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;
 }
 private static void TestJobLifecycle(AzureHDInsightJobDefinition mapReduceJobDefinition)
 {
     ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
     AzureHDInsightJob startedJob = TestJobStart(mapReduceJobDefinition, testCluster);
     TestJobStop(testCluster, startedJob.JobId);
 }
 private static AzureHDInsightJob TestJobStart(AzureHDInsightJobDefinition mapReduceJobDefinition)
 {
     ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster();
     return TestJobStart(mapReduceJobDefinition, testCluster);
 }