def build_qa_kernel(self):
        """Build a QA kernel.

		This function is dedicated to build a QA kernel in order to intel-gpu-tools
		by the automated system.
		The kernels from QA have the same source code that drm-tip.
		:return:
			- kernel_commit : which is the kernel commit built from kernel_build.py
			script and it will be use during fastfeedback execution.
		"""
        kernel_builder_path = os.path.join(self.main_path, 'kernel',
                                           'drm-intel-qa')

        workspace = os.path.join(kernel_builder_path, 'gfx-qa-tools')
        if os.path.exists(workspace):
            self.log.info('deleting workspace')
            rmtree(workspace)

        self.log.info(
            'cloning gfx-qa-tools in : {0}'.format(kernel_builder_path))
        cmd = 'git -C {path} clone {repo}'.format(path=kernel_builder_path,
                                                  repo=self.gfx_qa_repo)
        bash.check_output(cmd,
                          'gfx-qa-tools repository was successfully cloned',
                          'an error occurred cloning gfx-qa-tools repository')

        self.log.info('building QA kernel')
        kernel_commit = kernel_build.KernelManaging(tag=True).check_pid()

        if not kernel_commit:
            utils.emailer(self.sender,
                          self.mailing_list,
                          'fastfeedback could not be launched on ({year}) '
                          '(WW{week_number}) ({week_day}) ({hour})'.format(
                              year=self.year,
                              week_number=self.week_number,
                              week_day=self.week_day,
                              hour=self.hour),
                          'fastfeedback could not be launched due to '
                          '({kernel_commit}) is empty'.format(
                              kernel_commit=os.path.basename(kernel_commit)),
                          silent=True)
            sys.exit(1)

        self.log.info(
            'using the latest kernel code built : {0}'.format(kernel_commit))

        return kernel_commit
    def build_graphic_stack(self):
        """Build a new graphic stack.

		The aim of this function is to build a new graphic stack for intel-gpu-tools.
		This action will be performed by gfxStack.py script, and the final file will
		be a debian package that will contains all the drivers required in order to
		run intel-gpu-tools.

		:return:
			-graphic_stack_code: the graphic_stack_code is a file that is created
			by gfxStack.py if everything went well.
		"""
        self.log.info('building a new graphic stack for : {0}'.format(
            self.suite))
        graphic_stack_code = gfxStack.Builder(
            config_file=self.gfx_stack_config).build()

        if not graphic_stack_code:
            self.log.error('graphic_stack_code is empty')
            utils.emailer(
                self.sender,
                self.mailing_list,
                'fastfeedback could not be launched on ({year}) '
                '(WW{week_number}) ({week_day}) ({hour})'.format(
                    year=self.year,
                    week_number=self.week_number,
                    week_day=self.week_day,
                    hour=self.hour),
                'fastfeedback could not be launched due to gfx_stack_code is empty',
                silent=True)
            sys.exit(1)

        self.log.info(
            'using the latest graphic stack code built : ({0})'.format(
                graphic_stack_code))

        return graphic_stack_code
