| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 re | 7 import re |
| 8 import webapp2 | 8 import webapp2 |
| 9 import webtest | 9 import webtest |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 'builder1': { | 47 'builder1': { |
| 48 'mastername': 'tryserver1', | 48 'mastername': 'tryserver1', |
| 49 'buildername': 'trybot1', | 49 'buildername': 'trybot1', |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 _MOCK_TRY_JOB_SETTINGS = { | 54 _MOCK_TRY_JOB_SETTINGS = { |
| 55 'server_query_interval_seconds': 60, | 55 'server_query_interval_seconds': 60, |
| 56 'job_timeout_hours': 5, | 56 'job_timeout_hours': 5, |
| 57 'allowed_response_error_times': 1 | 57 'allowed_response_error_times': 1, |
| 58 'max_seconds_look_back_for_group': 1 |
| 58 } | 59 } |
| 59 | 60 |
| 60 _MOCK_SWARMING_SETTINGS = { | 61 _MOCK_SWARMING_SETTINGS = { |
| 61 'server_host': 'chromium-swarm.appspot.com', | 62 'server_host': 'chromium-swarm.appspot.com', |
| 62 'default_request_priority': 150, | 63 'default_request_priority': 150, |
| 63 'request_expiration_hours': 20, | 64 'request_expiration_hours': 20, |
| 64 'server_query_interval_seconds': 60, | 65 'server_query_interval_seconds': 60, |
| 65 'task_timeout_hours': 23, | 66 'task_timeout_hours': 23, |
| 66 'isolated_server': 'https://isolateserver.appspot.com', | 67 'isolated_server': 'https://isolateserver.appspot.com', |
| 67 'isolated_storage_url': 'isolateserver.storage.googleapis.com', | 68 'isolated_storage_url': 'isolateserver.storage.googleapis.com', |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 self.assertFalse(config._ValidateTrybotMapping({'a': ['b']})) | 456 self.assertFalse(config._ValidateTrybotMapping({'a': ['b']})) |
| 456 self.assertFalse(config._ValidateTrybotMapping({'a': {'b': ['1']}})) | 457 self.assertFalse(config._ValidateTrybotMapping({'a': {'b': ['1']}})) |
| 457 self.assertFalse(config._ValidateTrybotMapping({'a': {'b': {}}})) | 458 self.assertFalse(config._ValidateTrybotMapping({'a': {'b': {}}})) |
| 458 | 459 |
| 459 def testValidateTryJobSettings(self): | 460 def testValidateTryJobSettings(self): |
| 460 self.assertFalse(config._ValidateTryJobSettings([])) | 461 self.assertFalse(config._ValidateTryJobSettings([])) |
| 461 self.assertFalse(config._ValidateTryJobSettings({})) | 462 self.assertFalse(config._ValidateTryJobSettings({})) |
| 462 self.assertFalse(config._ValidateTryJobSettings({ | 463 self.assertFalse(config._ValidateTryJobSettings({ |
| 463 'server_query_interval_seconds': '1', # Should be an int. | 464 'server_query_interval_seconds': '1', # Should be an int. |
| 464 'job_timeout_hours': 1, | 465 'job_timeout_hours': 1, |
| 465 'allowed_response_error_times': 1 | 466 'allowed_response_error_times': 1, |
| 467 'max_seconds_look_back_for_group': 1 |
| 466 })) | 468 })) |
| 467 self.assertFalse(config._ValidateTryJobSettings({ | 469 self.assertFalse(config._ValidateTryJobSettings({ |
| 468 'server_query_interval_seconds': 1, | 470 'server_query_interval_seconds': 1, |
| 469 'job_timeout_hours': '1', # Should be an int. | 471 'job_timeout_hours': '1', # Should be an int. |
| 470 'allowed_response_error_times': 1 | 472 'allowed_response_error_times': 1, |
| 473 'max_seconds_look_back_for_group': 1 |
| 471 })) | 474 })) |
| 472 self.assertFalse(config._ValidateTryJobSettings({ | 475 self.assertFalse(config._ValidateTryJobSettings({ |
| 473 'server_query_interval_seconds': 1, | 476 'server_query_interval_seconds': 1, |
| 474 'job_timeout_hours': 1, | 477 'job_timeout_hours': 1, |
| 475 'allowed_response_error_times': '1', # Should be an int. | 478 'allowed_response_error_times': '1', # Should be an int. |
| 479 'max_seconds_look_back_for_group': 1 |
| 476 })) | 480 })) |
| 477 self.assertTrue(config._ValidateTryJobSettings({ | 481 self.assertFalse(config._ValidateTryJobSettings({ |
| 478 'server_query_interval_seconds': 1, | 482 'server_query_interval_seconds': 1, |
| 479 'job_timeout_hours': 1, | 483 'job_timeout_hours': 1, |
| 480 'allowed_response_error_times': 1 | 484 'allowed_response_error_times': 1, |
| 485 'max_seconds_look_back_for_group': 'a' # Should be an int. |
| 481 })) | 486 })) |
| 482 self.assertTrue(config._ValidateSwarmingSettings(_MOCK_SWARMING_SETTINGS)) | 487 self.assertTrue(config._ValidateTryJobSettings(_MOCK_TRY_JOB_SETTINGS)) |
| 483 | 488 |
| 484 def testValidateSwarmingSettings(self): | 489 def testValidateSwarmingSettings(self): |
| 485 self.assertFalse(config._ValidateSwarmingSettings([])) | 490 self.assertFalse(config._ValidateSwarmingSettings([])) |
| 486 self.assertFalse(config._ValidateSwarmingSettings({})) | 491 self.assertFalse(config._ValidateSwarmingSettings({})) |
| 487 self.assertFalse(config._ValidateSwarmingSettings({ | 492 self.assertFalse(config._ValidateSwarmingSettings({ |
| 488 'server_host': ['chromium-swarm.appspot.com'], # Should be a string. | 493 'server_host': ['chromium-swarm.appspot.com'], # Should be a string. |
| 489 'default_request_priority': 150, | 494 'default_request_priority': 150, |
| 490 'request_expiration_hours': 20, | 495 'request_expiration_hours': 20, |
| 491 'server_query_interval_seconds': 60, | 496 'server_query_interval_seconds': 60, |
| 492 'task_timeout_hours': 23, | 497 'task_timeout_hours': 23, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 | 695 |
| 691 self.assertEquals(expected_response, response.json_body) | 696 self.assertEquals(expected_response, response.json_body) |
| 692 | 697 |
| 693 def testValidateActionSettings(self): | 698 def testValidateActionSettings(self): |
| 694 self.assertFalse(config._ValidateActionSettings({})) | 699 self.assertFalse(config._ValidateActionSettings({})) |
| 695 self.assertTrue(config._ValidateActionSettings( | 700 self.assertTrue(config._ValidateActionSettings( |
| 696 { | 701 { |
| 697 'cr_notification_build_threshold': 2, | 702 'cr_notification_build_threshold': 2, |
| 698 'cr_notification_latency_limit_minutes': 1000, | 703 'cr_notification_latency_limit_minutes': 1000, |
| 699 })) | 704 })) |
| OLD | NEW |