Exemplo n.º 1
0
        public async Task <IActionResult> OnPostCreateAndSubmitASBJobAsync()
        {
            try
            {
                string username = "******";
                string password = "******";

                //AuthenticateUserPassword
                sb.AppendLine(String.Format("username: {0}, password: {1}", username, password));
                string sessionCode = await AuthenticateUserPasswordAsync(username, password);

                //string sessionCode = AuthenticateUserKeycloakOpenId(openIdToken);
                sb.AppendLine(String.Format("sessionCode: {0}", sessionCode));

                //CancelJob(2, sessionCode);

                //CreateJobSpecification
                JobSpecificationExt jobSpec = CreateJobSpecification();
                sb.AppendLine(String.Format("JobSpecification created"));
                sb.AppendLine(jobSpec.ToString());

                //CreateJob
                SubmittedJobInfoExt submittedJob = await CreateJobAsync(jobSpec, sessionCode);

                sb.AppendLine(String.Format("Job {0} created", submittedJob.Id));
                sb.AppendLine(submittedJob.ToString());

                //FileUpload
                //UploadInputFiles((long)submittedJob.Id, submittedJob.Tasks?.Select(s => s.Id).ToList(), sessionCode);
                //sb.AppendLine(String.Format("All files uploaded"));

                //SubmitJob
                SubmitJobAsync((long)submittedJob.Id, sessionCode);
                sb.AppendLine(String.Format("Job submitted"));

                AsbSubmittedJob = (long)submittedJob.Id;

                while (submittedJob.State != JobStateExt.Running)
                {
                    Thread.Sleep(30000);
                    submittedJob = await GetCurrentInfoForJobAsync((long)submittedJob.Id, sessionCode);
                }

                sb.AppendLine(String.Format("Job is running"));

                ResponseContent = sb.ToString();
            }
            catch (Exception e)
            {
                ResponseContent = e.Message;
            }
            return(Page());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostCreateAndSubmitTestJobAsync()
        {
            string response = "";

            try
            {
                string username    = "******";
                string password    = "******";
                string openIdToken = ""; // Fill the OpenId token for testing.

                //AuthenticateUserPassword
                sb.AppendLine(String.Format("username: {0}, password: {1}", username, password));
                string sessionCode = await AuthenticateUserPasswordAsync(username, password);

                //string sessionCode = AuthenticateUserKeycloakOpenId(openIdToken);
                sb.AppendLine(String.Format("sessionCode: {0}", sessionCode));

                //CreateJobSpecification
                JobSpecificationExt jobSpec = CreateJobSpecification();
                sb.AppendLine(String.Format("JobSpecification created"));
                sb.AppendLine(jobSpec.ToString());

                //CreateJob
                SubmittedJobInfoExt submittedJob = await CreateJobAsync(jobSpec, sessionCode);

                sb.AppendLine(String.Format("Job {0} created", submittedJob.Id));
                sb.AppendLine(submittedJob.ToString());

                //FileUpload
                UploadInputFilesAsync((long)submittedJob.Id, submittedJob.Tasks?.Select(s => s.Id).ToList(), sessionCode);
                sb.AppendLine(String.Format("All files uploaded"));

                //SubmitJob
                SubmitJobAsync((long)submittedJob.Id, sessionCode);
                sb.AppendLine(String.Format("Job submitted"));

                //MonitorJob
                lastSubmittedJobId = (long)submittedJob.Id; //TODO remove later - only for getCurrentJobInfo
                MonitorJob(submittedJob, sessionCode);

                ResponseContent = sb.ToString();
            }
            catch (Exception e)
            {
                ResponseContent = e.Message;
            }
            return(Page());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnPostTestSubmitAndCancelJobAsync()
        {
            try
            {
                string username = "******";
                string password = "******";

                //AuthenticateUserPassword
                sb.AppendLine(String.Format("username: {0}, password: {1}", username, password));
                string sessionCode = await AuthenticateUserPasswordAsync(username, password);

                sb.AppendLine(String.Format("sessionCode: {0}", sessionCode));

                //CreateJobSpecification
                JobSpecificationExt jobSpec = CreateJobSpecification();
                sb.AppendLine(String.Format("JobSpecification created"));
                sb.AppendLine(jobSpec.ToString());

                //CreateJob
                SubmittedJobInfoExt submittedJob = await CreateJobAsync(jobSpec, sessionCode);

                sb.AppendLine(String.Format("Job {0} created", submittedJob.Id));
                sb.AppendLine(submittedJob.ToString());

                //FileUpload
                UploadInputFilesAsync((long)submittedJob.Id, submittedJob.Tasks?.Select(s => s.Id).ToList(), sessionCode);
                sb.AppendLine(String.Format("All files uploaded"));

                //SubmitJob
                SubmitJobAsync((long)submittedJob.Id, sessionCode);
                sb.AppendLine(String.Format("Job submitted"));

                //TODO DELETE LATER - only for getCurrentInfoForJob
                lastSubmittedJobId = (long)submittedJob.Id;

                //wait for job to be in running state and then cancel this job and delete job content on cluster
                while (true)
                {
                    submittedJob = await GetCurrentInfoForJobAsync((long)submittedJob.Id, sessionCode);

                    if (submittedJob.State == JobStateExt.Running)
                    {
                        sb.AppendLine(String.Format("Job {0} state: {1}", submittedJob.Id, submittedJob.State));

                        //CancelJob
                        sb.AppendLine(String.Format("Canceling job {0} ...", submittedJob.Id));
                        submittedJob = await CancelJobAsync((long)submittedJob.Id, sessionCode);

                        sb.AppendLine(String.Format("Job {0} was canceled.", submittedJob.Id));

                        //DeleteJob
                        sb.AppendLine(String.Format("Deleting job {0} ...", submittedJob.Id));
                        string deleteJobResponse = await DeleteJobAsync((long)submittedJob.Id, sessionCode);

                        sb.AppendLine(deleteJobResponse);

                        break;
                    }
                    Thread.Sleep(30000);
                }

                ResponseContent = sb.ToString();
            }
            catch (Exception e)
            {
                ResponseContent = e.Message;
            }

            return(Page());
        }