def send_email(remote_username, machine_logged, remote_user_ip):
    """Send a email notification

	:param remote_username: the remote user name
	:param machine_logged: the machine what is logged
	:param remote_user_ip: the remote ip what is logged
	"""

    user_info = bash.get_output('id {0}'.format(remote_username)).replace(
        ' ', '\n')
    sender = 'bifrost.intel.com@noreply'
    mailing_list = '*****@*****.**'
    subject = 'new ssh connection detected of: {0}'.format(remote_username)
    message = '''

	A new ssh connection was detected on bifrost, please see the details below:

	{detail_info}

	machine logged : {machine}
	ip logged      : {ip}
	'''.format(detail_info=user_info, machine=machine_logged, ip=remote_user_ip)

    utils.emailer(sender, mailing_list, subject, message, silent=True)
    def send_email(self, trc_link, pass_test, fail_test, total_test,
                   pass_rate_of_executed, elapsed_time):
        """Send a email to notify that the execution is finished

		:param trc_link: which is the trc link report.
		:param pass_test: which is passed tests.
		:param fail_test: which is the failed tests.
		:param total_test: which is the total test run.
		:param pass_rate_of_executed: which is the pass rate of the executed.
		:param elapsed_time: which is the elapsed time of the execution.
		"""

        self.log.info('sending the email')
        # platform distribution
        sys_info = platform.platform()
        distro = sys_info.split(
            'with-')[1] if 'with-' in sys_info else sys_info
        # Getting the displays attached to the DUT
        displays_attached = \
         bash.get_output(
          "sudo cat /sys/kernel/debug/dri/0/i915_display_info "
          "| grep \"^connector\" | grep "
          "-we \"connected\" | awk -F\"type \" '{print $2}' | "
          "awk '{print $1}' | sed 's/,//g'").decode('utf-8').split()
        displays_attached = ' & '.join(displays_attached)

        body = '''
rendercheck execution has finished, please see the overall statistics

================================================
DUT configuration
================================================
User: {user}
Password: {pwd}
IP: {host_ip}
Hostname: {host}
Grub parameters: {grub}
guc: {guc}
huc: {huc}
dmc: {dmc}
Raspberry IP: {raspberry_ip}
Raspberry number: {raspberry_number}
Raspberry switch: {switch_number}
USB cutter serial: {usb_cutter}
Package: {package}
Gfx stack code: {stack_code}
Kernel branch: {kernel_branch}
Kernel commit: {kernel_commit}
Rounds: {iterations}
Default image: {image}
Distro: {distro}

================================================
Statistics
================================================
Total tests: {total_tests}
Passed: {tests_pass}
Failed: {tests_fail}
Pass rate: {pass_rate}%
{overall_time}
Attached displays: {displays}

TRC link: {trc_link}
			'''.format(
            user=self.dut_user,
            pwd=self.data['dut_conf']['dut_password'],
            host_ip=self.data['dut_conf']['dut_static_ip'],
            host=self.dut_hostname,
            grub=self.data['dut_conf']['grub_parameters'],
            guc=self.data['firmwares']['guc'],
            huc=self.data['firmwares']['huc'],
            dmc=self.data['firmwares']['dmc'],
            raspberry_ip=self.data['raspberry_conf']['raspberry_ip'],
            raspberry_number=self.raspberry_number,
            switch_number=self.raspberry_power_switch,
            usb_cutter=self.data['raspberry_conf']['usb_cutter_serial'],
            package=self.data['suite_conf']['default_package'],
            stack_code=self.data['suite_conf']['gfx_stack_code'],
            kernel_branch=self.data['suite_conf']['kernel_branch'],
            kernel_commit=self.data['suite_conf']['kernel_commit'],
            iterations=self.data['suite_conf']['igt_iterations'],
            image=self.data['usb_conf']['default_image'],
            distro=distro,
            total_tests=total_test,
            tests_pass=pass_test,
            tests_fail=fail_test,
            pass_rate=pass_rate_of_executed,
            overall_time=elapsed_time,
            displays=displays_attached,
            trc_link=trc_link,
        )

        utils.emailer(
            '*****@*****.**',
            self.data['suite_conf']['default_mailing_list'],
            'rendercheck execution finished on ({hostname})'.format(
                hostname=self.dut_hostname), body)
