Use regex for test group searching in console
Searching by regex is much faster and it boosts console text parsing speed in hundreds times. Change-Id: Ib9707695a0473b402d83172c3d7219d4e1108f0a
This commit is contained in:
parent
7bb9751385
commit
aa452a4472
@ -100,7 +100,7 @@ class Build(object):
|
||||
job_url = "/".join([JENKINS["url"], 'job', self.name,
|
||||
str(self.number), 'consoleText'])
|
||||
logger.debug("Request job console from {}".format(job_url))
|
||||
return requests.get(job_url).text.split('\n')
|
||||
return requests.get(job_url).text
|
||||
|
||||
def get_build_data(self, depth=1):
|
||||
build_url = "/".join([JENKINS["url"], 'job',
|
||||
|
@ -40,6 +40,7 @@ GROUP_FIELD = 'custom_test_group'
|
||||
|
||||
STEP_NUM_PATTERN = re.compile(r'^(\d{1,3})[.].+')
|
||||
DURATION_PATTERN = re.compile(r'Duration:?\s+(\d+(?:[sm]|\s?m))(?:in)?\b')
|
||||
TEST_GROUP_PATTERN = re.compile(r'run_system_test.py\s+.*--group=(\S+)\b')
|
||||
|
||||
|
||||
def get_tests_descriptions(milestone_id, tests_include, tests_exclude, groups,
|
||||
@ -162,10 +163,8 @@ def get_tests_groups_from_jenkins(runner_name, build_number, distros):
|
||||
# Get the test group from the console of the job
|
||||
z = Build(b['jobName'], b['buildNumber'])
|
||||
console = z.get_job_console()
|
||||
groups = [keyword.split('=')[1]
|
||||
for line in console
|
||||
for keyword in line.split()
|
||||
if 'run_system_test.py' in line and '--group=' in keyword]
|
||||
groups = re.findall(TEST_GROUP_PATTERN, console)
|
||||
|
||||
if not groups:
|
||||
logger.error("No test group found in console of the job {0}/{1}"
|
||||
.format(b['jobName'], b['buildNumber']))
|
||||
|
Loading…
Reference in New Issue
Block a user