How to use _can_start_agent method in autotest

Best Python code snippet using autotest_python

monitor_db.py

Source:monitor_db.py Github

copy

Full Screen

...771 # tasks against the host, and it must be set772 # in addition to is_active, is_complete and success.773 agent.task.epilog()774 agent.task.abort()775 def _can_start_agent(self, agent, have_reached_limit):776 # always allow zero-process agents to run777 if agent.task.num_processes == 0:778 return True779 # don't allow any nonzero-process agents to run after we've reached a780 # limit (this avoids starvation of many-process agents)781 if have_reached_limit:782 return False783 # total process throttling784 max_runnable_processes = _drone_manager.max_runnable_processes(785 agent.task.owner_username,786 agent.task.get_drone_hostnames_allowed())787 if agent.task.num_processes > max_runnable_processes:788 return False789 return True790 def _handle_agents(self):791 """792 Handles agents of the dispatcher.793 Appropriate Agents are added to the dispatcher through794 _schedule_running_host_queue_entries. These agents each795 have a task. This method runs the agents task through796 agent.tick() leading to:797 agent.start798 prolog -> AgentTasks prolog799 For each queue entry:800 sets host status/status to Running801 set started_on in afe_host_queue_entries802 run -> AgentTasks run803 Creates PidfileRunMonitor804 Queues the autoserv command line for this AgentTask805 via the drone manager. These commands are executed806 through the drone managers execute actions.807 poll -> AgentTasks/BaseAgentTask poll808 checks the monitors exit_code.809 Executes epilog if task is finished.810 Executes AgentTasks _finish_task811 finish_task is usually responsible for setting the status812 of the HQE/host, and updating it's active and complete fileds.813 agent.is_done814 Removed the agent from the dispatchers _agents queue.815 Is_done checks the finished bit on the agent, that is816 set based on the Agents task. During the agents poll817 we check to see if the monitor process has exited in818 it's finish method, and set the success member of the819 task based on this exit code.820 """821 num_started_this_tick = 0822 num_finished_this_tick = 0823 have_reached_limit = False824 # iterate over copy, so we can remove agents during iteration825 logging.debug('Handling %d Agents', len(self._agents))826 for agent in list(self._agents):827 self._log_extra_msg('Processing Agent with Host Ids: %s and '828 'queue_entry ids:%s' % (agent.host_ids,829 agent.queue_entry_ids))830 if not agent.started:831 if not self._can_start_agent(agent, have_reached_limit):832 have_reached_limit = True833 logging.debug('Reached Limit of allowed running Agents.')834 continue835 num_started_this_tick += agent.task.num_processes836 self._log_extra_msg('Starting Agent')837 agent.tick()838 self._log_extra_msg('Agent tick completed.')839 if agent.is_done():840 num_finished_this_tick += agent.task.num_processes841 self._log_extra_msg("Agent finished")842 self.remove_agent(agent)843 autotest_stats.Gauge('scheduler.jobs_per_tick').send(844 'agents_started', num_started_this_tick)845 autotest_stats.Gauge('scheduler.jobs_per_tick').send(...

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:

YouTube

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?

Helpful

NotHelpful