How to use _add_drone method in autotest

Best Python code snippet using autotest_python

scheduler.py

Source:scheduler.py Github

copy

Full Screen

...31 for cluster in self.drone_cluster:32 for drone in cluster:33 yield drone34 def register_drone(self, drone: Drone):35 self._add_drone(drone)36 def unregister_drone(self, drone: Drone):37 for cluster in self.drone_cluster:38 try:39 cluster.remove(drone)40 except ValueError:41 pass42 else:43 if len(cluster) == 0:44 self.drone_cluster.remove(cluster)45 def _add_drone(self, drone: Drone, drone_resources: Dict = None):46 minimum_distance_cluster = None47 distance = float("Inf")48 if len(self.drone_cluster) > 0:49 for cluster in self.drone_cluster:50 current_distance = 051 for key in {*cluster[0].pool_resources, *drone.pool_resources}:52 if drone_resources:53 current_distance += abs(54 cluster[0].theoretical_available_resources.get(key, 0)55 - drone_resources.get(key, 0)56 )57 else:58 current_distance += abs(59 cluster[0].theoretical_available_resources.get(key, 0)60 - drone.theoretical_available_resources.get(key, 0)61 )62 if current_distance < distance:63 minimum_distance_cluster = cluster64 distance = current_distance65 if distance < 1:66 minimum_distance_cluster.append(drone)67 else:68 self.drone_cluster.append([drone])69 else:70 self.drone_cluster.append([drone])71 def update_drone(self, drone: Drone):72 self.unregister_drone(drone)73 self._add_drone(drone)74 async def run(self):75 async with Scope() as scope:76 scope.do(self._collect_jobs())77 async for _ in interval(self.interval):78 for job in self.job_queue.copy():79 best_match = self._schedule_job(job)80 if best_match:81 await best_match.schedule_job(job)82 self.job_queue.remove(job)83 await sampling_required.put(self.job_queue)84 self.unregister_drone(best_match)85 left_resources = best_match.theoretical_available_resources86 left_resources = {87 key: value - job.resources.get(key, 0)88 for key, value in left_resources.items()89 }90 self._add_drone(best_match, left_resources)91 if (92 not self._collecting93 and not self.job_queue94 and self._processing.levels.jobs == 095 ):96 break97 await sampling_required.put(self)98 async def _collect_jobs(self):99 async for job in self._stream_queue:100 self.job_queue.append(job)101 await self._processing.increase(jobs=1)102 # TODO: logging happens with each job103 await sampling_required.put(self.job_queue)104 self._collecting = False...

Full Screen

Full Screen

site_drone_manager.py

Source:site_drone_manager.py Github

copy

Full Screen

...43 """44 logging.info('killing %s', process)45 drone = self._get_drone_for_process(process)46 drone.queue_kill_process(process)47 def _add_drone(self, hostname):48 """49 Forked from drone_manager.py50 Catches AutoservRunError if the drone fails initialization and does not51 add it to the list of usable drones.52 @param hostname: Hostname of the drone we are trying to add.53 """54 logging.info('Adding drone %s' % hostname)55 drone = drones.get_drone(hostname)56 if drone:57 try:58 drone.call('initialize', self.absolute_path(''))59 except error.AutoservRunError as e:60 logging.error('Failed to initialize drone %s with error: %s',61 hostname, e)...

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