Merge lp:~canonical-platform-qa/qa-jenkins-jobs/snap-channel-support into lp:qa-jenkins-jobs

Proposed by Richard Huddie
Status: Merged
Approved by: Santiago Baldassin
Approved revision: 236
Merged at revision: 240
Proposed branch: lp:~canonical-platform-qa/qa-jenkins-jobs/snap-channel-support
Merge into: lp:qa-jenkins-jobs
Diff against target: 114 lines (+25/-22)
2 files modified
jobs/ubuntu-system-tests/jobs.yaml (+0/-4)
jobs/ubuntu-system-tests/upgrade_trigger.py (+25/-18)
To merge this branch: bzr merge lp:~canonical-platform-qa/qa-jenkins-jobs/snap-channel-support
Reviewer Review Type Date Requested Status
Santiago Baldassin (community) Approve
Max Brustkern (community) Approve
platform-qa-bot continuous-integration Approve
Review via email: mp+320420@code.launchpad.net

Commit message

Update the app launch tests trigger job to look in beta channel for updates first, followed by edge channel if no revision found in beta.

Description of the change

- Remove the SNAP_CHANNEL parameter, which was fixed to use edge channel
- Check beta channel for updates first, followed by edge channel
- Remove channel name from the dictionary key used to store saved revision as this is now not needed

This should be landed in parallel with: https://code.launchpad.net/~canonical-platform-qa/ubuntu-system-tests/snap-channel-support/+merge/320393

To post a comment you must log in.
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Max Brustkern (nuclearbob) wrote :

Looks good to me. I suppose removing the old data isn't really necessary.

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

Looks good to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'jobs/ubuntu-system-tests/jobs.yaml'
2--- jobs/ubuntu-system-tests/jobs.yaml 2017-03-15 16:33:44 +0000
3+++ jobs/ubuntu-system-tests/jobs.yaml 2017-03-21 14:27:35 +0000
4@@ -196,10 +196,6 @@
5 default: '{deb-triggers}'
6 description: Debs to monitor for updates to trigger new build.
7 - string:
8- name: SNAP_CHANNEL
9- default: 'edge'
10- description: Channel to install snaps from.
11- - string:
12 name: CORE_SERIES
13 default: '16'
14 description: Series of Ubuntu-core used.
15
16=== modified file 'jobs/ubuntu-system-tests/upgrade_trigger.py'
17--- jobs/ubuntu-system-tests/upgrade_trigger.py 2017-02-27 14:19:41 +0000
18+++ jobs/ubuntu-system-tests/upgrade_trigger.py 2017-03-21 14:27:35 +0000
19@@ -30,9 +30,10 @@
20 'https://search.apps.ubuntu.com/api/v1/snaps/details/{n}?channel={c}'
21 )
22 SNAP_DATA_FILE_NAME = 'snap-data.json'
23-KEY_SNAP = '{n}-{a}-{s}-{c}'
24+KEY_SNAP = '{n}-{a}-{s}'
25 KEY_REV = 'revision'
26 JENKINS_DATA = '/etc/jenkins_jobs/jenkins_jobs.ini'
27+CHANNELS = ['beta', 'edge']
28
29 jenkins = None
30
31@@ -52,16 +53,24 @@
32 return json.loads(data) if data else {}
33
34
35-def get_published_snap_revision(name, arch, series, channel):
36- """Return revision of specified published snap."""
37- url = STORE_QUERY_URL.format(n=name, c=channel)
38+def get_published_snap_revision(name, arch, series):
39+ """Return channel and revision of specified published snap.
40+ This will look at the beta channel first and then the edge
41+ channel, using the first revision that is found.
42+ """
43 headers = {'X-Ubuntu-Series': series, 'X-Ubuntu-Architecture': arch}
44- return int(requests.get(url, headers=headers).json()[KEY_REV])
45-
46-
47-def get_current_snap_revision(snap_data, name, arch, series, channel):
48+ for channel in CHANNELS:
49+ url = STORE_QUERY_URL.format(n=name, c=channel)
50+ response = requests.get(url, headers=headers)
51+ if response.ok:
52+ rev = int(response.json()[KEY_REV])
53+ return channel, rev
54+ raise RuntimeError('No published revision found for snap {n}.')
55+
56+
57+def get_current_snap_revision(snap_data, name, arch, series):
58 """Return revision of currently tested snap."""
59- key_snap = KEY_SNAP.format(n=name, a=arch, s=series, c=channel)
60+ key_snap = KEY_SNAP.format(n=name, a=arch, s=series)
61 try:
62 rev = int(snap_data[key_snap][KEY_REV])
63 except (KeyError, TypeError, ValueError):
64@@ -70,9 +79,9 @@
65
66
67 def save_published_snap_revision(work_dir, snap_data, name, arch, series,
68- channel, revision):
69+ revision):
70 """Save the published snap revision for future comparison."""
71- key_snap = KEY_SNAP.format(n=name, a=arch, s=series, c=channel)
72+ key_snap = KEY_SNAP.format(n=name, a=arch, s=series)
73 if key_snap not in snap_data:
74 snap_data[key_snap] = {}
75 snap_data[key_snap][KEY_REV] = revision
76@@ -81,20 +90,19 @@
77 f.write(json.dumps(snap_data))
78
79
80-def run_snap_trigger_check(work_dir, name, arch, series, channel):
81+def run_snap_trigger_check(work_dir, name, arch, series):
82 """Return status indicating if a new revision of snap is published. If a
83 new version is available then update the saved data file with this value.
84 """
85 snap_data = get_snap_data(work_dir)
86- current = get_current_snap_revision(
87- snap_data, name, arch, series, channel)
88- published = get_published_snap_revision(name, arch, series, channel)
89+ current = get_current_snap_revision(snap_data, name, arch, series)
90+ channel, published = get_published_snap_revision(name, arch, series)
91 if published > current:
92 print('New revision detected for: {n} {a} {c} {s} :: previous: {e} :: '
93 'new: {p}.'.format(n=name, a=arch, c=channel, s=series,
94 e=current, p=published))
95 save_published_snap_revision(
96- work_dir, snap_data, name, arch, series, channel, published)
97+ work_dir, snap_data, name, arch, series, published)
98 return True
99 return False
100
101@@ -135,12 +143,11 @@
102 unity8_mode = os.getenv('UNITY8_MODE')
103 device = os.getenv('DEVICE')
104 series = os.getenv('CORE_SERIES')
105- channel = os.getenv('SNAP_CHANNEL')
106 suite = os.getenv('SUITE')
107 snap_triggers = os.getenv('SNAP_TRIGGERS')
108 filters = os.getenv('FILTERS')
109 for snap in snap_triggers.split():
110- if run_snap_trigger_check(work_dir, snap, arch, series, channel):
111+ if run_snap_trigger_check(work_dir, snap, arch, series):
112 # Run a new build of required test job
113 job_name = (
114 'ust-test-{s}-{f}-{r}-{m}-{a}-{d}-unity8-'

Subscribers

People subscribed via source and target branches