How to use _get_profiler_logs method in autotest

Best Python code snippet using autotest_python

profilers.py

Source:profilers.py Github

copy

Full Screen

...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()180 # wait for the profilers to stop181 hostnames = [host_info[0].hostname for host_info in hosts]182 try:183 standalone_profiler.stop_profilers(hostnames)184 except Exception:185 self._get_all_failure_logs(test, hosts)186 raise187 def report(self, test, host=None):188 assert self.current_test == test189 hosts = self._get_hosts(host)190 # when running on specific hosts we cannot wait for the other191 # hosts to sync with us192 if not host:193 hostnames = [host_info[0].hostname for host_info in hosts]194 try:195 standalone_profiler.finish_profilers(hostnames)196 except Exception:197 self._get_all_failure_logs(test, hosts)198 raise199 # pull back all the results200 for host, at, autodir in hosts:201 self._get_profiler_logs(autodir, test, host)202 def handle_reboot(self, host):203 if self.current_test:204 test = self.current_test205 for profiler in self.list:206 if not profiler.supports_reboot:207 msg = 'profiler %s does not support rebooting during tests'208 msg %= profiler.name209 self.job.record('WARN', os.path.basename(test.outputdir),210 None, msg)211 self.report(test, host)212 self.before_start(test, host)...

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