Merge lp:~nuclearbob/uci-engine/nfss-check into lp:uci-engine

Proposed by Max Brustkern
Status: Rejected
Rejected by: Max Brustkern
Proposed branch: lp:~nuclearbob/uci-engine/nfss-check
Merge into: lp:uci-engine
Diff against target: 62 lines (+58/-0)
1 file modified
nf-stats-service/nfss_check.py (+58/-0)
To merge this branch: bzr merge lp:~nuclearbob/uci-engine/nfss-check
Reviewer Review Type Date Requested Status
Leo Arias (community) Disapprove
Thomi Richards (community) Needs Fixing
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+239603@code.launchpad.net

Description of the change

This branch adds a script to check if a test in NFSS has had data uploaded recently. It is intended for use with nagios.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:862
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~nuclearbob/uci-engine/nfss-check/+merge/239603/+edit-commit-message

http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/1635/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/1635/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

A few comments below.

Also, please re-order the functions so main() is first, and the things main() calls are listed below it (i.e.- from most generic to most specific).

Also, please coordinate with CI to discuss where this should live - they may want to live somewhere else.

review: Needs Fixing
Revision history for this message
Leo Arias (elopio) wrote :

I took Max's code and Thomi's suggestions and made a new branch here:
https://code.launchpad.net/~canonical-platform-qa/uci-engine/nfss-check/+merge/241322

review: Disapprove
Revision history for this message
Max Brustkern (nuclearbob) wrote :

That looks way better!

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'nf-stats-service/nfss_check.py'
2--- nf-stats-service/nfss_check.py 1970-01-01 00:00:00 +0000
3+++ nf-stats-service/nfss_check.py 2014-10-24 18:34:37 +0000
4@@ -0,0 +1,58 @@
5+#!/usr/bin/env python3
6+
7+# NFSS Check
8+# Copyright 2014 Canonical Ltd.
9+
10+# This program is free software: you can redistribute it and/or modify it
11+# under the terms of the GNU General Public License version 3, as published
12+# by the Free Software Foundation.
13+
14+# This program is distributed in the hope that it will be useful, but
15+# WITHOUT ANY WARRANTY; without even the implied warranties of
16+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17+# PURPOSE. See the GNU General Public License for more details.
18+
19+# You should have received a copy of the GNU General Public License along
20+# with this program. If not, see <http://www.gnu.org/licenses/>.
21+
22+import datetime
23+import json
24+import sys
25+
26+from urllib.request import urlopen
27+
28+NFSS_URL='http://nfss.staging.ubuntu.com/api/v1'
29+
30+
31+def usage():
32+ sys.stderr.write('Usage:\n'
33+ '{} <project> <test> <days>\n'.format(sys.argv[0]))
34+ sys.exit(2)
35+
36+def assert_args():
37+ if len(sys.argv) != 4:
38+ usage()
39+ try:
40+ int(sys.argv[3])
41+ except ValueError:
42+ sys.stderr.write('Error: must supply an int for days\n')
43+ usage()
44+
45+
46+def main():
47+ url = '{}/{}'.format(NFSS_URL, sys.argv[1])
48+ request = urlopen(url)
49+ data = json.loads(request.read().decode('utf-8'))
50+ last_data = data['tests'][sys.argv[2]]['last_data']
51+ date = datetime.datetime.strptime(last_data.replace(':', ''),
52+ '%Y-%m-%dT%H%M%S.%f%z')
53+ delta = datetime.datetime.now(tz=datetime.timezone.utc) - date
54+ if delta.days > int(sys.argv[3]):
55+ sys.stderr.write('Error: last update to {} {} on {}\n'
56+ .format(sys.argv[1], sys.argv[2], last_data))
57+ sys.exit(1)
58+
59+
60+if __name__ == '__main__':
61+ assert_args()
62+ main()

Subscribers

People subscribed via source and target branches