How to use check_environment method in lisa

Best Python code snippet using lisa_python

ezbench_setup.py

Source:ezbench_setup.py Github

copy

Full Screen

...101 # if not self.ssh_connection_a or not self.ssh_connection_b:102 # bash.message('err', 'please run this script under SSH connection')103 # sys.exit(1)104 # ===================================================================105 def check_environment(self, custom_message):106 """107 :param custom_message:108 :return: check if a DUT is in the automated system in order to sent109 messages to watchdog webpage : http://bifrost.intel.com:2020/watchdog110 """111 if self.automated_system:112 bash.message('info', 'sending a message to watchdog webpage')113 apiutils.update_watchdog_db(114 self.raspberry_n,115 self.switch_n,116 Suite=self.suite,117 Status=custom_message)118 sleep(3)119 def gfx_stack(self):120 """121 :return: here are two possibles scenarios for this function :122 1 - (DUT in the automated system) : check if a graphic stack package123 was installed during clonezilla installation, if not this script will124 not continue.125 2 - (DUT outside of the automated system) : check if a graphic stack126 is installed in the system, otherwise this function will help you to127 install a graphic stack from http://linuxgraphics.intel.com/deb.128 """129 # Checking for graphic stack from linuxgraphics.intel.com130 has_gfx_stack = bash.get_output("dpkg -l | grep 01.org").decode(131 "utf-8")132 has_gfx_stack_name = bash.get_output(133 "dpkg -l | grep 01.org | awk '{print $2}'").decode("utf-8")134 if not has_gfx_stack:135 while True:136 bash.message(137 'warn', 'no graphic stack was detected in the system, '138 'please install one graphic stack')139 self.check_environment(140 '(err) no graphic stack was detected in the system,'141 ' please install a graphic stack')142 if self.automated_system:143 sys.exit(1)144 workweek_list = \145 bash.get_output(146 "w3m -dump " + self.debian_packages_url +147 " | awk '{print $2}' | grep WW | "148 "sed 's|/||g'").decode("utf-8").split()149 for ww in workweek_list:150 print('-> ' + ww)151 workweek_input = input(152 bash.BLUE + '>>> (info)' + bash.END +153 ' enter a workweek (case sensitive) : ')154 if workweek_input not in workweek_list:155 bash.message(156 'err', 'invalid workweek, '157 'please select a valid one')158 bash.message('info', 'press any key to continue ...')159 input()160 os.system('clear')161 else:162 workweek_selection = workweek_input163 break164 while True:165 os.system('clear')166 bash.message(167 'info', 'please select a graphic stack to install')168 folder_list = \169 bash.get_output(170 'w3m -dump ' +171 os.path.join(172 self.debian_packages_url, workweek_selection) +173 " | grep -w \"\["174 "DIR\]\" | awk '{print $2}' | sed "175 "'s|/||g'").decode("utf-8").split()176 folder_dict = {}177 count = 1178 for folder in folder_list:179 to_update = {str(count): folder}180 folder_dict.update(to_update)181 count += 1182 count = 1183 for folder in folder_list:184 print('(' + str(count) + ') ' + folder)185 count += 1186 folder_input = input(187 bash.BLUE + '>>> (info)' + bash.END + ' enter a number : ')188 if folder_input in folder_dict:189 folder_to_download = folder_dict[folder_input]190 full_link_to_download = os.path.join(191 self.debian_packages_url, workweek_selection,192 folder_to_download)193 stack_folder = os.path.join(194 '/home', self.dut_user, 'graphic_stack_packages')195 if not os.path.exists(stack_folder):196 bash.message(197 'info', 'creating folder '198 '(graphic_stack_packages) into (' +199 stack_folder + ')', '')200 bash.return_command_status('mkdir -p ' + stack_folder)201 bash.message(202 'info', 'downloading graphic stack debian '203 'package (' + folder_to_download + ')', '')204 bash.return_command_status(205 'cd ' + stack_folder + " && wget -q -A '.deb' -np"206 " -nd -m -E -k -K -e robots=off -l 1 " +207 full_link_to_download)208 bash.message('info', 'installing the graphic stack', '')209 bash.return_command_status(210 'cd ' + stack_folder + ' && sudo dpkg -i '211 '--force-overwrite *.deb')212 break213 else:214 bash.message(215 'err', 'invalid selection, please select a valid one')216 bash.message(217 'info', 'press any key to continue ...')218 input()219 os.system('clear')220 elif has_gfx_stack:221 bash.message(222 'info', 'the following graphic stack was detected in '223 'the system')224 self.check_environment(225 'the following graphic stack was detected in the system (' +226 has_gfx_stack_name + ')')227 bash.message(228 'info', '(' + bash.CYAN + has_gfx_stack_name + bash.END + ')')229 def check_gfx_stack_for_xorg_xserver(self):230 """231 check if all the following condition are met for xorg-xserver232 debian package233 """234 custom_path = os.path.join('/opt', 'X11R7')235 xorg_binary = os.path.join(custom_path, 'bin', 'Xorg')236 modesetting_library = \237 os.path.join(238 custom_path, 'lib', 'xorg', 'modules', 'drivers',239 'modesetting_drv.so')240 xorg_conf = os.path.join('/etc', 'X11', 'xorg.conf')241 which_xorg = bash.get_output('which Xorg').decode("utf-8")242 checklist = [243 xorg_binary,244 modesetting_library,245 xorg_conf246 ]247 if os.path.exists(custom_path):248 for element in checklist:249 bash.message(250 'info',251 'checking if (' + element + ') exists in the system')252 if not os.path.exists(element):253 self.check_environment(254 '(err) (' + os.path.basename(element) +255 ') does not exists')256 bash.message(257 'err',258 '(' + os.path.basename(element) +259 ') does not exists, please check the graphic stack')260 sys.exit(1)261 else:262 self.check_environment(263 '(info) (' + os.path.basename(element) + ') exists')264 bash.message(265 'info', '(' + os.path.basename(element) + ') exists')266 if which_xorg != '/opt/X11R7/bin/Xorg':267 self.check_environment(268 '(err) xorg binary is in (' + which_xorg +269 ') instead of (/opt/X11R7/bin/Xorg) rebooting the system '270 'to check again')271 bash.message(272 'err',273 'xorg binary is in (' + which_xorg +274 ') instead of (/opt/X11R7/bin/Xorg) rebooting the system '275 'to check again')276 bash.message('info', 'sending an email')277 utils.emailer(278 self.sender,279 self.default_mailing_list,280 'xorg binary is in (' + which_xorg +281 ') instead of (/opt/X11R7/bin/Xorg) (' +282 self.dut_hostname + ') (' + self.ip + ')',283 'Xorg is misconfigured in the following platform :\n'284 ' - (' + self.dut_hostname + ')\n'285 ' - (' + self.ip + ')\n\n'286 'the automated system will reboot the DUT in order to '287 'check again in the next reboot'288 )289 os.system('sudo reboot')290 else:291 self.check_environment(292 '(info) xorg binary is in the correct location '293 '(/opt/X11R7/bin/Xorg)')294 bash.message(295 'info',296 'xorg binary is in the correct location '297 '(/opt/X11R7/bin/Xorg)')298 else:299 self.check_environment(300 '(err) (' + custom_path + ') does not exists')301 bash.message('err', '(' + custom_path + ') does not exists')302 sys.exit(1)303 def ezbench_repository(self):304 """305 :return: check if ezbench folder exists on /home/<user> otherwise306 this function will download it from the official repo handled by307 martin peres from FI.308 """309 # Checking for ezbench repository310 global ezbench_folder311 ezbench_folder = os.path.join('/home', self.dut_user, 'ezbench')312 if not os.path.exists(ezbench_folder):313 bash.message(314 'info', 'cloning ezbench into (' +315 os.path.join('/home', self.dut_user) + ')', '')316 bash.return_command_status(317 'git clone ' + self.ezbench_repo + ' ' + ezbench_folder)318 self.check_environment(319 'cloning ezbench into (' +320 os.path.join('/home', self.dut_user) + ')')321 elif os.path.exists(ezbench_folder):322 bash.message(323 'skip', '(ezbench) already exists on (' + ezbench_folder + ')')324 self.check_environment(325 '(ezbench) already exists on (' + ezbench_folder + ')')326 def check_kernel_on_server(self):327 """328 :return: this function is for download the kernel source code of329 drm-tip from bifrost.intel.com into the DUT and speed up the setup330 of any of the availables test suites in the script.331 """332 # checking if the kernel folder exists on bifrost.intel.com333 # to optimize times334 kernel_external_path = '/home/shared/ezbench/kernel/drm-tip'335 output = \336 bash.get_output(337 'ssh ' + self.server_user + '@' + self.server_hostname +338 " '[ -d " + kernel_external_path + " ] "339 "&& echo true || echo false'").decode("utf-8")340 if output == 'true':341 bash.message(342 'info',343 '(drm-tip) folder exists on (' + self.server_hostname + ')')344 self.check_environment(345 'downloading drm-tip from (' + self.server_hostname + ')')346 bash.message(347 'info',348 'downloading drm-tip from (' + self.server_hostname + ')')349 output = os.system(350 'scp -r ' + self.server_user + '@' + self.server_hostname +351 ':' + kernel_external_path + ' ' + self.kernel_folder)352 if output != 0:353 self.check_environment(354 '(warn) an error was occurred trying to download '355 '(drm-tip) (' + self.server_hostname + ')')356 bash.message(357 'warn',358 'an error was occurred trying to download (drm-tip) '359 'from (' + self.server_hostname + ')')360 return False361 else:362 self.check_environment(363 '(info) (drm-tip) was downloaded successfully from (' +364 self.server_hostname + ')')365 bash.message(366 'info',367 '(drm-tip) was downloaded successfully from (' +368 self.server_hostname + ')')369 # updating kernel as a double check370 kernel_local_folder = \371 os.path.join(self.kernel_folder, 'drm-tip')372 if os.path.exists(kernel_local_folder):373 bash.message('info', 'updating (drm-tip)')374 bash.message('cmd', 'git pull origin drm-tip')375 os.system(376 'cd ' + kernel_local_folder +377 ' && git pull origin drm-tip')378 bash.message('cmd', 'git reset --hard origin/drm-tip')379 output = os.system(380 'cd ' + kernel_local_folder +381 ' && git reset --hard origin/drm-tip')382 if output != 0:383 return False384 else:385 return True386 else:387 self.check_environment(388 '(warn) (drm-tip) folder does not exists on (' +389 self.server_hostname + ')')390 bash.message(391 'warn',392 '(drm-tip) folder does not exists on (' +393 self.server_hostname + ')')394 return False395 def kernel(self):396 """397 :return: this function check if the kernel source code from drm-tip398 exists in the system, otherwise it will try to download in this order:399 1 - if the kernel source code is available on bifrost.intel.com will400 download from here (this process is faster than the second step).401 2 - if the kernel source code does not exists on bifrost.intel.com402 this function will download it from the official repo of drm-tip403 (this process is slow than the first step)404 Note : the kernel source code from bifrost.intel.com is under a cronjob405 that keeps up-to-date every 5 minutes.406 """407 # Checking for kernel directory408 if not os.path.exists(self.kernel_folder):409 bash.message(410 'info', 'creating kernel folder into (' +411 self.kernel_folder + ')', '')412 bash.return_command_status('mkdir -p ' + self.kernel_folder)413 elif os.path.exists(self.kernel_folder):414 bash.message('skip', '(' + self.kernel_folder + ') already exists')415 # Checking for drm-tip into kernel_directory416 drm_tip_folder = os.path.join(self.kernel_folder, 'drm-tip')417 drm_tip_local_config_file = \418 os.path.join(self.thisPath, 'conf.d', 'debug.conf')419 drm_tip_config_file = os.path.join(drm_tip_folder, '.config')420 if not os.path.exists(drm_tip_folder):421 check_kernel = self.check_kernel_on_server()422 if not check_kernel:423 if os.path.exists(drm_tip_folder):424 self.check_environment(425 '(info) removing (drm-tip) from (' +426 self.kernel_folder + ')')427 bash.message(428 'info',429 'removing (drm-tip) from (' + self.kernel_folder + ')')430 os.system('rm -rf ' + drm_tip_folder)431 bash.message(432 'info', 'the following process will take a while, '433 'go for a cup of coffee °o°')434 bash.message(435 'info', 'cloning drm-tip')436 self.check_environment(437 'cloning drm-tip, this step could take a while')438 bash.return_command_status(439 'git clone https://anongit.freedesktop.org/git/'440 'drm-tip.git ' + drm_tip_folder)441 elif os.path.exists(drm_tip_folder):442 bash.message('skip', '(drm-tip) already exists')443 self.check_environment('(drm-tip) already exists')444 if os.path.exists(drm_tip_folder) and not \445 os.path.isfile(drm_tip_config_file):446 bash.message(447 'info', 'copying kernel config file to (' +448 drm_tip_folder + ')')449 self.check_environment(450 'copying kernel config file to (' + drm_tip_folder + ')')451 bash.return_command_status(452 'cp ' + drm_tip_local_config_file + ' ' + drm_tip_config_file)453 elif os.path.exists(drm_tip_folder) and \454 os.path.isfile(drm_tip_config_file):455 bash.message('skip', 'kernel config file already exists')456 self.check_environment('kernel config file already exists')457 def ssh_keys(self):458 """459 :return: this function is dedicated to introduce several ssh keys to460 the DUTs in order to get connection from they without any password from461 the following servers :462 - bifrost.intel.com463 - asgard.intel.com464 - midgard.intel.com465 - and some others systems466 """467 # Setting ssh keys in order to download anything from our servers468 if not os.path.isfile(469 os.path.join('/home', self.dut_user, '.ssh_keys')):470 if not os.path.exists(471 os.path.join('/home', self.dut_user, '.ssh')):472 bash.message('info', 'creating ssh directory')473 os.makedirs(os.path.join('/home', self.dut_user, '.ssh'))474 bash.message('info', 'setting ssh keys')475 self.check_environment('setting ssh keys')476 ssh_path = os.path.join(self.thisPath, 'tools', 'ssh')477 ssh_files = \478 bash.get_output('ls ' + ssh_path).decode("utf-8").split()479 for element in ssh_files:480 bash.message('info', 'copying (' + element + ')', '')481 bash.return_command_status(482 'cp ' + os.path.join(ssh_path, element) + ' ' +483 os.path.join('/home', self.dut_user, '.ssh'))484 os.system(485 'chmod 600 ' + os.path.join(486 '/home', self.dut_user, '.ssh', 'id_rsa'))487 bash.message('info', 'restarting ssh service')488 self.check_environment('restarting ssh service')489 bash.return_command_status('sudo systemctl restart ssh')490 os.system(491 'touch ' + os.path.join('/home', self.dut_user, '.ssh_keys'))492 else:493 bash.message('skip', 'ssh keys are already setup')494 self.check_environment('ssh keys are already setup')495 def benchmarks(self):496 """497 :return: this function is dedicated to setup benchmarks environment498 for ezbench499 """500 # Checking for benchmarks directory501 benchmarks_folder = os.path.join('/opt', 'benchmarks')502 if not os.path.exists(benchmarks_folder):503 bash.message(504 'info', 'creating benchmarks folder into (' +505 benchmarks_folder + ')', '')506 bash.return_command_status('mkdir -p ' + benchmarks_folder)507 elif os.path.exists(benchmarks_folder):508 bash.message('skip', '(' + benchmarks_folder + ') already exists')509 if len(os.listdir(benchmarks_folder)) == 0:510 os.path.getsize(benchmarks_folder)511 benchmarks_size = \512 bash.get_output(513 'ssh gfxserver@linuxgraphics.intel.com '514 '"du -sh /home/benchmarks"').decode("utf-8").split()[0]515 bash.message(516 'info', 'downloading (' + str(benchmarks_size) + ')', '')517 self.check_environment('downloading (' + str(benchmarks_size) + ')')518 bash.return_command_status(519 'scp gfxserver@linuxgraphics.intel.com:'520 '/home/benchmarks/* ' + benchmarks_folder)521 elif len(os.listdir(benchmarks_folder)) > 0:522 bash.message('skip', 'the benchmarks are already downloaded')523 self.check_environment('the benchmarks are already downloaded')524 if not os.path.isfile(525 os.path.join('/home', self.dut_user, '.benchmarks_done')):526 bash.message('info', 'decompressing the benchmarks', '')527 self.check_environment('decompressing the benchmarks')528 bash.return_command_status(529 'bash ' + os.path.join(self.thisPath, 'tools', 'unpack.sh'))530 os.system(531 'touch ' + os.path.join(532 '/home', self.dut_user, '.benchmarks_done'))533 elif os.path.isfile(534 os.path.join(535 '/home', self.dut_user, '.benchmarks_done')):536 bash.message('skip', 'the benchmarks were already decompressed')537 self.check_environment('the benchmarks were already decompressed')538 def user_parameters(self):539 """540 :return: this function is dedicated to modified the file that comes541 from ezbench called (user_parameters.sh) in order to setup the correct542 environment variables that ezbench uses for run different test suites.543 """544 # Setting user_parameters.sh545 user_parameters_sample = \546 os.path.join(547 '/home', self.dut_user,548 'ezbench', 'user_parameters.sh.sample')549 user_parameters_file = \550 os.path.join(551 '/home', self.dut_user, 'ezbench', 'user_parameters.sh')552 if os.path.isfile(user_parameters_sample) and not os.path.isfile(553 user_parameters_file):554 bash.message(555 'info', 'copying (user_parameters.sample) to '556 '(user_parameters.sh)')557 self.check_environment(558 'copying (user_parameters.sample) to (user_parameters.sh)')559 bash.return_command_status(560 'cp ' + user_parameters_sample + ' ' +561 user_parameters_file)562 elif not os.path.isfile(user_parameters_sample):563 bash.message(564 'err', '(user_parameters.sh.sample) does not '565 'exists into (' + ezbench_folder + ')')566 self.check_environment(567 '(err) (user_parameters.sh.sample) does not exists into (' +568 ezbench_folder + ')')569 sys.exit(1)570 if os.path.isfile(user_parameters_file):571 keys_to_replace = [572 'REPO_LINUX=/opt/source/linux/drm-tip',573 'REPO_LINUX_CONFIG=$\{REPO_LINUX\}/.config',574 'REPO_PIGLIT=' +575 os.path.join(576 '/home', self.dut_user, 'intel-graphics',577 'intel-gpu-tools', 'piglit'),578 'IGT_ROOT=' +579 os.path.join(580 '/home', self.dut_user, 'intel-graphics',581 'intel-gpu-tools'),582 'REPO_MESA=/opt/source/mesa',583 'REPO_XF86_VIDEO_INTEL=/opt/source/xf86-video-intel',584 'RENDERCHECK_FOLDER=/opt/benchmarks/rendercheck',585 'XF86_VIDEO_INTEL=/opt/benchmarks/xf86-video-intel']586 for key in keys_to_replace:587 only_variable = key.split('=')[0]588 line_number = \589 int(bash.get_output(590 "cat -n " + user_parameters_file + "| grep -w " +591 only_variable +592 "= | awk '{print $1}'").decode("utf-8"))593 line_value = \594 bash.get_output(595 "cat -n " + user_parameters_file +596 "| grep " + only_variable +597 "= | awk '{print $2}'").decode("utf-8")598 if key != line_value:599 bash.message(600 'info', 'replacing (' + only_variable +601 ') in (' + os.path.basename(user_parameters_file) +602 ')', '')603 bash.return_command_status(604 "sed -i '" + str(line_number) + "s|^.*$|" + key +605 "|g' " + user_parameters_file)606 else:607 bash.message(608 'err', '(user_parameters.sh) does not exists into (' +609 ezbench_folder + ')')610 self.check_environment(611 '(user_parameters.sh) does not exists into (' +612 ezbench_folder + ')')613 sys.exit(1)614 def grub_entry(self):615 """616 :return: this function is dedicated to setup a grub entry for617 ezbench daemon.618 If ezbench daemon is not setup in the DUT, ezbench will not works.619 """620 # Creating the grub entry for ezbench621 ezbench_grub_file = \622 os.path.join('/etc', 'grub.d', '40_ezbench-kernel')623 if not os.path.isfile(ezbench_grub_file):624 bash.message('info', 'creating the grub entry for ezbench')625 self.check_environment('creating the grub entry for ezbench')626 bash.return_command_status('sudo bash ' + self.ezbench_grub_entry)627 elif os.path.isfile(ezbench_grub_file):628 bash.message(629 'skip', '(' + os.path.basename(self.ezbench_grub_entry) +630 ') already exists')631 self.check_environment('grub entry for ezbench already exists')632 def ezbench_daemon(self):633 """634 :return: This function is dedicated to setup the ezbench daemon635 in the DUT.636 Without the ezbench daemon the suites will not works.637 """638 # Setting ezbench daemon639 ezbench_daemon_file = \640 os.path.join(641 '/etc', 'systemd', 'system', 'ezbenchd.service')642 ezbench_daemon_local_file = \643 os.path.join(self.thisPath, 'tools', 'ezbenchd.service')644 if not os.path.isfile(ezbench_daemon_file):645 bash.message(646 'info', 'setting (' +647 os.path.basename(ezbench_daemon_file) + ') daemon')648 self.check_environment(649 'setting (' + os.path.basename(ezbench_daemon_file) +650 ') daemon')651 bash.message(652 'info', 'copying (' +653 os.path.basename(ezbench_daemon_file) + ') local daemon '654 'into (' + os.path.dirname(ezbench_daemon_file) + ')', '')655 bash.return_command_status(656 'sudo cp ' + ezbench_daemon_local_file + ' ' +657 os.path.dirname(ezbench_daemon_file))658 self.check_environment('setting (ezbench) http server')659 bash.message(660 'info', 'setting (ezbench) http server on (' + self.ip +661 ':8080)', '')662 line_number = \663 int(bash.get_output(664 "cat -n " + ezbench_daemon_local_file +665 "| grep ExecStart= | awk '{print $1}'").decode("utf-8"))666 bash.return_command_status(667 "sudo sed -i '" + str(line_number) + "s|^.*$|ExecStart=" +668 os.path.join(ezbench_folder, 'ezbenchd.py') +669 " --http_server " + self.ip + ":8080|g' " +670 ezbench_daemon_file)671 bash.message(672 'info', 'setting the user (' + self.dut_user + ')', '')673 line_number = \674 int(bash.get_output(675 "cat -n " + ezbench_daemon_local_file +676 "| grep User= | awk '{print $1}'").decode("utf-8"))677 bash.return_command_status(678 "sudo sed -i '" + str(line_number) + "s|^.*$|User=" +679 self.dut_user + "|g' " + ezbench_daemon_file)680 bash.message(681 'info', 'setting the group (' + self.dut_user + ')', '')682 line_number = \683 int(bash.get_output(684 "cat -n " + ezbench_daemon_local_file + "| grep Group= | "685 "awk '{print $1}'").decode("utf-8"))686 bash.return_command_status(687 "sudo sed -i '" + str(line_number) +688 "s|^.*$|Group=" + self.dut_user + "|g' " + ezbench_daemon_file)689 bash.message(690 'info', 'changing owner for (' +691 os.path.basename(ezbench_daemon_local_file) + ') to root', '')692 bash.return_command_status('sudo chown root.root ' + ezbench_daemon_file)693 # enabling ezbench.d service694 self.check_environment('enabling ezbench daemon')695 bash.message(696 'info', 'enabling (' +697 os.path.basename(ezbench_daemon_local_file) + ') daemon', '')698 bash.return_command_status('sudo systemctl enable ezbenchd.service')699 bash.message(700 'info', 'checking is ezbench daemon was enabled correctly', '')701 ezbench_was_enabled = \702 bash.get_output(703 'systemctl is-enabled '704 'ezbenchd.service').decode("utf-8")705 if ezbench_was_enabled == 'enabled':706 print(' ... [' + bash.GREEN + 'DONE' + bash.END + ']')707 self.check_environment('ezbench daemon was enabled correctly')708 else:709 print(' ... [' + bash.RED + 'FAIL' + bash.END + ']')710 bash.message(711 'err', 'a issue was occurred enabling ezbench daemon')712 self.check_environment(713 'a issue was occurred enabling ezbench daemon')714 sys.exit(1)715 self.check_environment('starting ezbench daemon')716 bash.message(717 'info', 'starting (' +718 os.path.basename(ezbench_daemon_local_file) + ') daemon', '')719 bash.return_command_status('sudo systemctl start ezbenchd.service')720 bash.message(721 'info', 'checking is ezbench daemon was started correctly', '')722 ezbench_was_enabled = \723 bash.get_output(724 'systemctl is-active ezbenchd.service').decode("utf-8")725 if ezbench_was_enabled == 'active':726 print(' ... [' + bash.GREEN + 'DONE' + bash.END + ']')727 self.check_environment('ezbench daemon was correctly started')728 else:729 print(' ... [' + bash.RED + 'FAIL' + bash.END + ']')730 bash.message(731 'err', 'a issue was occurred activating '732 'ezbench daemon')733 self.check_environment(734 'a issue was occurred activating ezbench daemon')735 sys.exit(1)736 # =========================================================737 # 1) to check more information about the service (daemon) :738 # systemctl status ezbenchd.service739 # 2) https://www.digitalocean.com/community/tutorials/740 # how-to-use-systemctl-to-manage-systemd-services-and-units741 # =========================================================742 elif os.path.isfile(ezbench_daemon_file):743 bash.message(744 'skip', '(' + os.path.basename(ezbench_daemon_file) +745 ') daemon already exists on (' +746 os.path.dirname(ezbench_daemon_file) + ')')747 bash.message(748 'info', 'checking if (' +749 os.path.basename(ezbench_daemon_file) +750 ') is enabled', '')751 is_enabled = bash.get_output(752 'systemctl is-enabled ezbenchd.service').decode("utf-8")753 is_active = bash.get_output(754 'systemctl is-active ezbenchd.service').decode("utf-8")755 if is_enabled == 'enabled':756 print(' ... (' + bash.GREEN + 'DONE' + bash.END + ')')757 bash.message(758 'info', 'ezbench.d is enabled in the following url '759 '(http://' + self.ip + ':8080)')760 self.check_environment(761 'ezbench.d is enabled in the following url '762 '(http://' + self.ip + ':8080)')763 else:764 print(' ... (' + bash.RED + 'FAIL' + bash.END + ')')765 sys.exit(1)766 bash.message(767 'info', 'checking if (' +768 os.path.basename(ezbench_daemon_file) + ') is active', '')769 if is_active == 'active':770 print(' ... (' + bash.GREEN + 'DONE' + bash.END + ')')771 bash.message('info', 'ezbench.d is active in the system')772 self.check_environment('ezbench.d is active in the system')773 else:774 print(' ... (' + bash.RED + 'FAIL' + bash.END + ')')775 self.check_environment(776 '(err) ezbench.d is not active in the system')777 sys.exit(1)778 # setting a crontab for ezbench daemon779 cron_control_file = \780 os.path.join('/home', self.dut_user, '.cron_ctrl_root')781 crontab_root_file = \782 os.path.join(self.thisPath, 'tools', 'crontab_ezbench')783 if not os.path.isfile(cron_control_file):784 bash.message(785 'info', 'setting crontab for root in order to enable '786 'ezbench daemon at startup')787 self.check_environment(788 'setting crontab for root in order to enable ezbench daemon '789 'at startup')790 bash.return_command_status('sudo crontab -u root ' + crontab_root_file)791 bash.message('info', 'setting a cron control file', '')792 bash.return_command_status('touch ' + cron_control_file)793 elif os.path.isfile(cron_control_file):794 bash.message('skip', 'crontab for root is already setup')795 self.check_environment('crontab for root is already setup')796 def watchdog(self):797 """798 :return: This function is dedicated to compile the watchdog that799 ezbench has.800 This watchdog is develop by Petri from FI team.801 when this watchdog does not detect any movement from any test from802 intel-gpu-tools it will reboot the DUT automatically.803 """804 # Compiling internal watchdog805 ezbench_watchdog_folder = \806 os.path.join(ezbench_folder, 'utils', 'owatch')807 ezbench_watchdog_folder_binary = \808 os.path.join(ezbench_folder, 'utils', 'owatch', 'owatch')809 if os.path.exists(ezbench_watchdog_folder) and not \810 os.path.isfile(ezbench_watchdog_folder_binary):811 self.check_environment('compiling ezbench watchdog')812 bash.message('info', 'compiling ezbench watchdog', '')813 bash.return_command_status('cd ' + ezbench_watchdog_folder + ' && make')814 elif os.path.exists(ezbench_watchdog_folder) and \815 os.path.isfile(ezbench_watchdog_folder_binary):816 self.check_environment('ezbench watchdog is already compiled')817 bash.message('skip', 'ezbench watchdog is already compiled')818 elif not os.path.exists(ezbench_watchdog_folder):819 bash.message(820 'warn', '(owatch) folder does not exists, skipping '821 'internal watchdog compilation')822 self.check_environment(823 '(warn) (owatch) folder does not exists, '824 'skipping internal watchdog compilation')825 def disable_x(self):826 """827 :return: This function is dedicated to disable X.828 The suite that does not needs X is:829 - intel-gpu-tools830 """831 # Disabling X832 check_x = bash.get_output('ps -e | grep X').decode("utf-8")833 current_tty = bash.get_output('tty').decode("utf-8")834 if check_x:835 bash.message('info', 'X is enabled, disabling')836 self.check_environment('X is enabled, disabling')837 bash.message(838 'info', 'systemctl enable multi-user.target --force', '')839 bash.return_command_status(840 'sudo systemctl enable multi-user.target '841 '--force 2> /dev/null')842 bash.message(843 'info', 'systemctl set-default multi-user.target', '')844 bash.return_command_status(845 'sudo systemctl set-default multi-user.target 2> /dev/null')846 else:847 bash.message(848 'info', 'X is not enabled, current TTY is (' + bash.CYAN +849 current_tty + bash.END + ')')850 self.check_environment('X is not enabled')851 def control_file(self, send_email=True):852 """853 :return: This function is dedicated to create a control file for this854 scripts, in order to know when the functions are not needed anymore855 because this script executed successfully the function called for each856 suite in this script.857 """858 if not os.path.isfile(self.file_to_write):859 with open(self.file_to_write, 'w') as ez_file:860 ez_file.write('(info) ezbench setup is completed\n')861 self.check_environment(862 'ezbench setup completed daemon on (' + self.ip + ':8080)')863 if self.automated_system and self.default_mailing_list and send_email:864 utils.emailer(865 self.sender,866 self.default_mailing_list,867 'ezbench is ready to run in [' +868 self.dut_hostname + '] [' + self.ip + ']',869 '(' + self.dut_hostname + ') is ready for run ezbench\n\n'870 'Technical data\n'871 ' - ezbench daemon on (' + self.ip + ':8080)\n'872 ' - ezbench folder : (' +873 os.path.join('/home', self.dut_user, 'ezbench') + ')\n'874 ' - kernel tree path : (/opt/source/linux/drm-tip)\n'875 ' - Kernel command line : (' + self.grub_parameters + ')\n'876 ' - Graphical environment : (' +877 str(self.graphical_environment) + ')\n\n'878 'Firmwares\n'879 ' - guc : (' + str(self.guc) + ')\n'880 ' - huc : (' + str(self.huc) + ')\n'881 ' - dmc : (' + str(self.dmc) + ')\n'882 )883 bash.return_command_status('sudo reboot')884 else:885 self.check_environment(886 'ezbench setup completed daemon on (' + self.ip + ':8080)')887 # running rendercheck888 if self.suite == 'ezbench_rendercheck':889 rendercheck.ExecutionManager().run_rendercheck()890 def enable_x(self):891 """892 :return: This function is dedicated to enable X.893 The following suites needs X enabled in order to run :894 - rendercheck895 - benchmarks896 """897 # Enabling X898 check_x = bash.get_output('ps -e | grep X').decode("utf-8")899 if check_x:900 bash.message('skip', 'X is enabled')901 self.check_environment('X is enabled')902 else:903 bash.message('info', 'X is not enabled, enabling')904 self.check_environment('X is not enabled, enabling')905 bash.message('info', 'systemctl set-default graphical.target', '')906 bash.return_command_status(907 'sudo systemctl set-default graphical.target &> /dev/null')908 bash.message('info', 'systemctl start lightdm', '')909 bash.return_command_status('sudo systemctl start lightdm &> /dev/null')910 def repositories(self):911 """912 :return: This function is dedicated to clone the repositories that913 ezbench needed in order to test different suites.914 """915 mesa_url = 'https://anongit.freedesktop.org/git/mesa/mesa.git'916 xf86_video_intel_url = \917 'https://anongit.freedesktop.org/git/xorg/driver/' \918 'xf86-video-intel.git'919 repo_list = [920 '/opt/source/mesa', '/opt/source/xf86-video-intel',921 '/opt/benchmarks/xf86-video-intel']922 for repo in repo_list:923 only_repo = os.path.basename(repo)924 if not os.path.exists(repo):925 bash.message(926 'info', 'cloning (' + only_repo + ') into (' +927 os.path.dirname(repo) + ')', '')928 self.check_environment(929 'cloning (' + only_repo + ') into (' +930 os.path.dirname(repo) + ')')931 if only_repo == 'mesa':932 bash.return_command_status('cd ' + os.path.dirname(933 repo) + ' && git clone ' + mesa_url)934 elif only_repo == 'xf86-video-intel':935 bash.return_command_status('cd ' + os.path.dirname(936 repo) + ' && git clone ' + xf86_video_intel_url)937 else:938 bash.message('skip', '(' + repo + ') already exists')939 self.check_environment('(' + repo + ') already exists')940 def bashrc(self):941 """942 :return: This function is dedicated to check python version.943 ezbench only works with python3 version, other lower python version944 does not works with ezbech.945 """946 if int(self.python_version) == 2:947 bash.message(948 'info',949 'please set python 3 as default interpreter for (' +950 self.dut_user + ')')951 bash.message('info', 'type the following commands')952 bash.message('cmd', 'sudo rm /usr/bin/python')953 bash.message(954 'cmd', 'sudo ln -s /usr/bin/python3.5 /usr/bin/python')955 sys.exit(1)956 elif int(self.python_version) == 3:957 bash.message('skip', 'python 3 is the default interpreter')958 self.check_environment('python 3 is the default interpreter')959 def rendercheck_setup(self):960 """961 :return: This function is dedicated to setup all things needed for962 rendercheck since we are cloning from a different repository than the963 oficcial one, this is because that the repository of martin peres has964 some modification on rendercheck binary that allows to list the965 subtests by family and get the reports by subtests as well.966 """967 # dependencies968 dependencies_list = ['meson:0.40.1', 'tsocks', 'ninja:1.7.1']969 self.check_environment('(info) checking dependencies for rendercheck')970 for element in dependencies_list:971 dependency = element.split(':')[0]972 if ':' in element:973 required_version = element.split(':')[1]974 else:975 required_version = False976 output = \977 bash.get_output('dpkg -l | grep ' + dependency).decode("utf-8")978 if not output:979 self.check_environment(980 '(err) (' + dependency +981 ') dependency not found in the system')982 bash.message(983 'err',984 '(' + dependency + ') dependency not found in the system')985 sys.exit(1)986 else:987 if required_version:988 dependency_version = \989 bash.get_output(dependency + ' --v').decode("utf-8")990 if required_version != dependency_version:991 self.check_environment(992 '(err) (' + dependency +993 ') version is not satisfactory')994 bash.message(995 'err',996 '(' + dependency + ') version is not satisfactory')997 bash.message(998 'info',999 'minimum version required is (' +1000 required_version + ')')1001 bash.message(1002 'info',1003 'current (' + dependency + ') version is (' +1004 dependency_version + ')')1005 sys.exit(1)1006 else:1007 bash.message(1008 'info',1009 '(' + dependency + ') version is : (' +1010 dependency_version + ') ☆')1011 # proxies configuration file1012 if not os.path.isfile('/etc/tsocks.conf'):1013 self.check_environment('copying (tsocks.conf) to /etc')1014 bash.message('info', 'copying (tsocks.conf) to /etc')1015 os.system(1016 'sudo cp ' + os.path.join(1017 self.thisPath, 'tools', 'tsocks.conf') + ' /etc')1018 # rendercheck repository1019 # due to rendercheck only shows results per family, we have to clone1020 # from martin peres repository located at :1021 # https://cgit.freedesktop.org/~mperes/rendercheck1022 # because martin did a patch in order to rendercheck shows the subtest1023 # during the test per family with --r option1024 rendercheck_url = 'git://people.freedesktop.org/~mperes/rendercheck'1025 if not os.path.exists('/opt/benchmarks/rendercheck'):1026 self.check_environment(1027 'cloning (rendercheck) into (/opt/benchmarks)')1028 bash.message(1029 'info', 'cloning (rendercheck) into (/opt/benchmarks)')1030 bash.return_command_status(1031 'cd /opt/benchmarks && tsocks git clone ' + rendercheck_url)1032 # compiling rendercheck1033 rendercheck_folder = '/opt/benchmarks/rendercheck'1034 if os.path.exists(rendercheck_folder) and not \1035 os.path.exists(os.path.join(rendercheck_folder, 'build')):1036 self.check_environment('compiling rendercheck')1037 bash.message('info', 'compiling rendercheck')1038 if not os.path.exists(os.path.join(rendercheck_folder, 'build')):1039 os.makedirs(os.path.join(rendercheck_folder, 'build'))1040 self.check_environment('(cmd) meson . build')1041 bash.message('cmd', 'meson . build')1042 bash.return_command_status(1043 'cd ' + rendercheck_folder + ' && meson . build')1044 self.check_environment('(cmd) cd build && ninja')1045 bash.message('cmd', 'cd build && ninja')1046 bash.return_command_status(1047 'cd ' + os.path.join(rendercheck_folder, 'build') +1048 ' && ninja')1049 self.check_environment(1050 '(info) creating a soft link for rendercheck')1051 bash.message('info', 'creating a soft link for rendercheck')1052 bash.return_command_status(1053 'ln -s ' + rendercheck_folder + '/build/rendercheck ' +1054 rendercheck_folder)1055 elif os.path.exists(rendercheck_folder) and \1056 os.path.isfile(1057 os.path.join(rendercheck_folder, 'build', 'rendercheck')):1058 self.check_environment('(info) (rendercheck) is already compiled')1059 bash.message('info', '(rendercheck) is already compiled')1060 elif not os.path.exists(rendercheck_folder):1061 self.check_environment(1062 '(err) (' + rendercheck_folder + ') does not exists')1063 bash.message(1064 'err', '(' + rendercheck_folder + ') does not exists')1065 sys.exit(1)1066 rendercheck_current_commit = \1067 bash.get_output(1068 'cd ' + rendercheck_folder +1069 ' && git log -1 --pretty=fuller').decode("utf-8")1070 bash.message(1071 'info', '(rendercheck) commit :\n\n' + rendercheck_current_commit)1072 def setup(self, suite):1073 """1074 :param suite: the suite to be setup in the DUT.1075 :return: calls to specific functions in order to setup the available...

