def run(self): if self.metadata_container is None: return self.chosen_endpoint, self.chosen_zone, self.chosen_volume, self.chosen_volume_collection = (None,)*4 self.initiator_endpoint, self.target_endpoint, self.zone_endpoint, self.created_volume = (None,)*4 test_name = "Storage Services CRUD test" print "MESSAGE::%s starting" % test_name print "TEST_CASE::API crawling" api_explorer = ApiExplorer(self.metadata_container, self.configuration) self.discovery_container, status = api_explorer.discover(MetadataConstants.SERVICE_ROOT_URI, MetadataConstants.SERVICE_ROOT) print "STATUS::{status}".format(status=status) requirements = [ Requirement(MetadataConstants.SERVICE_ROOT, min=1, max=1), Requirement(MetadataConstants.STORAGE_SERVICE, min=1), Requirement(MetadataConstants.VOLUME, min=1), Requirement(MetadataConstants.VOLUME_COLLECTION, min=1) ] preconditions = Preconditions(self.metadata_container, requirements) status = preconditions.validate(self.discovery_container) if status == ValidationStatus.FAILED: self.set_status_failed() return self.api_caller = ApiCaller(self.configuration) status = ValidationStatus.join_statuses(status, self.crud_fabrics_target()) print "MESSAGE::%s overall status: %s" % (test_name, ColorPrinter.format_status(status))
def write(self, msg): """ :type msg: str :param msg: message to log """ if msg.startswith("%s%s" % (self.LOG_PREFIX, self.SEPARATOR)): print >> self.logging_messages_stream, "".join( msg.split(self.SEPARATOR)[1:]) elif msg.startswith("%s%s" % (self.TEST_CASE_TITLE, self.SEPARATOR)): Indent.indent_reset() test_case = "".join(msg.split(self.SEPARATOR)[1:]).strip() self.logging_messages_stream.set_active_case(test_case) msg = '\nTest case: {test_case}'.format(test_case=test_case) print "%s%s" % (indent(), ColorPrinter.format_text( msg, color=ColorPrinter.BLUE_FORE, bold=True)) Indent.indent_right() elif msg.startswith("%s%s" % (self.STATUS, self.SEPARATOR)): status = "".join(msg.split(self.SEPARATOR)[1:]).strip() self.logging_messages_stream.set_case_status(status) print "%s%s" % (indent(), ColorPrinter.format_status(status, bold=True)) Indent.indent_reset() elif msg.startswith(self.SCREEN): print "%s%s" % (indent(), "".join(msg.split( self.SCREEN)[1:]).strip()) else: print >> self.logging_messages_stream, msg
def write(self, msg): """ :type msg: str :param msg: message to log """ if msg.startswith("%s%s" % (self.LOG_PREFIX, self.SEPARATOR)): print >> self.logging_messages_stream, "".join(msg.split(self.SEPARATOR)[1:]) elif msg.startswith("%s%s" % (self.TEST_CASE_TITLE, self.SEPARATOR)): Indent.indent_reset() test_case = "".join(msg.split(self.SEPARATOR)[1:]).strip() self.logging_messages_stream.set_active_case(test_case) msg = '\nTest case: {test_case}'.format(test_case=test_case) print "%s%s" % ( indent(), ColorPrinter.format_text(msg, color=ColorPrinter.BLUE_FORE, bold=True)) Indent.indent_right() elif msg.startswith("%s%s" % (self.STATUS, self.SEPARATOR)): status = "".join(msg.split(self.SEPARATOR)[1:]).strip() self.logging_messages_stream.set_case_status(status) print "%s%s" % ( indent(), ColorPrinter.format_status(status, bold=True) ) Indent.indent_reset() elif msg.startswith(self.SCREEN): print "%s%s" % ( indent(), "".join(msg.split(self.SCREEN)[1:]).strip() ) else: print >> self.logging_messages_stream, msg
def run(self): if self.metadata_container is None: return test_name = "Storage Services CRUD test" print "MESSAGE::%s starting" % test_name print "TEST_CASE::API crawling" api_explorer = ApiExplorer(self.metadata_container, self.configuration) self.discovery_container, status = api_explorer.discover(MetadataConstants.SERVICE_ROOT_URI, MetadataConstants.SERVICE_ROOT) print "STATUS::{status}".format(status=status) requirements = [ Requirement(MetadataConstants.SERVICE_ROOT, min=1, max=1), Requirement(MetadataConstants.STORAGE_SERVICE, min=1), Requirement(MetadataConstants.LOGICAL_DRIVE_COLLECTION, min=1), Requirement(MetadataConstants.REMOTE_TARGET_COLLECTION, min=1), Requirement(MetadataConstants.LOGICAL_DRIVE, min=2) ] preconditions = Preconditions(self.metadata_container, requirements) status = preconditions.validate(self.discovery_container) if status == ValidationStatus.FAILED: self.set_status_blocked() return self.api_caller = ApiCaller(self.configuration) status = ValidationStatus.join_statuses(status, self.crud_logical_drive()) status = ValidationStatus.join_statuses(status, self.crud_remote_target()) print "MESSAGE::%s overall status: %s" % (test_name, ColorPrinter.format_status(status))
def format_script_results(self, script_execution_id): script_execution = ScriptDAO.get_script_execution_details(script_execution_id) status, passed, total = ScriptDAO.get_script_execution_statistics(script_execution_id) overall_status = ResultStatus.PASSED if status else ResultStatus.FAILED results_header = "Test script{horizontal_separator}{test_script_path}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, test_script_path=script_execution.script_path, vertical_separator=VERTICAL_SEPARATOR) results_header += "Overall status{horizontal_separator}{overall_status}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, overall_status=ColorPrinter.format_status(overall_status), vertical_separator=VERTICAL_SEPARATOR) results_header += "Pass rate{horizontal_separator}{passed}/{total}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, passed=passed, total=total, vertical_separator=VERTICAL_SEPARATOR) results_header += "configuration:{vertical_separator}".format(vertical_separator=VERTICAL_SEPARATOR) for param in script_execution.configuration.split("--"): if not param: continue param_name = param.split(" ")[0] if param_name in [PARAM_USER, PARAM_PASSWORD]: param_value = "**********" else: param_value = "".join(param.split(" ")[1:]) results_header += \ "{horizontal_separator}" \ "{param_name:10}{horizontal_separator}" \ "{param_value}{vertical_separator}" \ .format(vertical_separator=VERTICAL_SEPARATOR, param_name=param_name, param_value=param_value, horizontal_separator=HORIZONTAL_SEPARATOR) results_header += "Level of details -d{level}\n".format(level=self.message_level) results_header += "Reported cases" yield results_header cases_results = (self.format_case_results(case_execution_id) for case_execution_id in CaseDAO.get_cases_execution_ids_for_script_execution(script_execution_id)) yield VERTICAL_SEPARATOR for case_result in cases_results: for line in case_result: yield line yield VERTICAL_SEPARATOR
def run(self): if self.metadata_container is None: return self.chosen_endpoint, self.chosen_zone, self.chosen_volume, self.chosen_volume_collection = ( None, ) * 4 self.initiator_endpoint, self.target_endpoint, self.zone_endpoint, self.created_volume = ( None, ) * 4 self.initiator_unique_name = self.generate_unique_names() if self.configuration.UniqueInitiatorName \ != "generate" else self.configuration.UniqueInitiatorName self.target_unique_name = self.generate_unique_names() if self.configuration.UniqueTargetName \ != "generate" else self.configuration.UniqueTargetName test_name = "Storage Services CRUD test with NVM Express (NVMe) Support" print "MESSAGE::%s starting" % test_name print "TEST_CASE::API crawling" api_explorer = ApiExplorer(self.metadata_container, self.configuration) self.discovery_container, status = api_explorer.discover( MetadataConstants.SERVICE_ROOT_URI, MetadataConstants.SERVICE_ROOT) print "STATUS::{status}".format(status=status) requirements = [ Requirement(MetadataConstants.SERVICE_ROOT, min=1, max=1), Requirement(MetadataConstants.STORAGE_SERVICE, min=1), Requirement(MetadataConstants.VOLUME, min=1), Requirement(MetadataConstants.VOLUME_COLLECTION, min=1) ] preconditions = Preconditions(self.metadata_container, requirements) status = preconditions.validate(self.discovery_container) if status == ValidationStatus.FAILED: self.set_status_failed() return self.api_caller = ApiCaller(self.configuration) status = ValidationStatus.join_statuses(status, self.crud_nvme()) print "MESSAGE::%s overall status: %s" % ( test_name, ColorPrinter.format_status(status))
def format_case_results(self, case_execution_id): case_execution_details = CaseDAO.get_case_execution_details(case_execution_id) results_header = "Test Case: {case_name}{vertical_separator}{vertical_separator}".format( case_name=case_execution_details.name, vertical_separator=VERTICAL_SEPARATOR) results_footer = "{vertical_separator}{horizontal_separator}[{status}]\t{case_name}{vertical_separator}".format( horizontal_separator=HORIZONTAL_SEPARATOR, case_name=case_execution_details.name, status=ColorPrinter.format_status(case_execution_details.status), vertical_separator=VERTICAL_SEPARATOR) yield VERTICAL_SEPARATOR yield results_header for messages in self.format_case_messages(case_execution_id): yield messages yield VERTICAL_SEPARATOR yield results_footer yield VERTICAL_SEPARATOR yield CASE_SEPARATOR