Merge lp:~sbaldassin/qakit/bileto_qakit into lp:qakit

Proposed by Santiago Baldassin
Status: Approved
Approved by: Sergio Cazzolato
Approved revision: 197
Proposed branch: lp:~sbaldassin/qakit/bileto_qakit
Merge into: lp:qakit
Diff against target: 79 lines (+28/-23)
2 files modified
qakit/practitest/practitest.py (+6/-2)
qakit/ust/worker.py (+22/-21)
To merge this branch: bzr merge lp:~sbaldassin/qakit/bileto_qakit
Reviewer Review Type Date Requested Status
Canonical Platform QA Team Pending
Review via email: mp+307565@code.launchpad.net

Commit message

Avoid the ust run if it was already triggered and return a default filter

Description of the change

This change prevents the ust run if it was already triggered and it also returns a default filter for those cases where the source package mapping was not added to the domains.json

To post a comment you must log in.

Unmerged revisions

197. By Santiago Baldassin

Minor changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qakit/practitest/practitest.py'
2--- qakit/practitest/practitest.py 2016-09-15 18:35:45 +0000
3+++ qakit/practitest/practitest.py 2016-10-04 13:03:19 +0000
4@@ -27,7 +27,7 @@
5 from qakit.practitest import auth
6 from qakit.practitest import util
7
8-
9+DEFAULT_FILTER_LIST = ["126288"]
10 PROD_PRACTITEST = 'https://prod.practitest.com/api'
11
12 TEST_LEVEL = '___f_10490'
13@@ -399,7 +399,11 @@
14 domains_file = os.path.join(practitest_dir, 'data', 'domains.json')
15 with open(domains_file) as domains:
16 domains_json = json.loads(domains.read())
17- filters = [domains_json[package] for package in src_pkgs]
18+ try:
19+ filters = [domains_json[package] for package in src_pkgs]
20+ except KeyError:
21+ return DEFAULT_FILTER_LIST
22
23 # Flat the lists and remove duplicates
24 return list(set([item for sublist in filters for item in sublist]))
25+
26
27=== modified file 'qakit/ust/worker.py'
28--- qakit/ust/worker.py 2016-09-15 19:32:05 +0000
29+++ qakit/ust/worker.py 2016-10-04 13:03:19 +0000
30@@ -62,27 +62,28 @@
31 is published in such a topic, it will be process by the
32 process_ust_request method which will call this one to run the tests
33 """
34- team, ppa_name = ppa.split('/')
35- launchpad_ppa = Ppa(team=team, name=ppa_name)
36- src_pkgs = launchpad_ppa.get_source_packages()
37- packages = list(
38- set([package.source_package_name for package in src_pkgs]))
39- request_id = launchpad_ppa.calculate_hash()
40-
41- pt = PractitestSession(self.conf.parser.get('practitest', 'project_id'),
42- self.conf.parser.get('practitest', 'api_key'),
43- self.conf.parser.get('practitest', 'api_secret_key'))
44- filters = pt.get_filters_for_src_pkgs(packages)
45- tests = pt.get_tests(filters)
46-
47- try:
48- tests_ids = ' '.join([test['___f_10589']['value'] for test in tests])
49- except KeyError:
50- tests_ids = ' '
51-
52- self.jenkins.build_job(self.conf.parser.get('jenkins', 'job_name'),
53- {"PPA": ppa, "TESTS_TO_RUN": tests_ids, "REQUEST_ID": request_id},
54- {'token': self.conf.parser.get('jenkins', 'token')})
55+ if self.get_result(ppa) is None:
56+ team, ppa_name = ppa.split('/')
57+ launchpad_ppa = Ppa(team=team, name=ppa_name)
58+ src_pkgs = launchpad_ppa.get_source_packages()
59+ packages = list(
60+ set([package.source_package_name for package in src_pkgs]))
61+ request_id = launchpad_ppa.calculate_hash()
62+
63+ pt = PractitestSession(self.conf.parser.get('practitest', 'project_id'),
64+ self.conf.parser.get('practitest', 'api_key'),
65+ self.conf.parser.get('practitest', 'api_secret_key'))
66+ filters = pt.get_filters_for_src_pkgs(packages)
67+ tests = pt.get_tests(filters)
68+
69+ try:
70+ tests_ids = ' '.join([test['___f_10589']['value'] for test in tests])
71+ except KeyError:
72+ tests_ids = ' '
73+
74+ self.jenkins.build_job(self.conf.parser.get('jenkins', 'job_name'),
75+ {"PPA": ppa, "TESTS_TO_RUN": tests_ids, "REQUEST_ID": request_id},
76+ {'token': self.conf.parser.get('jenkins', 'token')})
77
78 def get_result(self, ppa):
79 """

Subscribers

People subscribed via source and target branches