Fix parsing of mime-type at subunit-v2-parser

+ ignore unwanted test id with strange data
+ do not try to split charset from mime-type. we do not use it.

Change-Id: I374c45008dcdfb910d34868df795e6dbf5b962a3
Closes-Bug: #1871406
This commit is contained in:
Andrey Kurilin 2020-04-21 17:23:31 +03:00
parent d6cb04faef
commit b9c303c2f4
3 changed files with 20 additions and 11 deletions

View File

@ -17,6 +17,17 @@ Changelog
.. Release notes for existing releases are MUTABLE! If there is something that
was missed or can be improved, feel free to change it!
[unreleased]
------------
Fixed
~~~~~
* [verification component] Failure while parsing subunit v2 stream in case of
unwanted test_id
`Launchpad-bug #1871406 <https://launchpad.net/bugs/1871406>`_
[3.0.0] - 2020-03-23
--------------------

View File

@ -20,13 +20,18 @@ from rally.common import logging
from rally.utils import encodeutils
_IGNORE_LIST = [
"subunit.parser"
]
def prepare_input_args(func):
# NOTE(andreykurilin): Variables 'runnable', 'eof', 'route_code' are not
# used in parser.
def inner(self, test_id=None, test_status=None, timestamp=None,
file_name=None, file_bytes=None, mime_type=None, test_tags=None,
runnable=True, eof=False, route_code=None):
if not test_id:
if not test_id or test_id in _IGNORE_LIST:
return
if (test_id.startswith("setUpClass (")
@ -35,14 +40,8 @@ def prepare_input_args(func):
tags = _parse_test_tags(test_id)
if mime_type:
mime_type, charset = mime_type.split("; ")[:2]
charset = charset.split("=")[1]
else:
charset = None
func(self, test_id, test_status, timestamp, tags,
file_name, file_bytes, test_tags, mime_type, charset)
file_name, file_bytes, test_tags, mime_type)
return inner
@ -161,8 +160,7 @@ class SubunitV2StreamResult(object):
@prepare_input_args
def status(self, test_id=None, test_status=None, timestamp=None, tags=None,
file_name=None, file_bytes=None, worker=None, mime_type=None,
charset=None):
file_name=None, file_bytes=None, worker=None, mime_type=None):
if timestamp:
if not self._first_timestamp:
self._first_timestamp = timestamp

View File

@ -98,7 +98,7 @@ RuntimeError: broken setUp method
@subunit_v2.prepare_input_args
def some_a(self_, test_id, test_status, timestamp, test_tags,
file_name, file_bytes, worker, mime_type, charset):
file_name, file_bytes, worker, mime_type):
some_mock(test_id, test_tags)
some_a("", "setUpClass (some_test[tag1,tag2])")