Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/net/buildbot_unittest.py

Issue 2760463002: Add more logging when fetching layout test results. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (C) 2009 Google Inc. All rights reserved. 1 # Copyright (C) 2009 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 11 matching lines...) Expand all
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 import unittest 29 import unittest
30 30
31 from webkitpy.common.net.buildbot import BuildBot, Build, filter_latest_builds 31 from webkitpy.common.net.buildbot import BuildBot, Build, filter_latest_builds
32 from webkitpy.common.system.log_testing import LoggingTestCase
32 33
33 34
34 class BuilderTest(unittest.TestCase): 35 class BuilderTest(LoggingTestCase):
35 36
36 def test_results_url_no_build_number(self): 37 def test_results_url_no_build_number(self):
37 self.assertEqual( 38 self.assertEqual(
38 BuildBot().results_url('Test Builder'), 39 BuildBot().results_url('Test Builder'),
39 'https://storage.googleapis.com/chromium-layout-test-archives/Test_B uilder/results/layout-test-results') 40 'https://storage.googleapis.com/chromium-layout-test-archives/Test_B uilder/results/layout-test-results')
40 41
41 def test_results_url_with_build_number(self): 42 def test_results_url_with_build_number(self):
42 self.assertEqual( 43 self.assertEqual(
43 BuildBot().results_url('Test Builder', 10), 44 BuildBot().results_url('Test Builder', 10),
44 'https://storage.googleapis.com/chromium-layout-test-archives/Test_B uilder/10/layout-test-results') 45 'https://storage.googleapis.com/chromium-layout-test-archives/Test_B uilder/10/layout-test-results')
45 46
46 def test_builder_results_url_base(self): 47 def test_builder_results_url_base(self):
47 self.assertEqual( 48 self.assertEqual(
48 BuildBot().builder_results_url_base('WebKit Mac10.8 (dbg)'), 49 BuildBot().builder_results_url_base('WebKit Mac10.8 (dbg)'),
49 'https://storage.googleapis.com/chromium-layout-test-archives/WebKit _Mac10_8__dbg_') 50 'https://storage.googleapis.com/chromium-layout-test-archives/WebKit _Mac10_8__dbg_')
50 51
51 def test_accumulated_results_url(self): 52 def test_accumulated_results_url(self):
52 self.assertEqual( 53 self.assertEqual(
53 BuildBot().accumulated_results_url_base('WebKit Mac10.8 (dbg)'), 54 BuildBot().accumulated_results_url_base('WebKit Mac10.8 (dbg)'),
54 'https://storage.googleapis.com/chromium-layout-test-archives/WebKit _Mac10_8__dbg_/results/layout-test-results') 55 'https://storage.googleapis.com/chromium-layout-test-archives/WebKit _Mac10_8__dbg_/results/layout-test-results')
55 56
56 def fetch_layout_test_results_with_no_responses(self): 57 def test_fetch_layout_test_results_with_no_results_fetched(self):
57 buildbot = BuildBot() 58 buildbot = BuildBot()
58 buildbot._fetch_file = lambda: None # pylint: disable=protected-access 59
59 self.assertIsNone(buildbot.fetch_layout_test_results(buildbot.results_ur l('Builder'))) 60 def fetch_file(_, filename):
61 return None if filename == 'failing_results.json' else 'contents'
62
63 buildbot.fetch_file = fetch_file
64 results = buildbot.fetch_layout_test_results(buildbot.results_url('B'))
65 self.assertIsNone(results)
66 self.assertLog([
67 'WARNING: Got 404 response from:\n'
68 'https://storage.googleapis.com/chromium-layout-test-archives/B/resu lts/layout-test-results/failing_results.json\n'
69 ])
70
71 def test_fetch_layout_test_results_with_no_last_change_file(self):
72 buildbot = BuildBot()
73
74 def fetch_file(_, filename):
75 return None if filename == 'LAST_CHANGE' else 'contents'
76
77 buildbot.fetch_file = fetch_file
78 results = buildbot.fetch_layout_test_results(buildbot.results_url('B'))
79 self.assertIsNone(results)
80 self.assertLog([
81 'WARNING: Got 404 response from:\n'
82 'https://storage.googleapis.com/chromium-layout-test-archives/B/resu lts/layout-test-results/LAST_CHANGE\n'
83 ])
60 84
61 85
62 class BuildBotHelperFunctionTest(unittest.TestCase): 86 class BuildBotHelperFunctionTest(unittest.TestCase):
63 87
64 def test_filter_latest_jobs_empty(self): 88 def test_filter_latest_jobs_empty(self):
65 self.assertEqual(filter_latest_builds([]), []) 89 self.assertEqual(filter_latest_builds([]), [])
66 90
67 def test_filter_latest_jobs_higher_build_first(self): 91 def test_filter_latest_jobs_higher_build_first(self):
68 self.assertEqual( 92 self.assertEqual(
69 filter_latest_builds([Build('foo', 5), Build('foo', 3), Build('bar', 5)]), 93 filter_latest_builds([Build('foo', 5), Build('foo', 3), Build('bar', 5)]),
70 [Build('bar', 5), Build('foo', 5)]) 94 [Build('bar', 5), Build('foo', 5)])
71 95
72 def test_filter_latest_jobs_higher_build_last(self): 96 def test_filter_latest_jobs_higher_build_last(self):
73 self.assertEqual( 97 self.assertEqual(
74 filter_latest_builds([Build('foo', 3), Build('bar', 5), Build('foo', 5)]), 98 filter_latest_builds([Build('foo', 3), Build('bar', 5), Build('foo', 5)]),
75 [Build('bar', 5), Build('foo', 5)]) 99 [Build('bar', 5), Build('foo', 5)])
76 100
77 def test_filter_latest_jobs_no_build_number(self): 101 def test_filter_latest_jobs_no_build_number(self):
78 self.assertEqual( 102 self.assertEqual(
79 filter_latest_builds([Build('foo', 3), Build('bar'), Build('bar')]), 103 filter_latest_builds([Build('foo', 3), Build('bar'), Build('bar')]),
80 [Build('bar'), Build('foo', 3)]) 104 [Build('bar'), Build('foo', 3)])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698