def post(self):
        file_params = self.request.POST.getall(PARAM_FILE)
        if not file_params:
            self.response.out.write("FAIL: missing upload file field.")
            return

        builder = self.request.get(PARAM_BUILDER)
        if not builder:
            self.response.out.write("FAIL: missing builder parameter.")
            return

        master = self.request.get(PARAM_MASTER)
        test_type = self.request.get(PARAM_TEST_TYPE)

        logging.debug(
            "Processing upload request, master: %s, builder: %s, test_type: %s.",
            master, builder, test_type)

        # There are two possible types of each file_params in the request:
        # one file item or a list of file items.
        # Normalize file_params to a file item list.
        files = []
        logging.debug("test: %s, type:%s", file_params, type(file_params))
        for item in file_params:
            if not isinstance(item, list) and not isinstance(item, tuple):
                item = [item]
            files.extend(item)

        errors = []
        final_status_code = 200
        for file in files:
            if file.filename == "incremental_results.json":
                status_string, status_code = JsonResults.update(master, builder, test_type, file.value, is_full_results_format=False)
            elif file.filename == "times_ms.json":
                # We never look at historical times_ms.json files, so we can overwrite the existing one if it exists.
                status_string, status_code = TestFile.overwrite_or_add_file(master, builder, test_type, file.filename, file.value)
            else:
                status_string, status_code = TestFile.add_file(master, builder, test_type, file.filename, file.value)
                # FIXME: Upload full_results.json files for non-layout tests as well and stop supporting the
                # incremental_results.json file format.
                if status_code == 200 and file.filename == "full_results.json":
                    status_string, status_code = JsonResults.update(master, builder, test_type, file.value, is_full_results_format=True)

            if status_code == 200:
                logging.info(status_string)
            else:
                logging.error(status_string)
                errors.append(status_string)
                final_status_code = status_code

        if errors:
            messages = "FAIL: " + "; ".join(errors)
            self.response.set_status(final_status_code, messages)
            self.response.out.write(messages)
        else:
            self.response.set_status(200)
            self.response.out.write("OK")
Beispiel #2
0
    def post(self):
        file_params = self.request.POST.getall(PARAM_FILE)
        if not file_params:
            self.response.out.write("FAIL: missing upload file field.")
            return

        builder = self.request.get(PARAM_BUILDER)
        if not builder:
            self.response.out.write("FAIL: missing builder parameter.")
            return

        master = self.request.get(PARAM_MASTER)
        test_type = self.request.get(PARAM_TEST_TYPE)

        logging.debug(
            "Processing upload request, master: %s, builder: %s, test_type: %s.",
            master, builder, test_type)

        # There are two possible types of each file_params in the request:
        # one file item or a list of file items.
        # Normalize file_params to a file item list.
        files = []
        logging.debug("test: %s, type:%s", file_params, type(file_params))
        for item in file_params:
            if not isinstance(item, list) and not isinstance(item, tuple):
                item = [item]
            files.extend(item)

        errors = []
        for file in files:
            if file.filename == "incremental_results.json":
                # FIXME: Remove this check once we stop uploading incremental_results.json files for layout tests.
                if test_type == "layout-tests":
                    update_succeeded = True
                else:
                    update_succeeded = JsonResults.update(master, builder, test_type, file.value, is_full_results_format=False)
            else:
                update_succeeded = bool(TestFile.add_file(master, builder, test_type, file.filename, file.value))
                # FIXME: Upload full_results.json files for non-layout tests as well and stop supporting the
                # incremental_results.json file format.
                if file.filename == "full_results.json" and test_type == "layout-tests":
                    update_succeeded |= JsonResults.update(master, builder, test_type, file.value, is_full_results_format=True)

            if not update_succeeded:
                errors.append(
                    "Upload failed, master: %s, builder: %s, test_type: %s, name: %s." %
                    (master, builder, test_type, file.filename))

        if errors:
            messages = "FAIL: " + "; ".join(errors)
            logging.warning(messages)
            self.response.set_status(500, messages)
            self.response.out.write("FAIL")
        else:
            self.response.set_status(200)
            self.response.out.write("OK")
    def get(self):
        key = self.request.get(PARAM_KEY)
        master = self.request.get(PARAM_MASTER)
        builder = self.request.get(PARAM_BUILDER)
        test_type = self.request.get(PARAM_TEST_TYPE)
        build_number = self.request.get(PARAM_BUILD_NUMBER, default_value=None)
        name = self.request.get(PARAM_NAME)
        before = self.request.get(PARAM_BEFORE)
        num_files = self.request.get(PARAM_NUM_FILES)
        test_list_json = self.request.get(PARAM_TEST_LIST_JSON)
        callback_name = self.request.get(PARAM_CALLBACK)

        logging.debug(
            "Getting files, master %s, builder: %s, test_type: %s, build_number: %s, name: %s, before: %s.",
            master, builder, test_type, build_number, name, before)

        if key:
            json, date = self._get_file_content_from_key(key)
        elif num_files or not master or not builder or not test_type or (
                not build_number
                and not JsonResults.is_aggregate_file(name)) or not name:
            limit = int(num_files) if num_files else 100
            self._get_file_list(master, builder, test_type, build_number, name,
                                before, limit, callback_name)
            return
        else:
            # FIXME: Stop using the old master name style after all files have been updated.
            master_data = master_config.getMaster(master)
            if not master_data:
                master_data = master_config.getMasterByMasterName(master)
            if not master_data:
                self.error(404)
                return

            json, date = self._get_file_content(master_data['url_name'],
                                                builder, test_type,
                                                build_number, name)
            if json is None:
                json, date = self._get_file_content(master_data['name'],
                                                    builder, test_type,
                                                    build_number, name)

            if json and test_list_json:
                json = JsonResults.get_test_list(builder, json)

        if json:
            json = _replace_jsonp_callback(json, callback_name)

        self._serve_json(json, date)