Exemple #5
0
	def kernel_builder(self, **kwargs):
		"""Dedicated function to build the kernel

		The aim of this function is to build kernel from drm-tip and tagged as
		drm-intel-qa in order to preserve the commit in our server.

		:param kwargs: could has the following values
			- kernel_target: which is the kernel source code to build
			- latest_commit: which is the latest commit to build
			- latest_commit_information: which is the full information from the
			latest commit
			- kernel_name: which is the kernel name
		"""
		kernel_target = kwargs['kernel_target']
		latest_commit = kwargs['latest_commit']
		latest_commit_information = kwargs['latest_commit_information']
		kernel_name = kwargs['kernel_name']

		utils.timer('start')
		bash.check_output(
			'git -C {0} checkout drm-tip'.format(kernel_target),
			'git checkout branch drm-tip was successful',
			'git checkout branch drm-tip was failed',
			print_messages=False
		)
		bash.check_output(
			'git -C {path} checkout {commit}'.format(
				path=kernel_target, commit=latest_commit),
			'git checkout commit drm-tip was successful',
			'git checkout commit drm-tip was failed',
			print_messages=False
		)

		# this is part of the new procedure in order to avoid issues with FWs
		kernel_config = os.path.join(kernel_target, '.config')
		self.log.info('copying config to: {0}'.format(kernel_config))
		kernel_conf = os.path.join(self.this_path, 'conf.d', 'debug.conf')
		copyfile(kernel_conf, kernel_config)

		self.log.info('● setting kernel keys ●')

		# naming the kernel
		self.write_read_config_file(
			config_file=kernel_config,
			kernel_key='CONFIG_LOCALVERSION',
			kernel_value='"-{name}-ww{week_number}-commit-{commit}"'.format(
				name=kernel_name, week_number=self.week_number, commit=latest_commit)
		)

		# changing the kernel keys setup in kernel.yml
		for key, value in self.kernel_keys.items():
			self.write_read_config_file(
				config_file=kernel_config,
				kernel_key=key,
				kernel_value=value
			)

		# creating config file to build the kernel
		self.log.info('creating kernel config file')
		os.system('cd {0} && make olddefconfig'.format(kernel_target))
		self.log.info('creating a (tmp.d) folder')
		os.makedirs(os.path.join(kernel_target, 'tmp.d'))
		self.log.info('moving all kernel tree to (tmp.d)')
		dest = os.path.join(kernel_target, 'tmp.d')
		os.system('mv ' + kernel_target + '/{.,}* ' + dest + ' 2> /dev/null')

		# build options
		cores = int(bash.get_output('nproc')) + 2

		self.log.info('compiling {kernel_name} with : {cores} cores'.format(
			kernel_name=kernel_name, cores=cores))
		# there is an internal Bash variable called "$PIPESTATUS" it’s an array
		# that holds the exit status of each command in your last foreground
		# pipeline of commands.
		output = os.system(
			'cd {path} && make -j{cores}  deb-pkg | '
			'tee {log_path}/kernel_compilation.log ; '
			'bash -c "test ${{PIPESTATUS[0]}} -eq 0"'.format(
				path=dest, cores=cores, log_path=self.log_path))

		if output:
			self.log.error('unable to compile drm-tip')
			utils.emailer(
				'*****@*****.**',
				self.mailing_list,
				'unable to compile {0} kernel'.format(kernel_name),
				'bifrost.intel.com was unable to compile {name} kernel\n\n'
				'The following commit was unable to compile: {commit}'.format(
					name=kernel_name, commit=latest_commit))
			utils.timer('stop', print_elapsed_time=False)
			sys.exit(1)

		self.log.info('{0} : was compiled successfully'.format(kernel_name))

		# getting information from the kernel tree
		custom_config = os.path.join(kernel_target, 'tmp.d', '.config')
		dsc_file = bash.get_output('ls {0} | grep .dsc$'.format(kernel_target))
		changes_file = bash.get_output('ls {0} | grep .changes$'.format(
			kernel_target))
		kernel_full_version = bash.get_output(
			'cat {path} | grep -w ^Version'.format(
				path=os.path.join(kernel_target, dsc_file))).split()[1]
		kernel_version = kernel_full_version.split('-')[0]
		my_list = kernel_full_version.split('-')
		commit_index = my_list.index('commit') + 1
		commit = my_list[commit_index].split('+')[0]

		# this condition is when a new kernel does not contains the tag rc in
		# their name
		if re.search('rc', kernel_full_version):
			release_candidate = kernel_full_version.split('-')[1]
			kernel_version = '{version}-{rc}-{commit}'.format(
				version=kernel_version, rc=release_candidate, commit=commit)
		else:
			kernel_version = '{version}-{commit}'.format(
				version=kernel_version, commit=commit)

		package_list = bash.get_output(
			'cat {path} | grep -w ^Package-List -A 4 | '
			'sed -e \'s/Package-List://g\' -e \'1d\''.format(
				path=os.path.join(kernel_target, dsc_file)))

		git_log = bash.get_output(
			'git -C {path} show {commit} --format=fuller'.format(
				path=os.path.join(kernel_target, 'tmp.d'), commit=commit))

		# creating output directory for the kernel debian packages
		pre_output_dir = os.path.join(
			self.debian_packages_local_path, 'WW{0}'.format(self.week_number))

		if self.enforce:
			enforce_folders = int(bash.get_output(
				'ls {path} | grep enforce | wc -l'.format(path=pre_output_dir))) + 1
			if self.kernel_folder_nickname:
				output_dir = os.path.join(
					pre_output_dir,
					'{kernel_version}-{week_day}-{nick_name}-enforce-{enforce}'.format(
						kernel_version=kernel_version, week_day=self.week_day,
						nick_name=self.kernel_folder_nickname, enforce=enforce_folders))
			else:
				output_dir = os.path.join(
					pre_output_dir, '{kernel_version}-{week_day}-enforce-{enforce}'.format(
						kernel_version=kernel_version, week_day=self.week_day,
						enforce=enforce_folders))
		else:
			if self.kernel_folder_nickname:
				output_dir = os.path.join(
					pre_output_dir, '{kernel_version}-{week_day}-{nick_name}'.format(
						kernel_version=kernel_version, week_day=self.week_day,
						nick_name=self.kernel_folder_nickname))
			else:
				output_dir = os.path.join(
					pre_output_dir, '{kernel_version}-{week_day}'.format(
						kernel_version=kernel_version, week_day=self.week_day))

		self.structure_debian_packages_folder(
			output_dir=output_dir,
			kernel_target=kernel_target,
			git_log=git_log,
			package_list=package_list,
			dsc_file=dsc_file,
			changes_file=changes_file,
			custom_config=custom_config,
			commit=commit
		)

		if self.tag:
			# creating the QA tag
			self.create_qa_tag(commit)

		if self.data['miscellaneous']['upload_package']:
			# uploading kernel debian packages
			self.upload_kernel_debian_packages(output_dir=output_dir)
			debian_packages_link = True
		else:
			self.log.info(
				'the kernel debian packages will not be uploaded due to '
				'(upload_package) key is set to False')
			debian_packages_link = False

		# sending a email notification
		self.send_email(
			output_dir=output_dir,
			kernel_name=kernel_name,
			debian_packages_link=debian_packages_link,
			kernel_version=kernel_version,
			git_log=git_log,
			package_list=package_list,
			latest_commit_information=latest_commit_information
		)

		utils.timer('stop', print_elapsed_time=False)
