public void CreatePigJob() { var args = new[] { "arg1", "arg2" }; const string file = "file"; const string status = "folder"; const string query = "pigquery"; var files = new[] { "file1", "file2" }; var cmdlet = new NewAzureHDInsightPigJobDefinitionCommand { CommandRuntime = commandRuntimeMock.Object, HDInsightJobClient = hdinsightJobManagementMock.Object, Arguments = args, Query = query, File = file, Files = files, StatusFolder = status }; cmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify( f => f.WriteObject( It.Is<AzureHDInsightPigJobDefinition>( job => job.Query == query && job.Arguments.Count == args.Length && job.Files.Count == files.Length && job.File == file && job.StatusFolder == status))); }
public void CreateHiveJob() { var args = new[] { "arg1", "arg2" }; var defines = new Dictionary<string, string> { {"hive.1", "val1"}, {"hive.2", "val2"} }; const string query = "show tables;"; const string name = "hivejob"; const string file = "file"; const string status = "folder"; var files = new[] { "file1", "file2" }; var cmdlet = new NewAzureHDInsightHiveJobDefinitionCommand { CommandRuntime = commandRuntimeMock.Object, HDInsightJobClient = hdinsightJobManagementMock.Object, Arguments = args, JobName = name, Query = query, File = file, Files = files, RunAsFileJob = false, StatusFolder = status }; foreach (var define in defines) { cmdlet.Defines.Add(define.Key, define.Value); } cmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify( f => f.WriteObject( It.Is<AzureHDInsightHiveJobDefinition>( job => job.Defines.Count == defines.Count && job.Query == query && job.JobName == name && job.RunAsFileJob == false && job.File == file && job.Files.Count == files.Length && job.StatusFolder == status))); }
public void CreateStreamingJob() { var args = new[] { "arg1", "arg2" }; var defines = new Dictionary<string, string> { {"hive.1", "val1"}, {"hive.2", "val2"} }; const string status = "folder"; const string inputpath = "input"; const string outputpath = "output"; const string mapper = "mapper.exe"; const string reducer = "reducer.exe"; const string file = "file"; var cmdlet = new NewAzureHDInsightStreamingMapReduceJobDefinitionCommand { CommandRuntime = commandRuntimeMock.Object, HDInsightJobClient = hdinsightJobManagementMock.Object, Arguments = args, File = file, StatusFolder = status, InputPath = inputpath, OutputPath = outputpath, Mapper = mapper, Reducer = reducer }; foreach (var define in defines) { cmdlet.Defines.Add(define.Key, define.Value); } cmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify( f => f.WriteObject( It.Is<AzureHDInsightStreamingMapReduceJobDefinition>( job => job.Arguments.Count == args.Length && job.File == file && job.StatusFolder == status && job.Input == inputpath && job.Output == outputpath && job.Mapper == mapper && job.Reducer == reducer && job.Defines.Count == defines.Count))); }
public void StartJob() { // Update HDInsight Management properties for Job. SetupManagementClientForJobTests(); var cmdlet = new StartAzureHDInsightJobCommand { CommandRuntime = commandRuntimeMock.Object, HDInsightJobClient = hdinsightJobManagementMock.Object, HDInsightManagementClient = hdinsightManagementMock.Object, HttpCredential = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()), ClusterName = ClusterName }; var args = new[] { "arg1", "arg2" }; const string query = "show tables;"; const string name = "hivejob"; var hivedef = new AzureHDInsightHiveJobDefinition { JobName = name, Query = query, }; foreach (var arg in args) { hivedef.Arguments.Add(arg); } cmdlet.JobDefinition = hivedef; const string jobid = "jobid_1984120_001"; var jobsub = new JobSubmissionResponse { JobSubmissionJsonResponse = new JobSubmissionJsonResponse { Id = jobid }, StatusCode = HttpStatusCode.OK }; hdinsightJobManagementMock.Setup( c => c.SubmitHiveJob( It.Is<AzureHDInsightHiveJobDefinition>( def => def.JobName == name && def.Query == query && def.Arguments.Count == args.Length))) .Returns(jobsub) .Verifiable(); var getresponse = new JobGetResponse { StatusCode = HttpStatusCode.OK, JobDetail = new JobDetailRootJsonObject { Completed = "false", User = cmdlet.HttpCredential.UserName, Id = jobid, Status = new Status(), Userargs = new Userargs() } }; hdinsightJobManagementMock.Setup(c => c.GetJob(jobsub.JobSubmissionJsonResponse.Id)).Returns(getresponse).Verifiable(); cmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify( f => f.WriteObject( It.Is<AzureHDInsightJob>( job => job.Cluster == ClusterName && job.JobId == jobid && job.Completed == "false"))); }
public void CreateMRJob() { var args = new[] { "arg1", "arg2" }; var defines = new Dictionary<string, string> { {"hive.1", "val1"}, {"hive.2", "val2"} }; const string name = "mrjob"; const string status = "folder"; const string classname = "class"; const string jar = "jar"; var jars = new[] { "jar1" }; var files = new[] { "file1", "file2" }; var cmdlet = new NewAzureHDInsightMapReduceJobDefinitionCommand { CommandRuntime = commandRuntimeMock.Object, HDInsightJobClient = hdinsightJobManagementMock.Object, Arguments = args, Files = files, JobName = name, ClassName = classname, JarFile = jar, LibJars = jars, StatusFolder = status }; foreach (var define in defines) { cmdlet.Defines.Add(define.Key, define.Value); } cmdlet.ExecuteCmdlet(); commandRuntimeMock.VerifyAll(); commandRuntimeMock.Verify( f => f.WriteObject( It.Is<AzureHDInsightMapReduceJobDefinition>( job => job.Arguments.Count == args.Length && job.Files.Count == files.Length && job.JobName == name && job.ClassName == classname && job.JarFile == jar && job.LibJars.Count == jars.Length && job.StatusFolder == status))); }