public void ICannotCallThe_Get_HDInsightJobOutputCmdlet_WithTaskLogsSwitch_NoDirectory() { using (IRunspace runspace = this.GetPowerShellRunspace()) { ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJob) .WithParameter(CmdletConstants.Cluster, testCluster.Name) .WithParameter(CmdletConstants.Credential, GetPSCredential(testCluster.HttpUserName, testCluster.HttpPassword)) .Invoke(); IEnumerable <AzureHDInsightJob> jobHistory = results.Results.ToEnumerable <AzureHDInsightJob>(); try { runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJobOutput) .WithParameter(CmdletConstants.Cluster, testCluster.Name) .WithParameter(CmdletConstants.Id, jobHistory.First().JobId) .WithParameter(CmdletConstants.DownloadTaskLogs, null) .Invoke(); Assert.Fail("test failed"); } catch (CmdletInvocationException invokeException) { var argException = invokeException.GetBaseException() as PSArgumentException; Assert.IsNotNull(argException); Assert.AreEqual(argException.ParamName, "taskLogsDirectory"); Assert.AreEqual(argException.Message, "Please specify the directory to download logs to."); } } }
public void ICanCallThe_Get_HDInsightJobOutputCmdlet_WithTaskLogsSwitch() { using (IRunspace runspace = this.GetPowerShellRunspace()) { ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJob) .WithParameter(CmdletConstants.Cluster, testCluster.Name) .WithParameter(CmdletConstants.Credential, GetPSCredential(testCluster.HttpUserName, testCluster.HttpPassword)) .Invoke(); IEnumerable <AzureHDInsightJob> jobHistory = results.Results.ToEnumerable <AzureHDInsightJob>(); DirectoryInfo taskLogsDirectory = Directory.CreateDirectory(Guid.NewGuid().ToString()); IPipelineResult outputContent = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJobOutput) .WithParameter(CmdletConstants.Cluster, testCluster.Name) .WithParameter(CmdletConstants.JobId, jobHistory.First().JobId) .WithParameter(CmdletConstants.DownloadTaskLogs, null) .WithParameter(CmdletConstants.TaskLogsDirectory, taskLogsDirectory.Name) .Invoke(); IEnumerable <FileInfo> result = taskLogsDirectory.EnumerateFiles(); Assert.IsTrue(result.Any()); } }
public virtual void WaitForJobWithId() { var hiveJobDefinition = new HiveJobCreateParameters() { JobName = "show tables jobDetails", Query = "show tables" }; var cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); using (var runspace = this.GetPowerShellRunspace()) { var results = runspace.NewPipeline() .AddCommand(CmdletConstants.NewAzureHDInsightHiveJobDefinition) .WithParameter(CmdletConstants.JobName, hiveJobDefinition.JobName) .WithParameter(CmdletConstants.Query, hiveJobDefinition.Query) .AddCommand(CmdletConstants.StartAzureHDInsightJob) .WithParameter(CmdletConstants.Cluster, cluster.ConnectionUrl) .WithParameter(CmdletConstants.Credential, IntegrationTestBase.GetPSCredential(cluster.HttpUserName, cluster.HttpPassword)) .Invoke(); Assert.AreEqual(1, results.Results.Count); var job = results.Results.First().BaseObject as Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.DataObjects.AzureHDInsightJob; results = runspace.NewPipeline() .AddCommand(CmdletConstants.WaitAzureHDInsightJob) .WithParameter(CmdletConstants.Credential, IntegrationTestBase.GetPSCredential(cluster.HttpUserName, cluster.HttpPassword)) .WithParameter(CmdletConstants.JobId, job.JobId) .WithParameter(CmdletConstants.Cluster, job.Cluster) .Invoke(); var completedJob = results.Results.ToEnumerable <AzureHDInsightJob>().FirstOrDefault(); Assert.IsNotNull(completedJob); Assert.AreEqual(job.JobId, completedJob.JobId); Assert.AreEqual("Completed", completedJob.State); } }
public virtual void WaitForJob() { var hiveJobDefinition = new HiveJobCreateParameters { JobName = "show tables jobDetails", Query = "show tables" }; // IHadoopClientExtensions.GetPollingInterval = () => 0; ClusterDetails cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); using (IRunspace runspace = this.GetPowerShellRunspace()) { IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.NewAzureHDInsightHiveJobDefinition) .WithParameter(CmdletConstants.JobName, hiveJobDefinition.JobName) .WithParameter(CmdletConstants.Query, hiveJobDefinition.Query) .AddCommand(CmdletConstants.StartAzureHDInsightJob) .WithParameter(CmdletConstants.Cluster, cluster.ConnectionUrl) .WithParameter(CmdletConstants.Credential, GetPSCredential(cluster.HttpUserName, cluster.HttpPassword)) .AddCommand(CmdletConstants.WaitAzureHDInsightJob) .WithParameter(CmdletConstants.Credential, GetPSCredential(cluster.HttpUserName, cluster.HttpPassword)) .Invoke(); Assert.AreEqual(1, results.Results.Count); Assert.AreEqual("Completed", results.Results.ToEnumerable <AzureHDInsightJob>().First().State); } }
public void ICanCallThe_Start_HDInsightJobsCmdlet_WithDebug() { var mapReduceJobDefinition = new AzureHDInsightMapReduceJobDefinition { JobName = "pi estimation jobDetails", ClassName = "pi", JarFile = TestConstants.WabsProtocolSchemeName + "container@hostname/examples.jar" }; using (IRunspace runspace = this.GetPowerShellRunspace()) { string expectedLogMessage = string.Format(CultureInfo.InvariantCulture, "Starting jobDetails '{0}'.", mapReduceJobDefinition.JobName); RunJobInPowershell( runspace, mapReduceJobDefinition, CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(), true, expectedLogMessage); } }
public void ICanCallThe_Get_HDInsightJobsCmdlet_WithNonExistantJobId() { using (IRunspace runspace = this.GetPowerShellRunspace()) { ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); string jobId = Guid.NewGuid().ToString(); IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJob) .WithParameter(CmdletConstants.Cluster, testCluster.ConnectionUrl) .WithParameter(CmdletConstants.Credential, GetPSCredential(testCluster.HttpUserName, testCluster.HttpPassword)) .WithParameter(CmdletConstants.Id, jobId) .Invoke(); Assert.AreEqual(results.Results.Count, 0); } }
public void ICanCallThe_Get_HDInsightJobsCmdlet_WithNonExistantJobId() { using (IRunspace runspace = this.GetPowerShellRunspace()) { ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); string jobId = Guid.NewGuid().ToString(); IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJobOutput) .WithParameter(CmdletConstants.Cluster, testCluster.Name) .WithParameter(CmdletConstants.Id, jobId) .WithParameter(CmdletConstants.StdErr, null) .Invoke(); Assert.IsTrue(results.Results.ToEnumerable <string>().All(string.IsNullOrEmpty)); } }
public void ICanCallThe_Get_HDInsightJobsCmdlet() { using (IRunspace runspace = this.GetPowerShellRunspace()) { ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJob) .WithParameter(CmdletConstants.Cluster, testCluster.ConnectionUrl) .WithParameter(CmdletConstants.Credential, GetPSCredential(testCluster.HttpUserName, testCluster.HttpPassword)) .Invoke(); IEnumerable <AzureHDInsightJob> jobHistory = results.Results.ToEnumerable <AzureHDInsightJob>(); JobList expectedJobHistory = HDInsightGetJobsCommandTests.GetJobHistory(testCluster.ConnectionUrl); Assert.AreEqual(expectedJobHistory.Jobs.Count, jobHistory.Count(), "Should have {0} jobs.", expectedJobHistory.Jobs.Count); } }
public virtual void WaitForInvalidJobDoesNotThrow() { var jobDetails = new JobDetails { JobId = Guid.NewGuid().ToString() }; var invalidJob = new AzureHDInsightJob(jobDetails, TestCredentials.WellKnownCluster.DnsName); // IHadoopClientExtensions.GetPollingInterval = () => 0; ClusterDetails cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); using (IRunspace runspace = this.GetPowerShellRunspace()) { runspace.NewPipeline() .AddCommand(CmdletConstants.WaitAzureHDInsightJob) .WithParameter(CmdletConstants.Credential, GetPSCredential(cluster.HttpUserName, cluster.HttpPassword)) .WithParameter(CmdletConstants.Job, invalidJob) .Invoke(); } }
public virtual void WaitForInvalidJobIdDoesNotThrow() { var jobDetails = new JobDetails() { JobId = Guid.NewGuid().ToString() }; var cluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); using (var runspace = this.GetPowerShellRunspace()) { runspace.NewPipeline() .AddCommand(CmdletConstants.WaitAzureHDInsightJob) .WithParameter(CmdletConstants.Credential, IntegrationTestBase.GetPSCredential(cluster.HttpUserName, cluster.HttpPassword)) .WithParameter(CmdletConstants.JobId, jobDetails.JobId) .WithParameter(CmdletConstants.Cluster, jobDetails.JobId) .Invoke(); } }
public void ICanCallThe_Get_HDInsightJobsCmdletWithJobId() { using (IRunspace runspace = this.GetPowerShellRunspace()) { ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJob) .WithParameter(CmdletConstants.Cluster, testCluster.ConnectionUrl) .WithParameter(CmdletConstants.Credential, GetPSCredential(testCluster.HttpUserName, testCluster.HttpPassword)) .Invoke(); var jobDetail = results.Results.ElementAt(0).ImmediateBaseObject as AzureHDInsightJobBase; Assert.IsNotNull(jobDetail); AzureHDInsightJob getJobDetailObj = GetJobWithID(runspace, jobDetail.JobId, testCluster); Assert.IsNotNull(getJobDetailObj); Assert.AreEqual(jobDetail.JobId, getJobDetailObj.JobId); } }
public virtual void ICanCallThe_NewHiveJob_Then_Start_HDInsightJobsCmdlet() { var hiveJobDefinition = new HiveJobCreateParameters { JobName = "show tables jobDetails", Query = "show tables" }; using (IRunspace runspace = this.GetPowerShellRunspace()) { IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.NewAzureHDInsightHiveJobDefinition) .WithParameter(CmdletConstants.JobName, hiveJobDefinition.JobName) .WithParameter(CmdletConstants.Query, hiveJobDefinition.Query) .Invoke(); Assert.AreEqual(1, results.Results.Count); AzureHDInsightHiveJobDefinition hiveJobFromPowershell = results.Results.ToEnumerable <AzureHDInsightHiveJobDefinition>().First(); ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); AzureHDInsightJob jobCreationDetails = RunJobInPowershell(runspace, hiveJobFromPowershell, testCluster); AzureHDInsightJob jobHistoryResult = GetJobsCmdletTests.GetJobWithID(runspace, jobCreationDetails.JobId, testCluster); } }
public void ICanCallThe_Get_HDInsightJobOutputCmdlet() { using (IRunspace runspace = this.GetPowerShellRunspace()) { ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJob) .WithParameter(CmdletConstants.Cluster, testCluster.Name) .WithParameter(CmdletConstants.Credential, GetPSCredential(testCluster.HttpUserName, testCluster.HttpPassword)) .Invoke(); IEnumerable <AzureHDInsightJob> jobHistory = results.Results.ToEnumerable <AzureHDInsightJob>(); IPipelineResult outputContent = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJobOutput) .WithParameter(CmdletConstants.Cluster, testCluster.Name) .WithParameter(CmdletConstants.Id, jobHistory.First().JobId) .Invoke(); string result = outputContent.Results.ToEnumerable <string>().First(); Assert.IsTrue(result.Length > 0); } }
public void ICanCallThe_Get_HDInsightJobsCmdlet_WithDebug() { using (IRunspace runspace = this.GetPowerShellRunspace()) { ClusterDetails testCluster = CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster(); var logWriter = new PowershellLogWriter(); BufferingLogWriterFactory.Instance = logWriter; IPipelineResult results = runspace.NewPipeline() .AddCommand(CmdletConstants.GetAzureHDInsightJob) .WithParameter(CmdletConstants.Cluster, testCluster.ConnectionUrl) .WithParameter(CmdletConstants.Credential, GetPSCredential(testCluster.HttpUserName, testCluster.HttpPassword)) .WithParameter(CmdletConstants.Debug, null) .Invoke(); IEnumerable <AzureHDInsightJob> jobHistory = results.Results.ToEnumerable <AzureHDInsightJob>(); JobList expectedJobHistory = HDInsightGetJobsCommandTests.GetJobHistory(testCluster.ConnectionUrl); Assert.AreEqual(expectedJobHistory.Jobs.Count, jobHistory.Count(), "Should have {0} jobs.", expectedJobHistory.Jobs.Count); string expectedLogMessage = "Listing jobs"; Assert.IsTrue(logWriter.Buffer.Any(message => message.Contains(expectedLogMessage))); BufferingLogWriterFactory.Reset(); } }
internal static AzureHDInsightJob RunJobInPowershell(IRunspace runspace, AzureHDInsightJobDefinition mapReduceJobDefinition) { return(RunJobInPowershell(runspace, mapReduceJobDefinition, CmdletScenariosTestCaseBase.GetHttpAccessEnabledCluster())); }