Exemple #6
0
	def send_email(self, **kwargs):
		"""Upload kernel debian packages.

		:param kwargs:
			- debian_packages_link: when set to True this function will send a
			email notification with the link to linuxgraphics.intel.com web page.
			where the user can download the packages otherwise only a email
			notification will send without the link.
			- output_dir: which is the output dir where the kernel debian packages
			are stored.
			- kernel_name: which is the kernel name.
			- kernel_version: which is the kernel version.
			- git_log: which is the log from git.
			- package_list: which are the debian packages compiled.
			- latest_commit_information: the full information for the compiled
			commit.
		"""
		output_dir = kwargs['output_dir']
		debian_packages_link = kwargs['debian_packages_link']
		kernel_name = kwargs['kernel_name']
		kernel_version = kwargs['kernel_version']
		git_log = kwargs['git_log']
		package_list = kwargs['package_list']
		latest_commit_information = kwargs['latest_commit_information']

		# sending an email notification
		if debian_packages_link:
			link = 'http://linuxgraphics.intel.com:/{kernel_id}/' \
				'WW{number}/{version}'.format(
					number=self.week_number, version=kernel_version, kernel_id=self.kernel_id)
			utils.emailer(
				'*****@*****.**',
				self.mailing_list,
				'new commit for {kernel_name} version: {version}'.format(
					kernel_name=kernel_name, version=kernel_version),
				'a new commit for {kernel_name} was build and uploaded to {server}\n'
				'link to kernel: {link}\n\n'
				'{log}\n\n '
				'Package list: \n'
				'{package}\n'
				'Kernel version: {version}\n\n'
				'{commit}'.format(
					kernel_name=kernel_name, server=self.server_for_upload_package, link=link,
					log=git_log, package=package_list, version=kernel_version,
					commit=latest_commit_information)
			)
		else:
			utils.emailer(
				'*****@*****.**',
				self.mailing_list,
				'new commit for {kernel_name} version: {version}'.format(
					kernel_name=kernel_name, version=kernel_version),
				'a new commit for {kernel_name} was build\n'
				'this commit was not uploaded to {server} and it is locally '
				'stored in : {output_dir}'
				'{log}\n\n '
				'Package list: \n'
				'{package}\n'
				'Kernel version: {version}\n\n'
				'{commit}'.format(
					output_dir=output_dir, kernel_name=kernel_name,
					server=self.server_for_upload_package, log=git_log,
					package=package_list, version=kernel_version,
					commit=latest_commit_information)
			)
