Merge lp:~jml/libdep-service/update-e2e-check into lp:libdep-service

Proposed by Jonathan Lange
Status: Merged
Approved by: James Westby
Approved revision: 68
Merged at revision: 66
Proposed branch: lp:~jml/libdep-service/update-e2e-check
Merge into: lp:libdep-service
Diff against target: 49 lines (+16/-4)
1 file modified
bin/end-to-end-check (+16/-4)
To merge this branch: bzr merge lp:~jml/libdep-service/update-e2e-check
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+130806@code.launchpad.net

Commit message

Make e2e check more flexible

Description of the change

Uses a matcher for the e2e check so that we aren't constantly baffled
by slight changes in returned data.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/end-to-end-check'
--- bin/end-to-end-check 2012-09-14 14:34:46 +0000
+++ bin/end-to-end-check 2012-10-22 12:48:23 +0000
@@ -2,13 +2,24 @@
22
3import argparse3import argparse
4import json4import json
5from operator import itemgetter
5import time6import time
6import urllib27import urllib2
7import sys8import sys
89
10from testtools.matchers import (
11 AfterPreprocessing,
12 Contains,
13 KeysEqual,
14 MatchesAll,
15 )
16
917
10QUERY = 'libs=libc.so.6&libs=notalibrary'18QUERY = 'libs=libc.so.6&libs=notalibrary'
11RESULT = {"libc.so.6": ["libc6", "libc6 (>= 2.13)", "libc6-amd64", "libc6-i386"]}19# Using only testtools 0.9.14 matchers, as that's what's on emim.
20RESULT = MatchesAll(
21 KeysEqual('libc.so.6'),
22 AfterPreprocessing(itemgetter('libc.so.6'), Contains('libc6')))
1223
1324
14def make_arg_parser():25def make_arg_parser():
@@ -39,15 +50,16 @@
39 return json.loads(result)50 return json.loads(result)
4051
4152
42def check_query_results(warn_duration, error_duration, expected_result,53def check_query_results(warn_duration, error_duration, result_matcher,
43 function, *args, **kwargs):54 function, *args, **kwargs):
44 start_time = time.time()55 start_time = time.time()
45 result = function(*args, **kwargs)56 result = function(*args, **kwargs)
46 duration = time.time() - start_time57 duration = time.time() - start_time
58 mismatch = result_matcher.match(result)
47 # XXX: If we could guarantee matchers gave a one-line output, we would59 # XXX: If we could guarantee matchers gave a one-line output, we would
48 # probably use matchers for this rather than assuming simple equality.60 # probably use matchers for this rather than assuming simple equality.
49 if result != expected_result:61 if mismatch:
50 return 2, "ERROR: Got %r, expected %r" % (result, expected_result)62 return 2, "ERROR: %s" % (mismatch.describe().replace('\n', '; '),)
51 elif duration > error_duration:63 elif duration > error_duration:
52 return 2, "ERROR: Check took %0.3fs. Must be less than %0.3fs" % (64 return 2, "ERROR: Check took %0.3fs. Must be less than %0.3fs" % (
53 duration, error_duration)65 duration, error_duration)

Subscribers

People subscribed via source and target branches