Beispiel #4
0
    def post(self):
        file_params = self.request.POST.getall(PARAM_FILE)
        if not file_params:
            self.response.out.write("FAIL: missing upload file field.")
            return

        builder = self.request.get(PARAM_BUILDER)
        if not builder:
            self.response.out.write("FAIL: missing builder parameter.")
            return

        master = self.request.get(PARAM_MASTER)
        test_type = self.request.get(PARAM_TEST_TYPE)
        incremental = self.request.get(PARAM_INCREMENTAL)

        logging.debug(
            "Processing upload request, master: %s, builder: %s, test_type: %s.",
            master, builder, test_type)

        # There are two possible types of each file_params in the request:
        # one file item or a list of file items.
        # Normalize file_params to a file item list.
        files = []
        logging.debug("test: %s, type:%s", file_params, type(file_params))
        for item in file_params:
            if not isinstance(item, list) and not isinstance(item, tuple):
                item = [item]
            files.extend(item)

        errors = []
        for file in files:
            filename = file.filename.lower()
            if ((incremental and filename == "results.json")
                    or (filename == "incremental_results.json")):
                # Merge incremental json results.
                update_succeeded = JsonResults.update(master, builder,
                                                      test_type, file.value)
            else:
                update_succeeded = TestFile.add_file(master, builder,
                                                     test_type, file.filename,
                                                     file.value)

            if not update_succeeded:
                errors.append(
                    "Upload failed, master: %s, builder: %s, test_type: %s, name: %s."
                    % (master, builder, test_type, file.filename))

        if errors:
            messages = "FAIL: " + "; ".join(errors)
            logging.warning(messages)
            self.response.set_status(500, messages)
            self.response.out.write("FAIL")
        else:
            self.response.set_status(200)
            self.response.out.write("OK")
Beispiel #5
0
    def post(self):
        file_params = self.request.POST.getall(PARAM_FILE)
        if not file_params:
            self.response.out.write("FAIL: missing upload file field.")
            return

        builder = self.request.get(PARAM_BUILDER)
        if not builder:
            self.response.out.write("FAIL: missing builder parameter.")
            return

        master = self.request.get(PARAM_MASTER)
        test_type = self.request.get(PARAM_TEST_TYPE)
        incremental = self.request.get(PARAM_INCREMENTAL)

        logging.debug(
            "Processing upload request, master: %s, builder: %s, test_type: %s.",
            master, builder, test_type)

        # There are two possible types of each file_params in the request:
        # one file item or a list of file items.
        # Normalize file_params to a file item list.
        files = []
        logging.debug("test: %s, type:%s", file_params, type(file_params))
        for item in file_params:
            if not isinstance(item, list) and not isinstance(item, tuple):
                item = [item]
            files.extend(item)

        errors = []
        for file in files:
            filename = file.filename.lower()
            if ((incremental and filename == "results.json") or
                (filename == "incremental_results.json")):
                # Merge incremental json results.
                update_succeeded = JsonResults.update(master, builder, test_type, file.value)
            else:
                update_succeeded = TestFile.add_file(
                    master, builder, test_type, file.filename, file.value)

            if not update_succeeded:
                errors.append(
                    "Upload failed, master: %s, builder: %s, test_type: %s, name: %s." %
                    (master, builder, test_type, file.filename))

        if errors:
            messages = "FAIL: " + "; ".join(errors)
            logging.warning(messages)
            self.response.set_status(500, messages)
            self.response.out.write("FAIL")
        else:
            self.response.set_status(200)
            self.response.out.write("OK")
