How to use _install_clients method in autotest

Best Python code snippet using autotest_python

installer.py

Source:installer.py Github

copy

Full Screen

...153 self._install_servusai()154 if self._args.listclients is True:155 self._list_clients()156 if self._args.clients is True:157 self._install_clients()158 if self._args.client is not None:159 self._install_client(self._args.client)160 def _list_clients(self):161 print("\nAvailable Clients:")162 for client in clients:163 print("\t", client['name'])164 print()165 def _install_ybot(self):166 print("\nInstall Y-Bot Core")167 self._download_bot("Y-Bot", ybot)168 def _install_servusai(self):169 print("\nInstall Servusai")170 self._download_bot("Servusai", servusai)171 def _install_clients(self):172 print("\nInstalling Clients")173 for client in clients:174 self._install_client(client['name'])175 def _install_client(self, name):176 for client in clients:177 if name.upper() == client['name'].upper():178 print("\nInstalling Client", name)179 self._do_client_install(client)180 return181 raise Exception("Unknown client", name)182 def _do_client_install(self, client):183 self._install_systemd_service(client)184 self._install_web_service(client)185 def _install_systemd_service(self, client):...

Full Screen

Full Screen

profilers.py

Source:profilers.py Github

copy

Full Screen

...38 def delete(self, profiler):39 super(profilers, self).delete(profiler)40 if profiler in self.add_log:41 del self.add_log[profiler]42 def _install_clients(self):43 """44 Install autotest on any current job hosts.45 """46 in_use_hosts = dict()47 # find hosts in use but not used by us48 for host in self.job.hosts:49 if host.hostname not in self.job.machines:50 # job.hosts include all host instances created on the fly.51 # We only care DUTs in job.machines which are52 # piped in from autoserv -m option.53 continue54 autodir = host.get_autodir()55 if not (autodir and autodir.startswith(PROFILER_TMPDIR)):56 in_use_hosts[host.hostname] = host57 logging.debug('Hosts currently in use: %s', set(in_use_hosts))58 # determine what valid host objects we already have installed59 profiler_hosts = set()60 for host, at, profiler_dir in self.installed_hosts.values():61 if host.path_exists(profiler_dir):62 profiler_hosts.add(host.hostname)63 else:64 # the profiler was wiped out somehow, drop this install65 logging.warning('The profiler client on %s at %s was deleted',66 host.hostname, profiler_dir)67 del self.installed_hosts[host.hostname]68 logging.debug('Hosts with profiler clients already installed: %s',69 profiler_hosts)70 # install autotest on any new hosts in use71 for hostname in set(in_use_hosts) - profiler_hosts:72 host = in_use_hosts[hostname]73 tmp_dir = host.get_tmp_dir(parent=PROFILER_TMPDIR)74 at = autotest.Autotest(host)75 at.install_no_autoserv(autodir=tmp_dir)76 self.installed_hosts[host.hostname] = (host, at, tmp_dir)77 # drop any installs from hosts no longer in job.hosts78 for hostname in profiler_hosts - set(in_use_hosts):79 del self.installed_hosts[hostname]80 def _get_hosts(self, host=None):81 """82 Returns a list of (Host, Autotest, install directory) tuples for hosts83 currently supported by this profiler. The returned Host object is always84 the one created by this profiler, regardless of what's passed in. If85 'host' is not None, all entries not matching that host object are86 filtered out of the list.87 """88 if host is None:89 return self.installed_hosts.values()90 if host.hostname in self.installed_hosts:91 return [self.installed_hosts[host.hostname]]92 return []93 def _get_local_profilers_dir(self, test, hostname):94 in_machine_dir = (95 os.path.basename(test.job.resultdir) in test.job.machines)96 if len(test.job.machines) > 1 and not in_machine_dir:97 local_dir = os.path.join(test.profdir, hostname)98 if not os.path.exists(local_dir):99 os.makedirs(local_dir)100 else:101 local_dir = test.profdir102 return local_dir103 def _get_failure_logs(self, autodir, test, host):104 """105 Collect the client logs from a profiler run and put them in a106 file named failure-*.log.107 """108 try:109 fd, path = tempfile.mkstemp(suffix='.log', prefix='failure-',110 dir=self._get_local_profilers_dir(test, host.hostname))111 os.close(fd)112 host.get_file(get_profiler_log_path(autodir), path)113 # try to collect any partial profiler logs114 self._get_profiler_logs(autodir, test, host)115 except (error.AutotestError, error.AutoservError):116 logging.exception('Profiler failure log collection failed')117 # swallow the exception so that we don't override an existing118 # exception being thrown119 def _get_all_failure_logs(self, test, hosts):120 for host, at, autodir in hosts:121 self._get_failure_logs(autodir, test, host)122 def _get_profiler_logs(self, autodir, test, host):123 results_dir = get_profiler_results_dir(autodir)124 local_dir = self._get_local_profilers_dir(test, host.hostname)125 self.job.remove_client_log(host.hostname, results_dir, local_dir)126 tempdir = tempfile.mkdtemp(dir=self.job.tmpdir)127 try:128 host.get_file(results_dir + '/', tempdir)129 except error.AutoservRunError:130 pass # no files to pull back, nothing we can do131 utils.merge_trees(tempdir, local_dir)132 shutil.rmtree(tempdir, ignore_errors=True)133 def _run_clients(self, test, hosts):134 """135 We initialize the profilers just before start because only then we136 know all the hosts involved.137 """138 hostnames = [host_info[0].hostname for host_info in hosts]139 profilers_args = [(p.name, p.args, p.dargs)140 for p in self.list]141 for host, at, autodir in hosts:142 control_script = standalone_profiler.generate_test(hostnames,143 host.hostname,144 profilers_args,145 180, None)146 try:147 at.run(control_script, background=True)148 except Exception:149 self._get_failure_logs(autodir, test, host)150 raise151 remote_results_dir = get_profiler_results_dir(autodir)152 local_results_dir = self._get_local_profilers_dir(test,153 host.hostname)154 self.job.add_client_log(host.hostname, remote_results_dir,155 local_results_dir)156 try:157 # wait for the profilers to be added158 standalone_profiler.wait_for_profilers(hostnames)159 except Exception:160 self._get_all_failure_logs(test, hosts)161 raise162 def before_start(self, test, host=None):163 # create host objects and install the needed clients164 # so later in start() we don't spend too much time165 self._install_clients()166 self._run_clients(test, self._get_hosts(host))167 def start(self, test, host=None):168 hosts = self._get_hosts(host)169 # wait for the profilers to start170 hostnames = [host_info[0].hostname for host_info in hosts]171 try:172 standalone_profiler.start_profilers(hostnames)173 except Exception:174 self._get_all_failure_logs(test, hosts)175 raise176 self.current_test = test177 def stop(self, test):178 assert self.current_test == test179 hosts = self._get_hosts()...

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