Full Screen

Full Screen

pseudo_proton

Source:pseudo_proton Github

copy

Full Screen

...219 if "PATH" in os.environ:220 self.env["PATH"] = g_proton.bin_dir + ":" + os.environ["PATH"]221 else:222 self.env["PATH"] = g_proton.bin_dir223 def check_environment(self, env_name, config_name):224 if not env_name in self.env:225 return False226 if nonzero(self.env[env_name]):227 self.compat_config.add(config_name)228 else:229 self.compat_config.discard(config_name)230 return True231 def init_session(self):232 self.env["WINEPREFIX"] = g_compatdata.prefix_dir233 #load environment overrides234 if "PROTON_LOG" in self.env and nonzero(self.env["PROTON_LOG"]):235 self.env.setdefault("WINEDEBUG", "+timestamp,+pid,+tid,+seh,+debugstr,+loaddll,+mscoree")236 self.env.setdefault("DXVK_LOG_LEVEL", "info")237 self.env.setdefault("VKD3D_DEBUG", "warn")238 self.env.setdefault("WINE_MONO_TRACE", "E:System.NotImplementedException")239 #for performance, logging is disabled by default; override with user_settings.py240 self.env.setdefault("WINEDEBUG", "-all")241 self.env.setdefault("DXVK_LOG_LEVEL", "none")242 self.env.setdefault("VKD3D_DEBUG", "none")243 #default wine-mono override for FNA games244# self.env.setdefault("WINE_MONO_OVERRIDES", "Microsoft.Xna.Framework.*,Gac=n")245 if "wined3d11" in self.compat_config:246 self.compat_config.add("wined3d")247 if not self.check_environment("PROTON_USE_WINED3D", "wined3d"):248 self.check_environment("PROTON_USE_WINED3D11", "wined3d11only")249 self.check_environment("PROTON_USE_WINED3D9", "wined3d9only")250 self.check_environment("PROTON_USE_WINE_DXGI", "winedxgi")251 self.check_environment("PROTON_NO_D3D11", "nod3d11")252 self.check_environment("PROTON_NO_D3D12", "nod3d12")253 self.check_environment("PROTON_NO_D3D10", "nod3d10")254 self.check_environment("PROTON_NO_D3D9", "nod3d9")255 self.check_environment("PROTON_USE_CUSTOMD3D9", "custom9")256 self.check_environment("PROTON_NO_ESYNC", "noesync")257 self.check_environment("PROTON_NO_FSYNC", "nofsync")258 self.check_environment("PROTON_DISABLE_LARGE_ADDRESS_AWARE", "disablelgadd")259 self.check_environment("PROTON_OLD_GL_STRING", "oldglstr")260 self.check_environment("PROTON_USE_SECCOMP", "seccomp")261 self.check_environment("PROTON_NO_WRITE_WATCH", "nowritewatch")262 self.check_environment("PROTON_DXVK_ASYNC", "dxvkasync")263 self.check_environment("PROTON_NVAPI_DISABLE", "nonvapi")264 self.check_environment("PROTON_WINEDBG_DISABLE", "nowinedbg")265 self.check_environment("PROTON_CONHOST_DISABLE", "noconhost")266 self.check_environment("PROTON_PULSE_LOWLATENCY", "pulselowlat")267 self.check_environment("PROTON_LOG_COMMAND_TO_PREFIX", "logcommandtoprefix")268 self.check_environment("PROTON_WINETRICKS", "winetricks")269 self.check_environment("PROTON_BYPASS_SHADERCACHE_PATH", "shadercachepath")270# if not "__GL_SHADER_DISK_CACHE_PATH" in self.env and not "__GL_SHADER_DISK_CACHE_PATH" in os.environ:271 #log("NV shader cache path is undefined. Using prefix path as a fallback.")272# self.env.setdefault("__GL_SHADER_DISK_CACHE_PATH", g_compatdata.prefix_dir)273# elif "shadercachepath" in self.compat_config:274# self.env["__GL_SHADER_DISK_CACHE_PATH"] = self.env["PROTON_BYPASS_SHADERCACHE_PATH"] + "/" + os.environ["SteamGameId"]275# if not "MESA_GLSL_CACHE_DIR" in self.env and not "MESA_GLSL_CACHE_DIR" in os.environ:276 #log("Mesa shader cache path is undefined. Using prefix path as a fallback.")277# self.env.setdefault("MESA_GLSL_CACHE_DIR", g_compatdata.prefix_dir)278# elif "shadercachepath" in self.compat_config:279# self.env["MESA_GLSL_CACHE_DIR"] = self.env["PROTON_BYPASS_SHADERCACHE_PATH"] + "/" + os.environ["SteamGameId"]280 if "noesync" in self.compat_config:281 self.env.pop("WINEESYNC", "")282 else:283 self.env["WINEESYNC"] = "1"...

Full Screen

Full Screen

deployments.py

Source:deployments.py Github

copy

Full Screen

2from invoke.exceptions import Exit3from env import SUMO_APP_TEMPLATE, SUMO_NODEPORT_TEMPLATE, SUMO_SERVICE_TEMPLATE4from deploy_utils import render_template, k8s_apply, k8s_delete_resource5@task()6def check_environment(ctx):7 """8 Ensure that a .yaml file has been specified9 """10 if "namespace" not in ctx.config["kubernetes"]:11 print("Please specify a configuration file with -f")12 raise Exit()13def _create(app, ctx, tag, apply, record=False):14 if tag:15 ctx.config["kubernetes"]["image"]["tag"] = tag16 t = render_template(config=ctx.config, template_name=SUMO_APP_TEMPLATE, app=app)17 k8s_apply(ctx, t, apply, record)18@task(check_environment)19def create_web(ctx, tag=None, apply=False):20 """...

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 lisa 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