def check_xserver_xorg():
    """Check the name of the configuration file xorg.conf in the system

	After a debian package is setup through clonezilla environment
	when Ubuntu starts for some reason the name of this file is changed to
	xorg.conf<random_number> and if the file has not the correct name TTY7 (X)
	will not be enabled.
	"""
    # validating if xserver is on graphic stack installed in the system

    path_graphic_stack = '/home/custom/graphic_stack/packages'
    xserver_in_easy_bugs = bash.get_output(
        'ls {0} | grep xserver '.format(path_graphic_stack)).decode('utf-8')

    if not xserver_in_easy_bugs:
        graphic_stack_package = bash.get_output(
            'ls {0} | grep .deb'.format(path_graphic_stack)).decode('utf-8')
        logger.info('the current graphic stack does not contains xserver')
        logger.info(graphic_stack_package)
        utils.emailer(
            sender, default_mailing_list,
            'the current graphic stack ({stack}) does not contains xserver'.
            format(stack=graphic_stack_package),
            'The following system does not contains a graphic stack for xserver\n'
            'host: {host}\nip: {ip}\n'.format(host=dut_hostname,
                                              ip=dut_static_ip))
        sys.exit(1)

    if not os.path.exists(control_file):
        xserver_original_name = 'xorg.conf'
        xserver_system_name = bash.get_output(
            'ls /etc/X11 | grep xorg.conf | grep -v failsafe').decode('utf-8')

        logger.info(
            '(xorg.conf) current name is: {0}'.format(xserver_system_name))

        if xserver_original_name != xserver_system_name:
            logger.info('changing to: {0}'.format(xserver_original_name))
            output = \
             os.system(
              'sudo mv ' +
              os.path.join('/etc', 'X11', xserver_system_name) +
              ' ' + os.path.join('/etc', 'X11', xserver_original_name))
            if output != 0:
                logger.error(
                    'an error has occurred trying to change the name of : {0}'.
                    format(xserver_system_name))
                utils.emailer(
                    sender, default_mailing_list,
                    'an error has occurred trying to change the name of ({0}) on ({1}) ({2})'
                    .format(xserver_system_name, dut_hostname, dut_static_ip),
                    'The following system has poorly configured (xorg.conf), '
                    'please check it manually:\n - ({0})\n - ({1})'.format(
                        dut_hostname, dut_static_ip))
                sys.exit(1)
            else:
                logger.info('({0}) was changed to ({1}) successfully'.format(
                    xserver_system_name, xserver_original_name))
                logger.info(
                    'creating a control file into: {0}'.format(control_file))
                os.system('touch ' + control_file)
                logger.info('rebooting the system')
                os.system('sudo reboot')
        else:
            logger.info(
                '(xserver_system_name) and (xserver_original_name) are the same'
            )
    else:
        bash.message('info', 'control file ({0}) exists'.format(control_file))
        bash.message('info', 'nothing to do')
        sys.exit(0)
