How to use _schedule_hostless_job method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...601 only_hostless=not _inline_host_acquisition)602 if not queue_entries:603 return []604 return queue_entries605 def _schedule_hostless_job(self, queue_entry):606 """Schedule a hostless (suite) job.607 @param queue_entry: The queue_entry representing the hostless job.608 """609 self.add_agent_task(HostlessQueueTask(queue_entry))610 # Need to set execution_subdir before setting the status:611 # After a restart of the scheduler, agents will be restored for HQEs in612 # Starting, Running, Gathering, Parsing or Archiving. To do this, the613 # execution_subdir is needed. Therefore it must be set before entering614 # one of these states.615 # Otherwise, if the scheduler was interrupted between setting the status616 # and the execution_subdir, upon it's restart restoring agents would617 # fail.618 # Is there a way to get a status in one of these states without going619 # through this code? Following cases are possible:620 # - If it's aborted before being started:621 # active bit will be 0, so there's nothing to parse, it will just be622 # set to completed by _find_aborting. Critical statuses are skipped.623 # - If it's aborted or it fails after being started:624 # It was started, so this code was executed.625 queue_entry.update_field('execution_subdir', 'hostless')626 queue_entry.set_status(models.HostQueueEntry.Status.STARTING)627 def _schedule_host_job(self, host, queue_entry):628 """Schedules a job on the given host.629 1. Assign the host to the hqe, if it isn't already assigned.630 2. Create a SpecialAgentTask for the hqe.631 3. Activate the hqe.632 @param queue_entry: The job to schedule.633 @param host: The host to schedule the job on.634 """635 if self.host_has_agent(host):636 host_agent_task = list(self._host_agents.get([0].task637 subject = 'Host with agents assigned to an HQE'638 message = ('HQE: %s assigned host %s, but the host has '639 'agent: %s for queue_entry %s. The HQE '640 'will have to try and acquire a host next tick ' %641 (queue_entry, host.hostname, host_agent_task,642 host_agent_task.queue_entry))643 email_manager.manager.enqueue_notify_email(subject, message)644 else:645 self._host_scheduler.schedule_host_job(host, queue_entry)646 def _schedule_new_jobs(self):647 """648 Find any new HQEs and call schedule_pre_job_tasks for it.649 This involves setting the status of the HQE and creating a row in the650 db corresponding the the special task, through651 scheduler_models._queue_special_task. The new db row is then added as652 an agent to the dispatcher through _schedule_special_tasks and653 scheduled for execution on the drone through _handle_agents.654 """655 queue_entries = self._refresh_pending_queue_entries()656 key = 'scheduler.jobs_per_tick'657 new_hostless_jobs = 0658 new_jobs_with_hosts = 0659 new_jobs_need_hosts = 0660 host_jobs = []661 logging.debug('Processing %d queue_entries', len(queue_entries))662 for queue_entry in queue_entries:663 if queue_entry.is_hostless():664 self._schedule_hostless_job(queue_entry)665 new_hostless_jobs = new_hostless_jobs + 1666 else:667 host_jobs.append(queue_entry)668 new_jobs_need_hosts = new_jobs_need_hosts + 1669 autotest_stats.Gauge(key).send('new_hostless_jobs', new_hostless_jobs)670 if not host_jobs:671 return672 if not _inline_host_acquisition:673 message = ('Found %s jobs that need hosts though '674 '_inline_host_acquisition=%s. Will acquire hosts.' %675 ([str(job) for job in host_jobs],676 _inline_host_acquisition))677 email_manager.manager.enqueue_notify_email(678 'Processing unexpected host acquisition requests', message)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?