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

Proposed by Santiago Baldassin
Status: Needs review
Proposed branch: lp:~sbaldassin/qakit/trigger_unity8_snap_tests
Merge into: lp:qakit
Diff against target: 104 lines (+88/-0)
3 files modified
qakit/snappy/requirements.txt (+2/-0)
qakit/snappy/trigger.py (+69/-0)
qakit/snappy/trigger_sanity.sh (+17/-0)
To merge this branch: bzr merge lp:~sbaldassin/qakit/trigger_unity8_snap_tests
Reviewer Review Type Date Requested Status
Heber Parrucci (community) Needs Fixing
Review via email: mp+314625@code.launchpad.net

Commit message

Trigger unity8 snap sanity

Description of the change

This mp adds a entry point to qakit which will trigger a unity8 sanity test plan in jenkins every time a new version of the snap is available in the edge channel

To post a comment you must log in.
210. By Santiago Baldassin

Minor changes

Revision history for this message
Heber Parrucci (heber013) wrote :

Minor comments inline

review: Needs Fixing
211. By Santiago Baldassin

Adding a virtual env to trigger

212. By Santiago Baldassin

Addressing comments from the reviews

Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

All comments addressed

Revision history for this message
Heber Parrucci (heber013) wrote :

Some comments inline

review: Needs Fixing
Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Thanks for the feedback. All comments were addressed

213. By Santiago Baldassin

Addressing comments from the reviews

Unmerged revisions

213. By Santiago Baldassin

Addressing comments from the reviews

212. By Santiago Baldassin

Addressing comments from the reviews

211. By Santiago Baldassin

Adding a virtual env to trigger

210. By Santiago Baldassin

Minor changes

209. By Santiago Baldassin

Adding an entry point to trigger unity8 snap sanity tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'qakit/snappy'
2=== added file 'qakit/snappy/__init__.py'
3=== added file 'qakit/snappy/requirements.txt'
4--- qakit/snappy/requirements.txt 1970-01-01 00:00:00 +0000
5+++ qakit/snappy/requirements.txt 2017-01-26 13:35:32 +0000
6@@ -0,0 +1,2 @@
7+python-jenkins
8+requests
9
10=== added file 'qakit/snappy/trigger.py'
11--- qakit/snappy/trigger.py 1970-01-01 00:00:00 +0000
12+++ qakit/snappy/trigger.py 2017-01-26 13:35:32 +0000
13@@ -0,0 +1,69 @@
14+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
15+
16+#
17+# Ubuntu System Tests
18+# Copyright (C) 2017 Canonical
19+#
20+# This program is free software: you can redistribute it and/or modify
21+# it under the terms of the GNU General Public License as published by
22+# the Free Software Foundation, either version 3 of the License, or
23+# (at your option) any later version.
24+#
25+# This program is distributed in the hope that it will be useful,
26+# but WITHOUT ANY WARRANTY; without even the implied warranty of
27+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+# GNU General Public License for more details.
29+#
30+# You should have received a copy of the GNU General Public License
31+# along with this program. If not, see <http://www.gnu.org/licenses/>.
32+#
33+import argparse
34+import os
35+import sys
36+from configparser import ConfigParser
37+
38+from jenkins import Jenkins
39+import logging
40+import requests
41+
42+
43+def main(snap_name, series, arch, snap_url):
44+ headers = {"X-Ubuntu-Series": series, "X-Ubuntu-Architecture": arch}
45+ latest_revision_id = requests.get(snap_url, headers=headers).json()['revision']
46+
47+ parser = ConfigParser()
48+ conf_file = os.getenv('QAKIT_CONFIG', os.path.expanduser('~/.config/qakit.ini'))
49+ parser.read(conf_file)
50+
51+ jenkins = Jenkins(parser.get("jenkins", "server"),
52+ parser.get("jenkins", "user"), parser.get("jenkins", "password"))
53+
54+ builds = jenkins.get_job_info(parser.get("jenkins", "{}_sanity_job".format(snap_name)), depth=2)['builds']
55+
56+ build_run = False
57+ for build in builds:
58+ parameters = list(filter(
59+ lambda action: action.get('parameters', None),
60+ build['actions']))[0]['parameters']
61+ try:
62+ revision_id=list(filter(lambda kv: str(kv['name']) == 'REVISION_ID', parameters))[0]['value']
63+ if int(revision_id) == int(latest_revision_id):
64+ build_run = True
65+ except IndexError:
66+ logging.info("Build does not have a revision id set")
67+
68+ if not build_run:
69+ jenkins.build_job(parser.get("jenkins", "{}_sanity_job".format(snap_name)),
70+ {"REVISION_ID": latest_revision_id})
71+
72+if __name__ == '__main__':
73+
74+ parser = argparse.ArgumentParser(description='Triggers snap sanity tests')
75+ parser.add_argument('--snap_name', help='X-Ubuntu-Series')
76+ parser.add_argument('--series', help='X-Ubuntu-Series')
77+ parser.add_argument('--arch', help='X-Ubuntu-Architecture')
78+ parser.add_argument('--snap_url', help='Url to download the snap')
79+
80+ args = parser.parse_args()
81+
82+ sys.exit(main(args.snap_name, args.series, args.arch, args.snap_url))
83
84=== added file 'qakit/snappy/trigger_sanity.sh'
85--- qakit/snappy/trigger_sanity.sh 1970-01-01 00:00:00 +0000
86+++ qakit/snappy/trigger_sanity.sh 2017-01-26 13:35:32 +0000
87@@ -0,0 +1,17 @@
88+#!/bin/bash
89+
90+virtualenv -p python3 venv
91+. venv/bin/activate
92+
93+
94+proxy=$1
95+
96+if [ "$proxy" ]; then
97+ echo "Using proxy: $proxy to install dependencies"
98+ pip install --proxy $proxy -r requirements.txt
99+else
100+ pip install -r requirements.txt
101+fi
102+
103+
104+venv/bin/python3 trigger.py --snap_name unity8-session --snap_url https://search.apps.ubuntu.com/api/v1/snaps/details/unity8-session?channel=edge --series 16 --arch amd64

Subscribers

People subscribed via source and target branches