Exemple #8
0
    def check_for_updates(self, path_to_repo, branch):
        """Check for updates in each folder into updater.yml

		:param path_to_repo: the selected path to the repository.
		:param branch: the selected branch for the repository.
		"""
        local_commit = \
         bash.get_output(
          'cd ' + path_to_repo + ' && git rev-parse origin/' + branch)
        remote_commit = \
         bash.get_output(
          'cd ' + path_to_repo + ' && timeout 5 git ls-remote origin ' +
          branch + ' | awk \'{print $1}\'')

        if local_commit != remote_commit:
            bash.message(
                'warn', '(' + path_to_repo + ') is (' + bash.YELLOW +
                'out-to-date' + bash.END + ')')
            bash.message('info', 'local commit  (' + local_commit + ')')
            bash.message('info', 'remote commit (' + remote_commit + ')')
            bash.message('info', 'updating repository ...')
            bash.message('info', 'counting the current commits ...')
            old_commits_number = \
             bash.get_output(
              'cd ' + path_to_repo + ' && git rev-list origin/' +
              branch + ' --count')
            old_commit_info = \
             bash.get_output(
              'cd ' + path_to_repo +
              ' && git log -1 --format=fuller origin/' + branch)
            bash.message('info', 'old commit information')
            print(old_commit_info)
            bash.message('cmd', 'git pull origin ' + branch)
            os.system('cd ' + path_to_repo + ' && git pull origin ' + branch)
            bash.message('cmd', 'git reset --hard origin/' + branch)
            os.system('cd ' + path_to_repo + ' && git reset --hard origin/' +
                      branch)
            new_commit_info = \
             bash.get_output(
              'cd ' + path_to_repo +
              ' && git log -1 --format=fuller origin/' + branch)
            bash.message('info', 'new commit information')
            print(old_commit_info)
            bash.message('info', 'counting the new commits ...')
            new_commits_number = bash.get_output('cd ' + path_to_repo +
                                                 ' && git rev-list origin/' +
                                                 branch + ' --count')
            new_commit = \
             bash.get_output(
              'cd ' + path_to_repo +
              ' && git rev-parse origin/' + branch)

            if local_commit != new_commit:
                bash.message(
                    'ok', '(' + os.path.basename(path_to_repo) + ') is (' +
                    bash.GREEN + 'up-to-date' + bash.END + ')')
                commits_diff = int(new_commits_number) - int(
                    old_commits_number)
                bash.message(
                    'info', 'commits downloaded : (' + str(commits_diff) + ')')
                bash.message('info', 'sending a email notification')
                utils.emailer(
                    self.sender, self.mailing_list,
                    'There is a new commit for (' +
                    os.path.basename(path_to_repo) + ') (' + self.month +
                    ') (' + self.week_day + ') (' + self.hour + ')',
                    'There is a new commit for (' +
                    os.path.basename(path_to_repo) +
                    ')\n\nCommits downloaded : (' + str(commits_diff) +
                    ')\n\nLatest commit is:\n\n' + new_commit_info)

            else:
                bash.message('info', 'local commit (' + local_commit + ')')
                bash.message('info', 'new commit   (' + new_commit + ')')
                bash.message(
                    'err', '(' + os.path.basename(path_to_repo) + ') is (' +
                    bash.YELLOW + 'out-to-date' + bash.END + ')')
                bash.message(
                    'err', 'an error occurred trying to update (' +
                    os.path.basename(path_to_repo) + ')')

        else:
            bash.message(
                'info', '(' + os.path.basename(path_to_repo) + ') is (' +
                bash.GREEN + 'up-to-date' + bash.END + ')')
            bash.message('info', 'local commit  (' + local_commit + ')')
            bash.message('info', 'remote commit (' + remote_commit + ')')
            current_commit_info = \
             bash.get_output(
              'cd ' + path_to_repo +
              ' && git log -1 --format=fuller origin/' + branch)
            bash.message('info', 'current commit information\n\n')
            print(current_commit_info + '\n\n')
    def orchestrator(self):
        """Managing of the automated intel-gpu-tools execution.

		The aim of this function is to manage the automated execution of
		intel-gpu-tools fastfeedback of the DUTs connected to the system.
		"""
        # check the previous execution
        self.check_previous_execution()

        # getting a graphic stack code for the execution
        graphic_stack_code = self.get_graphic_stack_code()

        # getting a kernel commit for the execution
        kernel_commit = self.get_kernel_commit()

        # if the graphic stack or the kernel are new components, the build_id
        # function will create a new entry in API and this will return a new
        # build_id, otherwise this will return an existing build_id.
        get_dict_from_api = apiutils.get_build_id_dict(
            stop=True,
            graphic_stack_code=graphic_stack_code,
            kernel_commit=kernel_commit,
            hour=self.hour,
            year=self.year,
            week_number=self.week_number,
            kernel_branch='drm-intel-qa',
            suite='igt_fast_feedback',
            latest='true')

        # creating the configuration files
        self.create_configuration_files(graphic_stack_code=graphic_stack_code,
                                        kernel_commit=kernel_commit,
                                        build_id=get_dict_from_api['build_id'],
                                        build_status=get_dict_from_api['New'])

        table_headers = [
            'Platform', 'Status', 'Hostname', 'Switch', 'IP address',
            'USB Cutter'
        ]

        if self.systems_to_launch:
            # creating the table
            table = utils.create_formatted_table(table_headers,
                                                 self.table_content_launch,
                                                 index=True,
                                                 silent=True)

            # if there is some system busy, this part will create the file
            # platforms_not_launched.yml
            self.check_for_systems_not_launched()

            if self.grab_systems_busy:
                utils.emailer(
                    self.sender,
                    self.mailing_list,
                    'fastfeedback was launched on ({year}) (WW{week_number}) '
                    '({week_day}) ({hour}) (grabsystemsbusy)'.format(
                        year=self.year,
                        week_number=self.week_number,
                        week_day=self.week_day,
                        hour=self.hour),
                    'fastfeedback was launched on the following platforms\n\n'
                    + table.encode('utf-8'),
                    silent=True)
            elif self.dryrun:
                utils.emailer(
                    self.sender,
                    self.mailing_list,
                    'fastfeedback was launched on ({year}) (WW{week_number}) '
                    '({week_day}) ({hour}) (dryrun)'.format(
                        year=self.year,
                        week_number=self.week_number,
                        week_day=self.week_day,
                        hour=self.hour),
                    'fastfeedback was launched on the following platforms\n\n'
                    + table.encode('utf-8'),
                    silent=True)
            else:
                utils.emailer(
                    self.sender,
                    self.mailing_list,
                    'fastfeedback was launched on ({year}) (WW{week_number}) '
                    '({week_day}) ({hour})'.format(
                        year=self.year,
                        week_number=self.week_number,
                        week_day=self.week_day,
                        hour=self.hour),
                    'fastfeedback was launched on the following platforms\n\n'
                    + table.encode('utf-8'),
                    silent=True)

            print(table.encode('utf-8'))
            sys.exit(0)

        else:
            # creating the table
            table = utils.create_formatted_table(table_headers,
                                                 self.table_content_not_launch,
                                                 index=True,
                                                 silent=True)

            # if there is some system busy, this part will create the file
            # platforms_not_launched.yml
            self.check_for_systems_not_launched()

            self.log.warning(
                'there is not platforms to launch intel-gpu-tools (fastfeedback)'
            )
            utils.emailer(
                self.sender,
                self.mailing_list,
                'fastfeedback could not be launched on ({year}) '
                '(WW{week_number}) ({week_day}) ({hour})'.format(
                    year=self.year,
                    week_number=self.week_number,
                    week_day=self.week_day,
                    hour=self.hour),
                'fastfeedback could not be launched due to not platforms '
                'are available\n\n' + table.encode('utf-8'),
                silent=True)

            print(table.encode('utf-8'))
            sys.exit(0)
    def check_previous_execution(self):
        """Check for the previous execution

		The aim of this function is to check if intel-gpu-tools/kernel commits
		exist in the latest data returned by the API, in this case this will
		stop the script execution since does not make sense to run again with
		the same components reported in the latest execution.
		"""

        igt_path = '/home/shared/repositories/intel-gpu-tools'
        drm_tip_path = '/home/shared/repositories/drm-tip'

        # checking if the folders exist
        for path in igt_path, drm_tip_path:
            if not os.path.exists(path):
                self.log.error('{0} : does not exist'.format(path))
                sys.exit(1)

        # getting the latest commit of intel-gpu-tools
        latest_igt_commit = bash.get_output(
            'git -C {0} ls-remote origin master'.format(
                igt_path)).split()[0][:7]

        # getting the latest commit of drm-tip
        latest_drm_tip_commit = bash.get_output(
            'git -C {0} ls-remote origin drm-tip'.format(
                drm_tip_path)).split()[0][:7]

        # getting the intel-gpu-tools commit from a gfx_stack_code
        latest_igt_commit_bifrost = None
        graphic_stack_code = apiutils.get_latest_data_from_api(
            'gfx_stack_code', stop=True)
        if not graphic_stack_code:
            self.log.error('no graphic stack code was returned from the API')
            sys.exit(1)
        pattern = '*{0}*'.format(graphic_stack_code)

        for dirpath, dirnames, filenames in os.walk(self.debian_packages_path):
            if filenames:
                for archive in filenames:
                    if fnmatch.fnmatch(archive, pattern):
                        latest_igt_commit_bifrost = bash.get_output(
                            'cat {0}/easy-bugs | grep intel-gpu-tools -A1'.
                            format(dirpath)).split()[5][:7]

        # TODO(Beto): if this condition is met, we have to delete this build id
        # automatically from the API in order to avoid issues with clonezilla
        # (known errata)
        if not latest_igt_commit_bifrost:
            self.log.error(
                '({0}) : graphic stack code does not exits in bifrost however '
                'exist in the API, you have to delete it from the API in order '
                'to avoid conflicts with clonezilla'.format(
                    graphic_stack_code))
            sys.exit(1)

        # checking if igt/kernel commit is in the latest data from the API
        conditions = [
            latest_igt_commit == latest_igt_commit_bifrost,
            latest_drm_tip_commit == apiutils.get_latest_data_from_api(
                'kernel_commit')
        ]

        if all(conditions):
            self.log.info(
                'the following intel-gpu-tools commit is already in latest data '
                'from the API : {0}'.format(latest_igt_commit))
            self.log.info(
                'the following drm-tip commit is already in latest data '
                'from the API : {0}'.format(latest_drm_tip_commit))

            utils.emailer(
                self.sender,
                self.mailing_list,
                'fastfeedback was not launched on ({year}) '
                '(WW{week_number}) ({week_day}) ({hour})'.format(
                    year=self.year,
                    week_number=self.week_number,
                    week_day=self.week_day,
                    hour=self.hour),
                'fastfeedback was not launched due to drm-tip/intel-gpu-tools '
                'commits exist on latest data from the API)\n\n'
                'drm-tip commit         : {kernel_commit}\n'
                'intel-gpu-tools commit : {igt_commit}'.format(
                    kernel_commit=latest_drm_tip_commit,
                    igt_commit=latest_igt_commit),
                silent=True)
            sys.exit(1)
Exemple #11
0
 def test_emailer(self, mock_sendmail):
     utils.emailer('tester', ['*****@*****.**'], 'my subject',
                   'test message')
     mock_sendmail.assert_called_once()