public NewAzureHDInsightHiveJobDefinitionCommand()
 {
     Arguments = new string[] {};
     Files = new string[] { };
     Defines = new Hashtable();
     job = new AzureHDInsightHiveJobDefinition();
 }
 public virtual JobSubmissionResponse SubmitHiveJob(AzureHDInsightHiveJobDefinition hiveJobDef)
 {
     var hiveJobParams = new HiveJobSubmissionParameters
     {
         Arguments = hiveJobDef.Arguments,
         Defines = hiveJobDef.Defines,
         File = hiveJobDef.File,
         Files = hiveJobDef.Files,
         Query = hiveJobDef.Query,
         StatusDir = hiveJobDef.StatusFolder
     };
     return HdInsightJobManagementClient.JobManagement.SubmitHiveJob(hiveJobParams);
 }
 public virtual JobSubmissionResponse SubmitHiveJob(AzureHDInsightHiveJobDefinition hiveJobDef)
 {
     var hiveJobParams = new HiveJobSubmissionParameters
     {
         Arguments = ConvertListToString(hiveJobDef.Arguments, "arg"),
         Defines = ConvertDefinesToString(hiveJobDef.Defines),
         File = hiveJobDef.File,
         Files = ConvertListToString(hiveJobDef.Files, "file"),
         Query = hiveJobDef.Query,
         StatusDir = hiveJobDef.StatusFolder,
         UserName = HdInsightJobManagementClient.Credentials.Username
     };
     return HdInsightJobManagementClient.JobManagement.SubmitHiveJob(hiveJobParams);
 }
Beispiel #4
0
        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")));
        }