コード例 #1
0
    def GenerateReportMessage(self, requested, executed):
        """Uploads the result to the web service.

        Requires the feature to be enabled; no-op otherwise.

        Args:
            requested: list, A list of test case records requested to run
            executed: list, A list of test case records that were executed

        Returns:
            binary string, serialized report message.
            None if web is not enabled.
        """
        if not self.enabled:
            return None

        # Handle case when runner fails, tests aren't executed
        if (not getattr(self, keys.ConfigKeys.RUN_AS_VTS_SELFTEST, False)
                and executed and executed[-1].test_name == "setup_class"):
            # Test failed during setup, all tests were not executed
            start_index = 0
        else:
            # Runner was aborted. Remaining tests weren't executed
            start_index = len(executed)

        for test in requested[start_index:]:
            msg = self.report_msg.test_case.add()
            msg.name = test.test_name
            msg.start_timestamp = feature_utils.GetTimestamp()
            msg.end_timestamp = msg.start_timestamp
            msg.test_result = ReportMsg.TEST_CASE_RESULT_FAIL

        self.report_msg.end_timestamp = feature_utils.GetTimestamp()

        build = getattr(self, keys.ConfigKeys.IKEY_BUILD)
        if keys.ConfigKeys.IKEY_BUILD_ID in build:
            build_id = str(build[keys.ConfigKeys.IKEY_BUILD_ID])
            self.report_msg.build_info.id = build_id

        logging.info("_tearDownClass hook: start (username: %s)",
                     getpass.getuser())

        if len(self.report_msg.test_case) == 0:
            logging.info("_tearDownClass hook: skip uploading (no test case)")
            return ''

        post_msg = ReportMsg.DashboardPostMessage()
        post_msg.test_report.extend([self.report_msg])

        self.rest_client.AddAuthToken(post_msg)

        message_b = base64.b64encode(post_msg.SerializeToString())

        logging.info('Result proto message generated. size: %s',
                     len(message_b))

        logging.info("_tearDownClass hook: status upload time stamp %s",
                     str(self.report_msg.start_timestamp))

        return message_b
コード例 #2
0
    def GenerateReportMessage(self, requested, executed):
        """Uploads the result to the web service.

        Requires the feature to be enabled; no-op otherwise.

        Args:
            requested: list, A list of test case records requested to run
            executed: list, A list of test case records that were executed

        Returns:
            binary string, serialized report message.
            None if web is not enabled.
        """
        if not self.enabled:
            return None

        for test in requested[len(executed):]:
            msg = self.report_msg.test_case.add()
            msg.name = test.test_name
            msg.start_timestamp = feature_utils.GetTimestamp()
            msg.end_timestamp = msg.start_timestamp
            msg.test_result = ReportMsg.TEST_CASE_RESULT_FAIL

        self.report_msg.end_timestamp = feature_utils.GetTimestamp()

        build = getattr(self, keys.ConfigKeys.IKEY_BUILD)
        if keys.ConfigKeys.IKEY_BUILD_ID in build:
            build_id = str(build[keys.ConfigKeys.IKEY_BUILD_ID])
            self.report_msg.build_info.id = build_id

        logging.debug("_tearDownClass hook: start (username: %s)",
                      getpass.getuser())

        if len(self.report_msg.test_case) == 0:
            logging.warn("_tearDownClass hook: skip uploading (no test case)")
            return ''

        post_msg = ReportMsg.DashboardPostMessage()
        post_msg.test_report.extend([self.report_msg])

        self.rest_client.AddAuthToken(post_msg)

        message_b = base64.b64encode(post_msg.SerializeToString())

        logging.debug('Result proto message generated. size: %s',
                      len(message_b))

        logging.debug("_tearDownClass hook: status upload time stamp %s",
                      str(self.report_msg.start_timestamp))

        return message_b
コード例 #3
0
    def Upload(self, requested, executed):
        """Uploads the result to the web service.

        Requires the feature to be enabled; no-op otherwise.

        Args:
            requested: list, A list of test case names requested to run
            executed: list, A list of test case names that were executed
        """
        if not self.enabled:
            return

        # Handle case when runner fails, tests aren't executed
        if (executed and executed[-1].test_name == "setup_class"):
            # Test failed during setup, all tests were not executed
            start_index = 0
        else:
            # Runner was aborted. Remaining tests weren't executed
            start_index = len(executed)

        for test in requested[start_index:]:
            msg = self.report_msg.test_case.add()
            msg.name = test
            msg.start_timestamp = feature_utils.GetTimestamp()
            msg.end_timestamp = msg.start_timestamp
            msg.test_result = ReportMsg.TEST_CASE_RESULT_FAIL

        self.report_msg.end_timestamp = feature_utils.GetTimestamp()

        build = getattr(self, keys.ConfigKeys.IKEY_BUILD)
        if keys.ConfigKeys.IKEY_BUILD_ID in build:
            build_id = str(build[keys.ConfigKeys.IKEY_BUILD_ID])
            self.report_msg.build_info.id = build_id

        logging.info("_tearDownClass hook: start (username: %s)",
                     getpass.getuser())

        if len(self.report_msg.test_case) > 0:
            post_msg = ReportMsg.DashboardPostMessage()
            post_msg.test_report.extend([self.report_msg])

            # Post new data to the dashboard
            self.rest_client.PostData(post_msg)

            logging.info("_tearDownClass hook: status upload time stamp %s",
                         str(self.report_msg.start_timestamp))
        else:
            logging.info("_tearDownClass hook: skip uploading (no test case)")