def test_logger_test_results(self, mock_logger_info): CONST.__setattr__('results_test_db_url', self.db_url) CONST.__setattr__('BUILD_TAG', self.build_tag) CONST.__setattr__('NODE_NAME', self.node_name) CONST.__setattr__('DEPLOY_SCENARIO', self.scenario) with mock.patch('functest.utils.functest_utils.get_version', return_value=self.version): functest_utils.logger_test_results(self.project, self.case_name, self.status, self.details) mock_logger_info.assert_called_once_with( "\n" "****************************************\n" "\t %(p)s/%(n)s results \n\n" "****************************************\n" "DB:\t%(db)s\n" "pod:\t%(pod)s\n" "version:\t%(v)s\n" "scenario:\t%(s)s\n" "status:\t%(c)s\n" "build tag:\t%(b)s\n" "details:\t%(d)s\n" % { 'p': self.project, 'n': self.case_name, 'db': CONST.__getattribute__('results_test_db_url'), 'pod': self.node_name, 'v': self.version, 's': self.scenario, 'c': self.status, 'b': self.build_tag, 'd': self.details })
def test_logger_test_results(self, mock_logger_info): with mock.patch('functest.utils.functest_utils.get_pod_name', return_value=self.node_name), \ mock.patch('functest.utils.functest_utils.get_scenario', return_value=self.scenario), \ mock.patch('functest.utils.functest_utils.get_version', return_value=self.version), \ mock.patch('functest.utils.functest_utils.get_build_tag', return_value=self.build_tag), \ mock.patch('functest.utils.functest_utils.get_db_url', return_value=self.db_url): functest_utils.logger_test_results(self.project, self.case_name, self.status, self.details) mock_logger_info.assert_called_once_with( "\n" "****************************************\n" "\t %(p)s/%(n)s results \n\n" "****************************************\n" "DB:\t%(db)s\n" "pod:\t%(pod)s\n" "version:\t%(v)s\n" "scenario:\t%(s)s\n" "status:\t%(c)s\n" "build tag:\t%(b)s\n" "details:\t%(d)s\n" % {'p': self.project, 'n': self.case_name, 'db': self.db_url, 'pod': self.node_name, 'v': self.version, 's': self.scenario, 'c': self.status, 'b': self.build_tag, 'd': self.details})
def run(self, **kwargs): """Run the feature. It allows executing any Python method by calling execute(). It sets the following attributes required to push the results to DB: * result, * start_time, * stop_time. It doesn't fulfill details when pushing the results to the DB. Args: kwargs: Arbitrary keyword arguments. Returns: TestCase.EX_OK if execute() returns 0, TestCase.EX_RUN_ERROR otherwise. """ self.start_time = time.time() exit_code = base.TestCase.EX_RUN_ERROR self.result = 0 try: if self.execute(**kwargs) == 0: exit_code = base.TestCase.EX_OK self.result = 100 ft_utils.logger_test_results(self.project_name, self.case_name, self.result, self.details) except Exception: # pylint: disable=broad-except self.__logger.exception("%s FAILED", self.project_name) self.__logger.info("Test result is stored in '%s'", self.result_file) self.stop_time = time.time() return exit_code
def run(self, **kwargs): cmd = 'cd %s/tests && ./functest_run.sh' % ft_constants.PARSER_REPO_DIR self.start_time = time.time() ret = ft_utils.execute_command(cmd, info=True, output_file=self.log_file) self.stop_time = time.time() self.criteria, details = ft_utils.check_test_result( self.project_name, ret, self.start_time, self.stop_time) ft_utils.logger_test_results(self.project_name, self.case_name, self.criteria, details) return ret
def main(): start_time = time.time() result_os = test_moon_openstack() result_odl = test_federation() stop_time = time.time() duration = round(stop_time - start_time, 1) if result_os[0] == 0 and result_odl[0]: logger.info("OS MOON PASSED") test_status = 'PASS' else: logger.info("OS MOON ERROR") test_status = 'FAIL' logger.info("Errors from OpenStack tests:") logger.info(result_os[1]) logger.info("Errors from Federation tests:") logger.info(result_odl[1]) details = { 'timestart': start_time, 'duration': duration, 'status': test_status, 'results': { 'openstack': result_os, 'opendaylight': result_odl } } functest_utils.logger_test_results("moon", "moon_authentication", test_status, details) if args.report: functest_utils.push_results_to_db("moon", "moon_authentication", start_time, stop_time, test_status, details) logger.info("Moon results pushed to DB") if result_os[0] != 0 or not result_odl[0]: return False return True
def main(): cmd = "%s/tests/run.sh %s/tests" % (COPPER_REPO_DIR, COPPER_REPO_DIR) start_time = time.time() log_file = RESULTS_DIR + "/copper.log" ret_val = functest_utils.execute_command(cmd, output_file=log_file) stop_time = time.time() duration = round(stop_time - start_time, 1) if ret_val == 0: logger.info("COPPER PASSED") test_status = 'PASS' else: logger.info("COPPER FAILED") test_status = 'FAIL' details = { 'timestart': start_time, 'duration': duration, 'status': test_status, } functest_utils.logger_test_results("Copper", "copper-notification", details['status'], details) try: if args.report: functest_utils.push_results_to_db("copper", "copper-notification", start_time, stop_time, details['status'], details) logger.info("COPPER results pushed to DB") except: logger.error("Error pushing results into Database '%s'" % sys.exc_info()[0]) if ret_val != 0: sys.exit(-1) sys.exit(0)
def main(): exit_code = -1 # if the image name is explicitly set for the doctor suite, set it as # enviroment variable if 'doctor' in functest_yaml and 'image_name' in functest_yaml['doctor']: os.environ["IMAGE_NAME"] = functest_yaml['doctor']['image_name'] cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO_DIR log_file = RESULTS_DIR + "/doctor.log" start_time = time.time() ret = functest_utils.execute_command(cmd, info=True, output_file=log_file) stop_time = time.time() duration = round(stop_time - start_time, 1) if ret == 0: logger.info("Doctor test case OK") test_status = 'OK' exit_code = 0 else: logger.info("Doctor test case FAILED") test_status = 'NOK' details = { 'timestart': start_time, 'duration': duration, 'status': test_status, } status = "FAIL" if details['status'] == "OK": status = "PASS" functest_utils.logger_test_results("Doctor", "doctor-notification", status, details) if args.report: functest_utils.push_results_to_db("doctor", "doctor-notification", start_time, stop_time, status, details) logger.info("Doctor results pushed to DB") exit(exit_code)
def log_results(self): ft_utils.logger_test_results(self.project_name, self.case_name, self.criteria, self.details)