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