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

Side by Side Diff: appengine/findit/handlers/test/config_test.py

Issue 2272953002: [Findit] Moving check flake parameters to config (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Updating swarming settings config example Created 4 years, 3 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
« no previous file with comments | « appengine/findit/handlers/config.py ('k') | appengine/findit/model/wf_config.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 _MOCK_SWARMING_SETTINGS = { 61 _MOCK_SWARMING_SETTINGS = {
62 'server_host': 'chromium-swarm.appspot.com', 62 'server_host': 'chromium-swarm.appspot.com',
63 'default_request_priority': 150, 63 'default_request_priority': 150,
64 'request_expiration_hours': 20, 64 'request_expiration_hours': 20,
65 'server_query_interval_seconds': 60, 65 'server_query_interval_seconds': 60,
66 'task_timeout_hours': 23, 66 'task_timeout_hours': 23,
67 'isolated_server': 'https://isolateserver.appspot.com', 67 'isolated_server': 'https://isolateserver.appspot.com',
68 'isolated_storage_url': 'isolateserver.storage.googleapis.com', 68 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
69 'iterations_to_rerun': 10 69 'iterations_to_rerun': 10,
70 'get_swarming_task_id_timeout_seconds': 5 * 60, # 5 minutes.
71 'get_swarming_task_id_wait_seconds': 10
70 } 72 }
71 73
72 74
73 _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS = { 75 _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS = {
74 'download_interval_seconds': 10, 76 'download_interval_seconds': 10,
75 'memcache_master_download_expiration_seconds': 3600, 77 'memcache_master_download_expiration_seconds': 3600,
76 'use_chrome_build_extract': True 78 'use_chrome_build_extract': True
77 } 79 }
78 80
79 _MOCK_ACTION_SETTINGS = { 81 _MOCK_ACTION_SETTINGS = {
80 'cr_notification_build_threshold': 2, 82 'cr_notification_build_threshold': 2,
81 'cr_notification_latency_limit_minutes': 1000, 83 'cr_notification_latency_limit_minutes': 1000,
82 } 84 }
83 85
86 _MOCK_CHECK_FLAKE_SETTINGS = {
87 'lower_flake_threshold': 0.02,
88 'upper_flake_threshold': 0.98,
89 'max_flake_in_a_row': 4,
90 'max_stable_in_a_row': 4,
91 'iterations_to_rerun': 100
92 }
93
84 _MOCK_VERSION_NUMBER = 12 94 _MOCK_VERSION_NUMBER = 12
85 95
86 96
87 class ConfigTest(testing.AppengineTestCase): 97 class ConfigTest(testing.AppengineTestCase):
88 app_module = webapp2.WSGIApplication([ 98 app_module = webapp2.WSGIApplication([
89 ('/config', config.Configuration), 99 ('/config', config.Configuration),
90 ], debug=True) 100 ], debug=True)
91 101
92 def testGetConfigurationSettings(self): 102 def testGetConfigurationSettings(self):
93 config_data = { 103 config_data = {
94 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES, 104 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES,
95 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS, 105 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS,
96 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 106 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
97 'swarming_settings': _MOCK_SWARMING_SETTINGS, 107 'swarming_settings': _MOCK_SWARMING_SETTINGS,
98 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 108 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
99 'action_settings': _MOCK_ACTION_SETTINGS, 109 'action_settings': _MOCK_ACTION_SETTINGS,
110 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS
100 } 111 }
101 112
102 self.mock_current_user(user_email='test@chromium.org', is_admin=True) 113 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
103 114
104 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True, 115 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True,
105 **config_data) 116 **config_data)
106 117
107 response = self.test_app.get('/config', params={'format': 'json'}) 118 response = self.test_app.get('/config', params={'format': 'json'})
108 self.assertEquals(response.status_int, 200) 119 self.assertEquals(response.status_int, 200)
109 120
110 expected_response = { 121 expected_response = {
111 'masters': _MOCK_STEPS_FOR_MASTERS_RULES, 122 'masters': _MOCK_STEPS_FOR_MASTERS_RULES,
112 'builders': _MOCK_BUILDERS_TO_TRYBOTS, 123 'builders': _MOCK_BUILDERS_TO_TRYBOTS,
113 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 124 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
114 'swarming_settings': _MOCK_SWARMING_SETTINGS, 125 'swarming_settings': _MOCK_SWARMING_SETTINGS,
115 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 126 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
116 'action_settings': _MOCK_ACTION_SETTINGS, 127 'action_settings': _MOCK_ACTION_SETTINGS,
128 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS,
117 'version': 1, 129 'version': 1,
118 'latest_version': 1, 130 'latest_version': 1,
119 'updated_by': 'test', 131 'updated_by': 'test',
120 'updated_ts': response.json_body.get('updated_ts') 132 'updated_ts': response.json_body.get('updated_ts')
121 } 133 }
122 134
123 self.assertEquals(expected_response, response.json_body) 135 self.assertEquals(expected_response, response.json_body)
124 136
125 def testGetVersionOfConfigurationSettings(self): 137 def testGetVersionOfConfigurationSettings(self):
126 self.mock_current_user(user_email='test@chromium.org', is_admin=True) 138 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
127 139
128 config_data = { 140 config_data = {
129 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES, 141 'steps_for_masters_rules': _MOCK_STEPS_FOR_MASTERS_RULES,
130 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS, 142 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS,
131 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 143 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
132 'swarming_settings': _MOCK_SWARMING_SETTINGS, 144 'swarming_settings': _MOCK_SWARMING_SETTINGS,
133 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 145 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
134 'action_settings': _MOCK_ACTION_SETTINGS, 146 'action_settings': _MOCK_ACTION_SETTINGS,
147 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS
135 } 148 }
136 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True, 149 wf_config.FinditConfig.Get().Update(users.GetCurrentUser(), True,
137 **config_data) 150 **config_data)
138 151
139 response = self.test_app.get( 152 response = self.test_app.get(
140 '/config', params={'version': 1, 'format': 'json'}) 153 '/config', params={'version': 1, 'format': 'json'})
141 self.assertEquals(response.status_int, 200) 154 self.assertEquals(response.status_int, 200)
142 155
143 expected_response = { 156 expected_response = {
144 'masters': _MOCK_STEPS_FOR_MASTERS_RULES, 157 'masters': _MOCK_STEPS_FOR_MASTERS_RULES,
145 'builders': _MOCK_BUILDERS_TO_TRYBOTS, 158 'builders': _MOCK_BUILDERS_TO_TRYBOTS,
146 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 159 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
147 'swarming_settings': _MOCK_SWARMING_SETTINGS, 160 'swarming_settings': _MOCK_SWARMING_SETTINGS,
148 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 161 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
149 'action_settings': _MOCK_ACTION_SETTINGS, 162 'action_settings': _MOCK_ACTION_SETTINGS,
163 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS,
150 'version': 1, 164 'version': 1,
151 'latest_version': 1, 165 'latest_version': 1,
152 'updated_by': 'test', 166 'updated_by': 'test',
153 'updated_ts': response.json_body.get('updated_ts') 167 'updated_ts': response.json_body.get('updated_ts')
154 } 168 }
155 169
156 self.assertEquals(expected_response, response.json_body) 170 self.assertEquals(expected_response, response.json_body)
157 171
158 def testGetOutOfBoundsVersionOfConfigurationSettings(self): 172 def testGetOutOfBoundsVersionOfConfigurationSettings(self):
159 config_data = { 173 config_data = {
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 self.assertFalse(config._ValidateSwarmingSettings([])) 504 self.assertFalse(config._ValidateSwarmingSettings([]))
491 self.assertFalse(config._ValidateSwarmingSettings({})) 505 self.assertFalse(config._ValidateSwarmingSettings({}))
492 self.assertFalse(config._ValidateSwarmingSettings({ 506 self.assertFalse(config._ValidateSwarmingSettings({
493 'server_host': ['chromium-swarm.appspot.com'], # Should be a string. 507 'server_host': ['chromium-swarm.appspot.com'], # Should be a string.
494 'default_request_priority': 150, 508 'default_request_priority': 150,
495 'request_expiration_hours': 20, 509 'request_expiration_hours': 20,
496 'server_query_interval_seconds': 60, 510 'server_query_interval_seconds': 60,
497 'task_timeout_hours': 23, 511 'task_timeout_hours': 23,
498 'isolated_server': 'https://isolateserver.appspot.com', 512 'isolated_server': 'https://isolateserver.appspot.com',
499 'isolated_storage_url': 'isolateserver.storage.googleapis.com', 513 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
500 'iterations_to_rerun': 10 514 'iterations_to_rerun': 10,
515 'get_swarming_task_id_timeout_seconds': 300,
516 'get_swarming_task_id_wait_seconds': 10
501 })) 517 }))
502 self.assertFalse(config._ValidateSwarmingSettings({ 518 self.assertFalse(config._ValidateSwarmingSettings({
503 'server_host': 'chromium-swarm.appspot.com', 519 'server_host': 'chromium-swarm.appspot.com',
504 'default_request_priority': '150', # Should be an int. 520 'default_request_priority': '150', # Should be an int.
505 'request_expiration_hours': 20, 521 'request_expiration_hours': 20,
506 'server_query_interval_seconds': 60, 522 'server_query_interval_seconds': 60,
507 'task_timeout_hours': 23, 523 'task_timeout_hours': 23,
508 'isolated_server': 'https://isolateserver.appspot.com', 524 'isolated_server': 'https://isolateserver.appspot.com',
509 'isolated_storage_url': 'isolateserver.storage.googleapis.com', 525 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
510 'iterations_to_rerun': 10 526 'iterations_to_rerun': 10,
527 'get_swarming_task_id_timeout_seconds': 300,
528 'get_swarming_task_id_wait_seconds': 10
511 })) 529 }))
512 self.assertFalse(config._ValidateSwarmingSettings({ 530 self.assertFalse(config._ValidateSwarmingSettings({
513 'server_host': 'chromium-swarm.appspot.com', 531 'server_host': 'chromium-swarm.appspot.com',
514 'default_request_priority': 150, 532 'default_request_priority': 150,
515 'request_expiration_hours': {}, # Should be an int. 533 'request_expiration_hours': {}, # Should be an int.
516 'server_query_interval_seconds': 60, 534 'server_query_interval_seconds': 60,
517 'task_timeout_hours': 23, 535 'task_timeout_hours': 23,
518 'isolated_server': 'https://isolateserver.appspot.com', 536 'isolated_server': 'https://isolateserver.appspot.com',
519 'isolated_storage_url': 'isolateserver.storage.googleapis.com', 537 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
520 'iterations_to_rerun': 10 538 'iterations_to_rerun': 10,
539 'get_swarming_task_id_timeout_seconds': 300,
540 'get_swarming_task_id_wait_seconds': 10
521 })) 541 }))
522 self.assertFalse(config._ValidateSwarmingSettings({ 542 self.assertFalse(config._ValidateSwarmingSettings({
523 'server_host': 'chromium-swarm.appspot.com', 543 'server_host': 'chromium-swarm.appspot.com',
524 'default_request_priority': 150, 544 'default_request_priority': 150,
525 'request_expiration_hours': 20, 545 'request_expiration_hours': 20,
526 'server_query_interval_seconds': [], # Should be an int. 546 'server_query_interval_seconds': [], # Should be an int.
527 'task_timeout_hours': 23, 547 'task_timeout_hours': 23,
528 'isolated_server': 'https://isolateserver.appspot.com', 548 'isolated_server': 'https://isolateserver.appspot.com',
529 'isolated_storage_url': 'isolateserver.storage.googleapis.com', 549 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
530 'iterations_to_rerun': 10 550 'iterations_to_rerun': 10,
551 'get_swarming_task_id_timeout_seconds': 300,
552 'get_swarming_task_id_wait_seconds': 10
531 })) 553 }))
532 self.assertFalse(config._ValidateSwarmingSettings({ 554 self.assertFalse(config._ValidateSwarmingSettings({
533 'server_host': 'chromium-swarm.appspot.com', 555 'server_host': 'chromium-swarm.appspot.com',
534 'default_request_priority': 150, 556 'default_request_priority': 150,
535 'request_expiration_hours': 20, 557 'request_expiration_hours': 20,
536 'server_query_interval_seconds': 60, 558 'server_query_interval_seconds': 60,
537 'task_timeout_hours': None, # should be an int. 559 'task_timeout_hours': None, # should be an int.
538 'isolated_server': 'https://isolateserver.appspot.com', 560 'isolated_server': 'https://isolateserver.appspot.com',
539 'isolated_storage_url': 'isolateserver.storage.googleapis.com', 561 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
540 'iterations_to_rerun': 10 562 'iterations_to_rerun': 10,
563 'get_swarming_task_id_timeout_seconds': 300,
564 'get_swarming_task_id_wait_seconds': 10
541 })) 565 }))
542 self.assertFalse(config._ValidateSwarmingSettings({ 566 self.assertFalse(config._ValidateSwarmingSettings({
543 'server_host': 'chromium-swarm.appspot.com', 567 'server_host': 'chromium-swarm.appspot.com',
544 'default_request_priority': 150, 568 'default_request_priority': 150,
545 'request_expiration_hours': 20, 569 'request_expiration_hours': 20,
546 'server_query_interval_seconds': 60, 570 'server_query_interval_seconds': 60,
547 'task_timeout_hours': 23, 571 'task_timeout_hours': 23,
548 'isolated_server': 1, # Should be a string. 572 'isolated_server': 1, # Should be a string.
549 'isolated_storage_url': 'isolateserver.storage.googleapis.com', 573 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
550 'iterations_to_rerun': 10 574 'iterations_to_rerun': 10,
575 'get_swarming_task_id_timeout_seconds': 300,
576 'get_swarming_task_id_wait_seconds': 10
551 })) 577 }))
552 self.assertFalse(config._ValidateSwarmingSettings({ 578 self.assertFalse(config._ValidateSwarmingSettings({
553 'server_host': 'chromium-swarm.appspot.com', 579 'server_host': 'chromium-swarm.appspot.com',
554 'default_request_priority': 150, 580 'default_request_priority': 150,
555 'request_expiration_hours': 20, 581 'request_expiration_hours': 20,
556 'server_query_interval_seconds': 60, 582 'server_query_interval_seconds': 60,
557 'task_timeout_hours': 23, 583 'task_timeout_hours': 23,
558 'isolated_server': 'https://isolateserver.appspot.com', 584 'isolated_server': 'https://isolateserver.appspot.com',
559 'isolated_storage_url': 3.2, # Should be a string. 585 'isolated_storage_url': 3.2, # Should be a string.
560 'iterations_to_rerun': 10 586 'iterations_to_rerun': 10,
587 'get_swarming_task_id_timeout_seconds': 300,
588 'get_swarming_task_id_wait_seconds': 10
561 })) 589 }))
562 self.assertFalse(config._ValidateSwarmingSettings({ 590 self.assertFalse(config._ValidateSwarmingSettings({
563 'server_host': 'chromium-swarm.appspot.com', 591 'server_host': 'chromium-swarm.appspot.com',
564 'default_request_priority': 150, 592 'default_request_priority': 150,
565 'request_expiration_hours': 20, 593 'request_expiration_hours': 20,
566 'server_query_interval_seconds': 60, 594 'server_query_interval_seconds': 60,
567 'task_timeout_hours': 23, 595 'task_timeout_hours': 23,
568 'isolated_server': 'https://isolateserver.appspot.com', 596 'isolated_server': 'https://isolateserver.appspot.com',
569 'isolated_storage_url': 'isolateserver.storage.googleapis.com', 597 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
570 'iterations_to_rerun': 1.0 # Should be an int. 598 'iterations_to_rerun': 1.0, # Should be an int.
599 'get_swarming_task_id_timeout_seconds': 300,
600 'get_swarming_task_id_wait_seconds': 10
601 }))
602 self.assertFalse(config._ValidateSwarmingSettings({
603 'server_host': 'chromium-swarm.appspot.com',
604 'default_request_priority': 150,
605 'request_expiration_hours': 20,
606 'server_query_interval_seconds': 60,
607 'task_timeout_hours': 23,
608 'isolated_server': 'https://isolateserver.appspot.com',
609 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
610 'iterations_to_rerun': 1,
611 'get_swarming_task_id_timeout_seconds': '300', # Should be an int.
612 'get_swarming_task_id_wait_seconds': 10
613 }))
614 self.assertFalse(config._ValidateSwarmingSettings({
615 'server_host': 'chromium-swarm.appspot.com',
616 'default_request_priority': 150,
617 'request_expiration_hours': 20,
618 'server_query_interval_seconds': 60,
619 'task_timeout_hours': 23,
620 'isolated_server': 'https://isolateserver.appspot.com',
621 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
622 'iterations_to_rerun': 1,
623 'get_swarming_task_id_timeout_seconds': 300,
624 'get_swarming_task_id_wait_seconds': [] # Should be an int.
571 })) 625 }))
572 self.assertTrue(config._ValidateSwarmingSettings({ 626 self.assertTrue(config._ValidateSwarmingSettings({
573 'server_host': 'chromium-swarm.appspot.com', 627 'server_host': 'chromium-swarm.appspot.com',
574 'default_request_priority': 150, 628 'default_request_priority': 150,
575 'request_expiration_hours': 20, 629 'request_expiration_hours': 20,
576 'server_query_interval_seconds': 60, 630 'server_query_interval_seconds': 60,
577 'task_timeout_hours': 23, 631 'task_timeout_hours': 23,
578 'isolated_server': 'https://isolateserver.appspot.com', 632 'isolated_server': 'https://isolateserver.appspot.com',
579 'isolated_storage_url': 'isolateserver.storage.googleapis.com', 633 'isolated_storage_url': 'isolateserver.storage.googleapis.com',
580 'iterations_to_rerun': 10 634 'iterations_to_rerun': 10,
635 'get_swarming_task_id_timeout_seconds': 300,
636 'get_swarming_task_id_wait_seconds': 10
581 })) 637 }))
582 638
583 def testValidateDownloadBuildDataSettings(self): 639 def testValidateDownloadBuildDataSettings(self):
584 self.assertFalse(config._ValidateDownloadBuildDataSettings({})) 640 self.assertFalse(config._ValidateDownloadBuildDataSettings({}))
585 self.assertFalse(config._ValidateDownloadBuildDataSettings({ 641 self.assertFalse(config._ValidateDownloadBuildDataSettings({
586 'download_interval_seconds': {}, # Should be an int. 642 'download_interval_seconds': {}, # Should be an int.
587 'memcache_master_download_expiration_seconds': 10, 643 'memcache_master_download_expiration_seconds': 10,
588 'use_chrome_build_extract': True 644 'use_chrome_build_extract': True
589 })) 645 }))
590 self.assertFalse(config._ValidateDownloadBuildDataSettings({ 646 self.assertFalse(config._ValidateDownloadBuildDataSettings({
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 }, 708 },
653 'global': { 709 'global': {
654 'unsupported_steps': ['1'] 710 'unsupported_steps': ['1']
655 } 711 }
656 }, 712 },
657 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS, 713 'builders_to_trybots': _MOCK_BUILDERS_TO_TRYBOTS,
658 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 714 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
659 'swarming_settings': _MOCK_SWARMING_SETTINGS, 715 'swarming_settings': _MOCK_SWARMING_SETTINGS,
660 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 716 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
661 'action_settings': _MOCK_ACTION_SETTINGS, 717 'action_settings': _MOCK_ACTION_SETTINGS,
718 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS
662 }) 719 })
663 } 720 }
664 721
665 response = self.test_app.post('/config', params=params) 722 response = self.test_app.post('/config', params=params)
666 723
667 expected_response = { 724 expected_response = {
668 'masters': { 725 'masters': {
669 'supported_masters': { 726 'supported_masters': {
670 'a': { 727 'a': {
671 }, 728 },
672 'b': { 729 'b': {
673 'supported_steps': ['1'], 730 'supported_steps': ['1'],
674 'unsupported_steps': ['2', '3', '4'], 731 'unsupported_steps': ['2', '3', '4'],
675 }, 732 },
676 'c': { 733 'c': {
677 'supported_steps': ['5'], 734 'supported_steps': ['5'],
678 'check_global': False 735 'check_global': False
679 } 736 }
680 }, 737 },
681 'global': { 738 'global': {
682 'unsupported_steps': ['1'] 739 'unsupported_steps': ['1']
683 } 740 }
684 }, 741 },
685 'builders': _MOCK_BUILDERS_TO_TRYBOTS, 742 'builders': _MOCK_BUILDERS_TO_TRYBOTS,
686 'try_job_settings': _MOCK_TRY_JOB_SETTINGS, 743 'try_job_settings': _MOCK_TRY_JOB_SETTINGS,
687 'swarming_settings': _MOCK_SWARMING_SETTINGS, 744 'swarming_settings': _MOCK_SWARMING_SETTINGS,
688 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS, 745 'download_build_data_settings': _MOCK_DOWNLOAD_BUILD_DATA_SETTINGS,
689 'action_settings': _MOCK_ACTION_SETTINGS, 746 'action_settings': _MOCK_ACTION_SETTINGS,
747 'check_flake_settings': _MOCK_CHECK_FLAKE_SETTINGS,
690 'version': 1, 748 'version': 1,
691 'latest_version': 1, 749 'latest_version': 1,
692 'updated_by': 'test', 750 'updated_by': 'test',
693 'updated_ts': response.json_body.get('updated_ts') 751 'updated_ts': response.json_body.get('updated_ts')
694 } 752 }
695 753
696 self.assertEquals(expected_response, response.json_body) 754 self.assertEquals(expected_response, response.json_body)
697 755
698 def testValidateActionSettings(self): 756 def testValidateActionSettings(self):
699 self.assertFalse(config._ValidateActionSettings({})) 757 self.assertFalse(config._ValidateActionSettings({}))
700 self.assertTrue(config._ValidateActionSettings( 758 self.assertTrue(config._ValidateActionSettings(
701 { 759 {
702 'cr_notification_build_threshold': 2, 760 'cr_notification_build_threshold': 2,
703 'cr_notification_latency_limit_minutes': 1000, 761 'cr_notification_latency_limit_minutes': 1000,
704 })) 762 }))
763
764 def testValidateCheckFlakeSettings(self):
765 self.assertFalse(config._ValidateCheckFlakeSettings({}))
766 self.assertFalse(config._ValidateCheckFlakeSettings(
767 {
768 'lower_flake_threshold': 1, # Should be a float.
769 'upper_flake_threshold': 0.98,
770 'max_flake_in_a_row': 4,
771 'max_stable_in_a_row': 4,
772 'iterations_to_rerun': 100
773 }))
774 self.assertFalse(config._ValidateCheckFlakeSettings(
775 {
776 'lower_flake_threshold': 0.02,
777 'upper_flake_threshold': 'a', # Should be a float.
778 'max_flake_in_a_row': 4,
779 'max_stable_in_a_row': 4,
780 'iterations_to_rerun': 100
781 }))
782 self.assertFalse(config._ValidateCheckFlakeSettings(
783 {
784 'lower_flake_threshold': 0.02,
785 'upper_flake_threshold': 0.98,
786 'max_flake_in_a_row': [], # Should be an int.
787 'max_stable_in_a_row': 4,
788 'iterations_to_rerun': 100
789 }))
790 self.assertFalse(config._ValidateCheckFlakeSettings(
791 {
792 'lower_flake_threshold': 0.02,
793 'upper_flake_threshold': 0.98,
794 'max_flake_in_a_row': 4,
795 'max_stable_in_a_row': {}, # Should be an int.
796 'iterations_to_rerun': 100
797 }))
798 self.assertFalse(config._ValidateCheckFlakeSettings(
799 {
800 'lower_flake_threshold': 0.02,
801 'upper_flake_threshold': 0.98,
802 'max_flake_in_a_row': 4,
803 'max_stable_in_a_row': 4,
804 'iterations_to_rerun': 3.2 # Should be an int.
805 }))
806 self.assertTrue(config._ValidateCheckFlakeSettings(
807 {
808 'lower_flake_threshold': 0.02,
809 'upper_flake_threshold': 0.98,
810 'max_flake_in_a_row': 4,
811 'max_stable_in_a_row': 4,
812 'iterations_to_rerun': 100
813 }))
OLDNEW
« no previous file with comments | « appengine/findit/handlers/config.py ('k') | appengine/findit/model/wf_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698