Beispiel #6
0
    def _get_test_list_json(self, builder, test_type):
        """Return json file with test name list only, do not include test
           results and other non-test-data .

        Args:
            builder: builder name.
            test_type: type of test results.
        """

        json = self._get_file_content(builder, test_type, "results.json")
        if not json:
            return None

        return JsonResults.get_test_list(builder, json)
Beispiel #7
0
    def _get_test_list_json(self, builder, test_type):
        """Return json file with test name list only, do not include test
           results and other non-test-data .

        Args:
            builder: builder name.
            test_type: type of test results.
        """

        json = self._get_file_content(builder, test_type, "results.json")
        if not json:
            return None

        return JsonResults.get_test_list(builder, json)
    def get(self):
        key = self.request.get(PARAM_KEY)
        master = self.request.get(PARAM_MASTER)
        builder = self.request.get(PARAM_BUILDER)
        test_type = self.request.get(PARAM_TEST_TYPE)
        build_number = self.request.get(PARAM_BUILD_NUMBER, default_value=None)
        name = self.request.get(PARAM_NAME)
        before = self.request.get(PARAM_BEFORE)
        num_files = self.request.get(PARAM_NUM_FILES)
        test_list_json = self.request.get(PARAM_TEST_LIST_JSON)
        callback_name = self.request.get(PARAM_CALLBACK)

        logging.debug(
            "Getting files, master %s, builder: %s, test_type: %s, build_number: %s, name: %s, before: %s.",
            master, builder, test_type, build_number, name, before)

        if key:
            json, date = self._get_file_content_from_key(key)
        elif num_files or not master or not builder or not test_type or (not build_number and not JsonResults.is_aggregate_file(name)) or not name:
            limit = int(num_files) if num_files else 100
            self._get_file_list(master, builder, test_type, build_number, name, before, limit, callback_name)
            return
        else:
            # FIXME: Stop using the old master name style after all files have been updated.
            master_data = master_config.getMaster(master)
            if not master_data:
                master_data = master_config.getMasterByMasterName(master)
            if not master_data:
                self.error(404)
                return

            json, date = self._get_file_content(master_data['url_name'], builder, test_type, build_number, name)
            if json is None:
                json, date = self._get_file_content(master_data['name'], builder, test_type, build_number, name)

            if json and test_list_json:
                json = JsonResults.get_test_list(builder, json)

        if json:
            json = _replace_jsonp_callback(json, callback_name)

        self._serve_json(json, date)
    def post(self):
        file_params = self.request.POST.getall(PARAM_FILE)
        if not file_params:
            self.response.out.write("FAIL: missing upload file field.")
            return

        builder = self.request.get(PARAM_BUILDER)
        if not builder:
            self.response.out.write("FAIL: missing builder parameter.")
            return

        master_parameter = self.request.get(PARAM_MASTER)

        master_data = master_config.getMasterByMasterName(master_parameter)
        if master_data:
            deprecated_master = master_parameter
            master = master_data['url_name']
        else:
            deprecated_master = None
            master = master_parameter

        test_type = self.request.get(PARAM_TEST_TYPE)

        logging.debug(
            "Processing upload request, master: %s, builder: %s, test_type: %s.",
            master, builder, test_type)

        # There are two possible types of each file_params in the request:
        # one file item or a list of file items.
        # Normalize file_params to a file item list.
        files = []
        logging.debug("test: %s, type:%s", file_params, type(file_params))
        for item in file_params:
            if not isinstance(item, list) and not isinstance(item, tuple):
                item = [item]
            files.extend(item)

        errors = []
        final_status_code = 200
        for file in files:
            file_json = JsonResults._load_json(file.value)
            if file.filename == "incremental_results.json":
                # FIXME: Ferret out and eliminate remaining incremental_results.json producers.
                logging.info(
                    "incremental_results.json received from master: %s, builder: %s, test_type: %s.",
                    master, builder, test_type)
                status_string, status_code = JsonResults.update(
                    master,
                    builder,
                    test_type,
                    file_json,
                    deprecated_master=deprecated_master,
                    is_full_results_format=False)
            else:
                try:
                    build_number = int(file_json.get('build_number', 0))
                    status_string, status_code = TestFile.add_file(
                        master, builder, test_type, build_number,
                        file.filename, file.value)
                except (ValueError, TypeError):
                    status_code = 403
                    status_string = 'Could not cast the build_number field in the json to an integer.'

                if status_code == 200:
                    logging.info(status_string)
                else:
                    logging.error(status_string)
                    errors.append(status_string)
                    final_status_code = status_code

            if status_code == 200 and file.filename == "full_results.json":
                status_string, status_code = JsonResults.update(
                    master,
                    builder,
                    test_type,
                    file_json,
                    deprecated_master=deprecated_master,
                    is_full_results_format=True)

            if status_code == 200:
                logging.info(status_string)
            else:
                logging.error(status_string)
                errors.append(status_string)
                final_status_code = status_code

        if errors:
            messages = "FAIL: " + "; ".join(errors)
            self.response.set_status(final_status_code, messages)
            self.response.out.write(messages)
        else:
            self.response.set_status(200)
            self.response.out.write("OK")
    def post(self):
        file_params = self.request.POST.getall(PARAM_FILE)
        if not file_params:
            self.response.out.write("FAIL: missing upload file field.")
            return

        builder = self.request.get(PARAM_BUILDER)
        if not builder:
            self.response.out.write("FAIL: missing builder parameter.")
            return

        master_parameter = self.request.get(PARAM_MASTER)

        master_data = master_config.getMasterByMasterName(master_parameter)
        if master_data:
            deprecated_master = master_parameter
            master = master_data['url_name']
        else:
            deprecated_master = None
            master = master_parameter

        test_type = self.request.get(PARAM_TEST_TYPE)

        logging.debug(
            "Processing upload request, master: %s, builder: %s, test_type: %s.",
            master, builder, test_type)

        # There are two possible types of each file_params in the request:
        # one file item or a list of file items.
        # Normalize file_params to a file item list.
        files = []
        logging.debug("test: %s, type:%s", file_params, type(file_params))
        for item in file_params:
            if not isinstance(item, list) and not isinstance(item, tuple):
                item = [item]
            files.extend(item)

        errors = []
        final_status_code = 200
        for file in files:
            file_json = JsonResults._load_json(file.value)
            if file.filename == "incremental_results.json":
                # FIXME: Ferret out and eliminate remaining incremental_results.json producers.
                logging.info("incremental_results.json received from master: %s, builder: %s, test_type: %s.",
                             master, builder, test_type)
                status_string, status_code = JsonResults.update(master, builder, test_type, file_json,
                    deprecated_master=deprecated_master, is_full_results_format=False)
            else:
                try:
                    build_number = int(file_json.get('build_number', 0))
                    status_string, status_code = TestFile.add_file(master, builder, test_type, build_number, file.filename, file.value)
                except (ValueError, TypeError):
                    status_code = 403
                    status_string = 'Could not cast the build_number field in the json to an integer.'

                if status_code == 200:
                    logging.info(status_string)
                else:
                    logging.error(status_string)
                    errors.append(status_string)
                    final_status_code = status_code

            if status_code == 200 and file.filename == "full_results.json":
                status_string, status_code = JsonResults.update(master, builder, test_type, file_json,
                    deprecated_master=deprecated_master, is_full_results_format=True)

            if status_code == 200:
                logging.info(status_string)
            else:
                logging.error(status_string)
                errors.append(status_string)
                final_status_code = status_code

        if errors:
            messages = "FAIL: " + "; ".join(errors)
            self.response.set_status(final_status_code, messages)
            self.response.out.write(messages)
        else:
            self.response.set_status(200)
            self.response.out.write("OK")