| 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 datetime | 5 import datetime |
| 6 import json | 6 import json |
| 7 import math | 7 import math |
| 8 import subprocess | 8 import subprocess |
| 9 import time | 9 import time |
| 10 | 10 |
| 11 import common | 11 import common |
| 12 from common import TestDriver | 12 from common import TestDriver |
| 13 from common import IntegrationTest | 13 from common import IntegrationTest |
| 14 from decorators import NotAndroid | 14 from decorators import NotAndroid |
| 15 from decorators import Slow |
| 15 | 16 |
| 16 # The maximum number of data points that will be saved. | 17 # The maximum number of data points that will be saved. |
| 17 MAX_DATA_POINTS = 365 | 18 MAX_DATA_POINTS = 365 |
| 18 | 19 |
| 19 # The number of days in the past to compute the average of for regression | 20 # The number of days in the past to compute the average of for regression |
| 20 # alerting. | 21 # alerting. |
| 21 ALERT_WINDOW = 31 | 22 ALERT_WINDOW = 31 |
| 22 | 23 |
| 23 # The amount of tolerable difference a single data point can be away from the | 24 # The amount of tolerable difference a single data point can be away from the |
| 24 # average without alerting. This is a percentage from 0.0 to 1.0 inclusive. | 25 # average without alerting. This is a percentage from 0.0 to 1.0 inclusive. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 75 } |
| 75 where keys are the content type with its compression value. | 76 where keys are the content type with its compression value. |
| 76 | 77 |
| 77 Due to the complexity of several methods in this class, a number of local | 78 Due to the complexity of several methods in this class, a number of local |
| 78 unit tests can be found at the bottom of this file. | 79 unit tests can be found at the bottom of this file. |
| 79 | 80 |
| 80 Please note that while this test uses the IntegrationTest framework, it is | 81 Please note that while this test uses the IntegrationTest framework, it is |
| 81 classified as a regression test. | 82 classified as a regression test. |
| 82 """ | 83 """ |
| 83 | 84 |
| 85 @Slow |
| 84 @NotAndroid | 86 @NotAndroid |
| 85 def testCompression(self): | 87 def testCompression(self): |
| 86 """This function is the main test function for regression compression | 88 """This function is the main test function for regression compression |
| 87 checking and facilitates the test with all of the helper functions' | 89 checking and facilitates the test with all of the helper functions' |
| 88 behavior. | 90 behavior. |
| 89 """ | 91 """ |
| 90 compression_average = self.getCurrentCompressionMetricsWithRetry() | 92 compression_average = self.getCurrentCompressionMetricsWithRetry() |
| 91 self.fetchFromGoogleStorage() | 93 self.fetchFromGoogleStorage() |
| 92 data = {} | 94 data = {} |
| 93 with open(DATA_FILE, 'r') as data_fp: | 95 with open(DATA_FILE, 'r') as data_fp: |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 for i in range(ALERT_WINDOW): | 373 for i in range(ALERT_WINDOW): |
| 372 date_obj = start_date + datetime.timedelta(days=i) | 374 date_obj = start_date + datetime.timedelta(days=i) |
| 373 datestamp = date_obj.strftime(DATE_FORMAT) | 375 datestamp = date_obj.strftime(DATE_FORMAT) |
| 374 data[datestamp] = {'mp4': 0.9} | 376 data[datestamp] = {'mp4': 0.9} |
| 375 self.assertRaises(Exception, self.checkForRegression, data, {'mp4': | 377 self.assertRaises(Exception, self.checkForRegression, data, {'mp4': |
| 376 (0.9 - THRESHOLD - 0.01)}) | 378 (0.9 - THRESHOLD - 0.01)}) |
| 377 | 379 |
| 378 | 380 |
| 379 if __name__ == '__main__': | 381 if __name__ == '__main__': |
| 380 IntegrationTest.RunAllTests() | 382 IntegrationTest.RunAllTests() |
| OLD | NEW |