| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import base64 | 5 import base64 |
| 6 import json | 6 import json |
| 7 import mock | 7 import mock |
| 8 import sys | 8 import sys |
| 9 import urlparse | 9 import urlparse |
| 10 import webapp2 | 10 import webapp2 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 'buildbotMasterName': 'bbmn', | 578 'buildbotMasterName': 'bbmn', |
| 579 'buildbotName': 'bbn', | 579 'buildbotName': 'bbn', |
| 580 'buildNumber': 42, | 580 'buildNumber': 42, |
| 581 'logUri': 'uri', | 581 'logUri': 'uri', |
| 582 })) | 582 })) |
| 583 add_histograms.InlineDenseSharedDiagnostics(histograms) | 583 add_histograms.InlineDenseSharedDiagnostics(histograms) |
| 584 self.assertTrue(hist.diagnostics['foo'].has_guid) | 584 self.assertTrue(hist.diagnostics['foo'].has_guid) |
| 585 | 585 |
| 586 def testDeduplicateAndPut_Same(self): | 586 def testDeduplicateAndPut_Same(self): |
| 587 d = { | 587 d = { |
| 588 'guid': 'abc', | 588 'buildNumber': 0, |
| 589 'osName': 'linux', | 589 'buildbotMasterName': '', |
| 590 'type': 'DeviceInfo' | 590 'buildbotName': '', |
| 591 'displayBotName': 'bot', |
| 592 'displayMasterName': 'master', |
| 593 'guid': 'e9c2891d-2b04-413f-8cf4-099827e67626', |
| 594 'logUri': '', |
| 595 'type': 'BuildbotInfo' |
| 591 } | 596 } |
| 592 test_key = utils.TestKey('Chromium/win7/foo') | 597 test_key = utils.TestKey('Chromium/win7/foo') |
| 593 entity = histogram.SparseDiagnostic( | 598 entity = histogram.SparseDiagnostic( |
| 594 data=d, test=test_key, start_revision=1, | 599 data=d, test=test_key, start_revision=1, |
| 595 end_revision=sys.maxint, id='abc') | 600 end_revision=sys.maxint, id='abc') |
| 596 entity.put() | 601 entity.put() |
| 597 d2 = d.copy() | 602 d2 = d.copy() |
| 598 d2['guid'] = 'def' | 603 d2['guid'] = 'def' |
| 599 entity2 = histogram.SparseDiagnostic( | 604 entity2 = histogram.SparseDiagnostic( |
| 600 data=d2, test=test_key, | 605 data=d2, test=test_key, |
| 601 start_revision=2, end_revision=sys.maxint, id='def') | 606 start_revision=2, end_revision=sys.maxint, id='def') |
| 602 add_histograms.DeduplicateAndPut([entity2], test_key, 2) | 607 add_histograms.DeduplicateAndPut([entity2], test_key, 2) |
| 603 sparse = histogram.SparseDiagnostic.query().fetch() | 608 sparse = histogram.SparseDiagnostic.query().fetch() |
| 604 self.assertEqual(1, len(sparse)) | 609 self.assertEqual(1, len(sparse)) |
| 605 | 610 |
| 606 def testDeduplicateAndPut_Different(self): | 611 def testDeduplicateAndPut_Different(self): |
| 607 d = { | 612 d = { |
| 608 'guid': 'abc', | 613 'buildNumber': 0, |
| 609 'osName': 'linux', | 614 'buildbotMasterName': '', |
| 610 'type': 'DeviceInfo' | 615 'buildbotName': '', |
| 616 'displayBotName': 'bot', |
| 617 'displayMasterName': 'master', |
| 618 'guid': 'e9c2891d-2b04-413f-8cf4-099827e67626', |
| 619 'logUri': '', |
| 620 'type': 'BuildbotInfo' |
| 611 } | 621 } |
| 612 test_key = utils.TestKey('Chromium/win7/foo') | 622 test_key = utils.TestKey('Chromium/win7/foo') |
| 613 entity = histogram.SparseDiagnostic( | 623 entity = histogram.SparseDiagnostic( |
| 614 data=d, test=test_key, start_revision=1, | 624 data=d, test=test_key, start_revision=1, |
| 615 end_revision=sys.maxint, id='abc') | 625 end_revision=sys.maxint, id='abc') |
| 616 entity.put() | 626 entity.put() |
| 617 d2 = d.copy() | 627 d2 = d.copy() |
| 618 d2['guid'] = 'def' | 628 d2['guid'] = 'def' |
| 619 d2['osName'] = 'mac' | 629 d2['displayBotName'] = 'mac' |
| 620 entity2 = histogram.SparseDiagnostic( | 630 entity2 = histogram.SparseDiagnostic( |
| 621 data=d2, test=test_key, | 631 data=d2, test=test_key, |
| 622 start_revision=1, end_revision=sys.maxint, id='def') | 632 start_revision=1, end_revision=sys.maxint, id='def') |
| 623 add_histograms.DeduplicateAndPut([entity2], test_key, 2) | 633 add_histograms.DeduplicateAndPut([entity2], test_key, 2) |
| 624 sparse = histogram.SparseDiagnostic.query().fetch() | 634 sparse = histogram.SparseDiagnostic.query().fetch() |
| 625 self.assertEqual(2, len(sparse)) | 635 self.assertEqual(2, len(sparse)) |
| 626 | 636 |
| 627 def testDeduplicateAndPut_New(self): | 637 def testDeduplicateAndPut_New(self): |
| 628 d = { | 638 d = { |
| 629 'guid': 'abc', | 639 'buildNumber': 0, |
| 630 'osName': 'linux', | 640 'buildbotMasterName': '', |
| 631 'type': 'DeviceInfo' | 641 'buildbotName': '', |
| 642 'displayBotName': 'bot', |
| 643 'displayMasterName': 'master', |
| 644 'guid': 'e9c2891d-2b04-413f-8cf4-099827e67626', |
| 645 'logUri': '', |
| 646 'type': 'BuildbotInfo' |
| 632 } | 647 } |
| 633 test_key = utils.TestKey('Chromium/win7/foo') | 648 test_key = utils.TestKey('Chromium/win7/foo') |
| 634 entity = histogram.SparseDiagnostic( | 649 entity = histogram.SparseDiagnostic( |
| 635 data=d, test=test_key, start_revision=1, | 650 data=d, test=test_key, start_revision=1, |
| 636 end_revision=sys.maxint, id='abc') | 651 end_revision=sys.maxint, id='abc') |
| 637 entity.put() | 652 entity.put() |
| 638 add_histograms.DeduplicateAndPut([entity], test_key, 1) | 653 add_histograms.DeduplicateAndPut([entity], test_key, 1) |
| 639 sparse = histogram.SparseDiagnostic.query().fetch() | 654 sparse = histogram.SparseDiagnostic.query().fetch() |
| 640 self.assertEqual(1, len(sparse)) | 655 self.assertEqual(1, len(sparse)) |
| OLD | NEW |