Search target Test Runs across all available Plans
Previously TESTRAIL_TESTS_DEPTH setting was applied while
getting a list of latest test plans created for given
milestone.
Now it's applied directly for test runs count with
provided test suite and configuration, so test plans which
do not contain such runs are just skipped. This improvement
is needed, because currently we create a lot of test plans
w/o SWARM run, so bugs links copying mechanism doesn't work
as expected.
Change-Id: Iac76a3461c44ca113ce334a397f9628d7cf6863a
(cherry picked from commit 4545efcc2b
)
This commit is contained in:
parent
9872689dfa
commit
d5002204fc
@ -361,6 +361,8 @@ def publish_results(project, milestone_id, test_plan,
|
|||||||
suite_id=suite_id,
|
suite_id=suite_id,
|
||||||
config_id=config_id,
|
config_id=config_id,
|
||||||
limit=TestRailSettings.previous_results_depth)
|
limit=TestRailSettings.previous_results_depth)
|
||||||
|
logger.debug('Found next test runs: {0}'.format(
|
||||||
|
[test_run['description'] for test_run in previous_tests_runs]))
|
||||||
cases = project.get_cases(suite_id=suite_id)
|
cases = project.get_cases(suite_id=suite_id)
|
||||||
tests = project.get_tests(run_id=test_run_ids[0])
|
tests = project.get_tests(run_id=test_run_ids[0])
|
||||||
results_to_publish = []
|
results_to_publish = []
|
||||||
|
@ -179,7 +179,7 @@ class TestRailProject(object):
|
|||||||
def get_case_fields(self):
|
def get_case_fields(self):
|
||||||
return self.client.send_get('get_case_fields')
|
return self.client.send_get('get_case_fields')
|
||||||
|
|
||||||
def get_plans(self, milestone_ids=None, limit=None):
|
def get_plans(self, milestone_ids=None, limit=None, offset=None):
|
||||||
plans_uri = 'get_plans/{project_id}'.format(
|
plans_uri = 'get_plans/{project_id}'.format(
|
||||||
project_id=self.project['id'])
|
project_id=self.project['id'])
|
||||||
if milestone_ids:
|
if milestone_ids:
|
||||||
@ -187,6 +187,8 @@ class TestRailProject(object):
|
|||||||
for m in milestone_ids])
|
for m in milestone_ids])
|
||||||
if limit:
|
if limit:
|
||||||
plans_uri += '&limit={0}'.format(limit)
|
plans_uri += '&limit={0}'.format(limit)
|
||||||
|
if offset:
|
||||||
|
plans_uri += '&offset={0}'.format(offset)
|
||||||
return self.client.send_get(plans_uri)
|
return self.client.send_get(plans_uri)
|
||||||
|
|
||||||
def get_plan(self, plan_id):
|
def get_plan(self, plan_id):
|
||||||
@ -256,14 +258,26 @@ class TestRailProject(object):
|
|||||||
return self.get_run(run_id=run['id'])
|
return self.get_run(run_id=run['id'])
|
||||||
|
|
||||||
def get_previous_runs(self, milestone_id, suite_id, config_id, limit=None):
|
def get_previous_runs(self, milestone_id, suite_id, config_id, limit=None):
|
||||||
all_runs = []
|
previous_runs = []
|
||||||
for plan in self.get_plans(milestone_ids=[milestone_id], limit=limit):
|
offset = 0
|
||||||
|
|
||||||
|
while len(previous_runs) < limit:
|
||||||
|
existing_plans = self.get_plans(milestone_ids=[milestone_id],
|
||||||
|
limit=limit,
|
||||||
|
offset=offset)
|
||||||
|
if not existing_plans:
|
||||||
|
break
|
||||||
|
|
||||||
|
for plan in existing_plans:
|
||||||
for entry in self.get_plan(plan['id'])['entries']:
|
for entry in self.get_plan(plan['id'])['entries']:
|
||||||
if entry['suite_id'] == suite_id:
|
if entry['suite_id'] == suite_id:
|
||||||
run_ids = [run for run in entry['runs'] if
|
run_ids = [run for run in entry['runs'] if
|
||||||
config_id in run['config_ids']]
|
config_id in run['config_ids']]
|
||||||
all_runs.extend(run_ids)
|
previous_runs.extend(run_ids)
|
||||||
return all_runs
|
|
||||||
|
offset += limit
|
||||||
|
|
||||||
|
return previous_runs
|
||||||
|
|
||||||
def add_run(self, new_run):
|
def add_run(self, new_run):
|
||||||
add_run_uri = 'add_run/{project_id}'.format(
|
add_run_uri = 'add_run/{project_id}'.format(
|
||||||
|
Loading…
Reference in New Issue
Block a user