How to use _create_test_output_dir method in autotest

Best Python code snippet using autotest_python

autotest_remote.py

Source:autotest_remote.py Github

copy

Full Screen

...130 logging.debug('Failed to create %s', path)131 raise error.AutoservInstallError(132 'Unable to find a place to install Autotest; tried %s' %133 ', '.join(client_autodir_paths))134 def _create_test_output_dir(self, host, autodir):135 tmpdir = os.path.join(autodir, 'tmp')136 state_autodir = settings.get_value('COMMON', 'test_output_dir',137 default=tmpdir)138 host.run('mkdir -p %s' % utils.sh_escape(state_autodir))139 def get_fetch_location(self):140 repos = settings.get_value("PACKAGES", 'fetch_location', type=list,141 default=[])142 repos.reverse()143 return repos144 def install(self, host=None, autodir=None):145 self._install(host=host, autodir=autodir)146 def install_full_client(self, host=None, autodir=None):147 self._install(host=host, autodir=autodir, use_autoserv=False,148 use_packaging=False)149 def install_no_autoserv(self, host=None, autodir=None):150 self._install(host=host, autodir=autodir, use_autoserv=False)151 def _install_using_packaging(self, host, autodir):152 repos = self.get_fetch_location()153 if not repos:154 raise error.PackageInstallError("No repos to install an "155 "autotest client from")156 pkgmgr = packages.PackageManager(autodir, hostname=host.hostname,157 repo_urls=repos,158 do_locking=False,159 run_function=host.run,160 run_function_dargs=dict(timeout=600))161 # The packages dir is used to store all the packages that162 # are fetched on that client. (for the tests,deps etc.163 # too apart from the client)164 pkg_dir = os.path.join(autodir, 'packages')165 # clean up the autodir except for the packages directory166 host.run('cd %s && ls | grep -v "^packages$"'167 ' | xargs rm -rf && rm -rf .[^.]*' % autodir)168 pkgmgr.install_pkg('autotest', 'client', pkg_dir, autodir,169 preserve_install_dir=True)170 self._create_test_output_dir(host, autodir)171 logging.info("Installation of autotest completed")172 self.installed = True173 def _install_using_send_file(self, host, autodir):174 dirs_to_exclude = set(["tests", "site_tests", "deps", "profilers"])175 light_files = [os.path.join(self.source_material, f)176 for f in os.listdir(self.source_material)177 if f not in dirs_to_exclude]178 # there should be one and only one grubby tarball179 grubby_glob = os.path.join(self.source_material,180 "deps/grubby/grubby-*.tar.bz2")181 grubby_tarball_paths = glob.glob(grubby_glob)182 if grubby_tarball_paths:183 grubby_tarball_path = grubby_tarball_paths[0]184 if os.path.exists(grubby_tarball_path):185 light_files.append(grubby_tarball_path)186 host.send_file(light_files, autodir, delete_dest=True)187 profilers_autodir = os.path.join(autodir, 'profilers')188 profilers_init = os.path.join(self.source_material, 'profilers',189 '__init__.py')190 host.run("mkdir -p %s" % profilers_autodir)191 host.send_file(profilers_init, profilers_autodir, delete_dest=True)192 dirs_to_exclude.discard("profilers")193 # create empty dirs for all the stuff we excluded194 commands = []195 for path in dirs_to_exclude:196 abs_path = os.path.join(autodir, path)197 abs_path = utils.sh_escape(abs_path)198 commands.append("mkdir -p '%s'" % abs_path)199 commands.append("touch '%s'/__init__.py" % abs_path)200 host.run(';'.join(commands))201 def _install(self, host=None, autodir=None, use_autoserv=True,202 use_packaging=True):203 """204 Install autotest.205 :param host A Host instance on which autotest will be installed206 :param autodir Location on the remote host to install to207 :param use_autoserv Enable install modes that depend on the client208 running with the autoserv harness209 :param use_packaging Enable install modes that use the packaging system210 @exception AutoservError If it wasn't possible to install the client211 after trying all available methods212 """213 if not host:214 host = self.host215 if not self.got:216 self.get()217 host.wait_up(timeout=30)218 host.setup()219 logging.info("Installing autotest on %s", host.hostname)220 if self.server_system_wide_install:221 msg_install = ("Autotest seems to be installed in the "222 "client on a system wide location, proceeding...")223 logging.info("Verifying client package install")224 if _client_system_wide_install(host):225 logging.info(msg_install)226 self.installed = True227 return228 install_cmd = INSTALL_CLIENT_CMD_MAPPING.get(self.os_vendor, None)229 if install_cmd is not None:230 logging.info(msg_install)231 host.run(install_cmd)232 if _client_system_wide_install(host):233 logging.info("Autotest seems to be installed in the "234 "client on a system wide location, proceeding...")235 self.installed = True236 return237 raise error.AutoservError("The autotest client package "238 "does not seem to be installed "239 "on %s" % host.hostname)240 # set up the autotest directory on the remote machine241 if not autodir:242 autodir = self.get_install_dir(host)243 logging.info('Using installation dir %s', autodir)244 host.set_autodir(autodir)245 host.run('mkdir -p %s' % utils.sh_escape(autodir))246 # make sure there are no files in $AUTODIR/results247 results_path = os.path.join(autodir, 'results')248 host.run('rm -rf %s/*' % utils.sh_escape(results_path),249 ignore_status=True)250 # Fetch the autotest client from the nearest repository251 if use_packaging:252 try:253 self._install_using_packaging(host, autodir)254 self._create_test_output_dir(host, autodir)255 logging.info("Installation of autotest completed")256 self.installed = True257 return258 except (error.PackageInstallError, error.AutoservRunError,259 SettingsError), e:260 logging.info("Could not install autotest using the packaging "261 "system: %s. Trying other methods", e)262 # try to install from file or directory263 if self.source_material:264 supports_autoserv_packaging = settings.get_value("PACKAGES",265 "serve_packages_from_autoserv",266 type=bool)267 # Copy autotest recursively268 if supports_autoserv_packaging and use_autoserv:269 self._install_using_send_file(host, autodir)270 else:271 host.send_file(self.source_material, autodir, delete_dest=True)272 self._create_test_output_dir(host, autodir)273 logging.info("Installation of autotest completed")274 self.installed = True275 return276 raise error.AutoservError('Could not install autotest on '277 'target machine: %s' % host.name)278 def uninstall(self, host=None):279 """280 Uninstall (i.e. delete) autotest. Removes the autotest client install281 from the specified host.282 :params host a Host instance from which the client will be removed283 """284 if not self.installed:285 return286 if self.server_system_wide_install:...

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