def test_get_build_url_milo(self, get_settings_async): get_settings_async.return_value = test_util.future( service_config_pb2.SettingsCfg(swarming=dict( milo_hostname='milo.example.com')), ) build = test_util.build(id=1) build.url = None self.assertEqual(api_common.get_build_url(build), 'https://milo.example.com/b/1')
def setUp(self): super(BaseTest, self).setUp() user.clear_request_cache() self.patch('tq.enqueue_async', autospec=True, return_value=future(None)) self.now = NOW self.patch( 'components.utils.utcnow', autospec=True, side_effect=lambda: self.now ) self.settings = service_config_pb2.SettingsCfg( swarming=dict( milo_hostname='milo.example.com', bbagent_package=dict( package_name='infra/tools/bbagent', version='luci-runner-version', version_canary='luci-runner-version-canary', builders=service_config_pb2.BuilderPredicate( regex=['chromium/try/linux'], ), ), kitchen_package=dict( package_name='infra/tools/kitchen', version='kitchen-version', version_canary='kitchen-version-canary', ), user_packages=[ dict( package_name='infra/tools/git', version='git-version', version_canary='git-version-canary', ), dict( package_name='infra/cpython/python', version='py-version', subdir='python', ), dict( package_name='infra/excluded', version='excluded-version', builders=service_config_pb2.BuilderPredicate( regex_exclude=['.*'], ), ), ], ), known_public_gerrit_hosts=['chromium-review.googlesource.com'], ) self.patch( 'config.get_settings_async', autospec=True, return_value=future(self.settings) )
def setUp(self): super(BuildBucketServiceTest, self).setUp() user.clear_request_cache() self.current_identity = auth.Identity('service', 'unittest') self.patch('components.auth.get_current_identity', side_effect=lambda: self.current_identity) self.patch('user.can_async', return_value=future(True)) self.now = datetime.datetime(2015, 1, 1) self.patch('components.utils.utcnow', side_effect=lambda: self.now) config.put_bucket( 'chromium', 'a' * 40, test_util.parse_bucket_cfg(''' name: "try" acls { role: READER identity: "anonymous:anonymous" } '''), ) config.put_bucket( 'chromium', 'a' * 40, test_util.parse_bucket_cfg(''' name: "luci" acls { role: READER identity: "anonymous:anonymous" } swarming { builders { name: "linux" swarming_host: "chromium-swarm.appspot.com" build_numbers: YES recipe { cipd_package: "infra/recipe_bundle" cipd_version: "refs/heads/master" name: "recipe" } } } '''), ) self.patch('swarming.cancel_task_async', return_value=future(None)) self.patch( 'google.appengine.api.app_identity.get_default_version_hostname', autospec=True, return_value='buildbucket.example.com') self.patch('tq.enqueue_async', autospec=True, return_value=future(None)) self.patch('config.get_settings_async', autospec=True, return_value=future(service_config_pb2.SettingsCfg())) self.patch('swarming.cancel_task_transactionally_async', autospec=True, return_value=future(None)) self.patch('search.TagIndex.random_shard_index', return_value=0)
def setUp(self): super(SwarmbucketApiTest, self).setUp() self.patch('components.utils.utcnow', autospec=True, return_value=datetime.datetime(2015, 11, 30)) self.patch( 'google.appengine.api.app_identity.get_default_version_hostname', return_value='cr-buildbucket.appspot.com') self.patch('creation._should_be_canary', side_effect=lambda p: p > 50) auth_testing.reset_local_state() auth.bootstrap_group('all', [auth.Anonymous]) user.clear_request_cache() chromium_cfg = test_util.parse_bucket_cfg(''' name: "luci.chromium.try" acls { role: SCHEDULER group: "all" } swarming { hostname: "swarming.example.com" builders { name: "linux" swarming_host: "swarming.example.com" category: "Chromium" build_numbers: YES recipe { cipd_package: "infra/recipe_bundle" cipd_version: "refs/heads/master" name: "presubmit" properties: "foo:bar" properties_j: "baz:1" } dimensions: "foo:bar" dimensions: "baz:baz" auto_builder_dimension: YES # Override builder cache without timeout to make tests # simpler. caches { path: "builder" name: "builder_cache_name" } } builders { name: "windows" category: "Chromium" swarming_host: "swarming.example.com" recipe { cipd_package: "infra/recipe_bundle" cipd_version: "refs/heads/master" name: "presubmit" } # Override builder cache without timeout to make tests # simpler. caches { path: "builder" name: "builder_cache_name" } } } ''') config.put_bucket('chromium', 'deadbeef', chromium_cfg) v8_cfg = test_util.parse_bucket_cfg(''' name: "luci.v8.try" acls { role: READER group: "all" } ''') config.put_bucket('v8', 'deadbeef', v8_cfg) props_def = { 'extra_args': [ 'cook', '-recipe', '${recipe}', '-properties', '${properties_json}', '-logdog-project', '${project}', ], 'cipd_input': { 'packages': [ { 'package_name': 'infra/test/bar/${os_ver}', 'path': '.', 'version': 'latest', }, { 'package_name': 'infra/test/foo/${platform}', 'path': 'third_party', 'version': 'stable', }, ], }, } self.task_template = { 'name': 'bb-${build_id}-${project}-${builder}', 'task_slices': [{ 'properties': props_def, 'wait_for_capacity': False, }], } self.patch( 'swarming._get_task_template', autospec=True, return_value=('rev', self.task_template), ) self.settings = service_config_pb2.SettingsCfg( swarming=dict( milo_hostname='milo.example.com', luci_runner_package=dict( package_name='infra/tools/luci_runner', version='luci-runner-version', ), kitchen_package=dict( package_name='infra/tools/kitchen', version='kitchen-version', ), user_packages=[ dict( package_name='infra/tools/git', version='git-version', ), ], ), logdog=dict(hostname='logdog.example.com'), ) self.patch( 'config.get_settings_async', autospec=True, return_value=future(self.settings), )
def setUp(self): super(CreationTest, self).setUp() user.clear_request_cache() self.current_identity = auth.Identity('service', 'unittest') self.patch('components.auth.get_current_identity', side_effect=lambda: self.current_identity) self.patch('user.can_async', return_value=future(True)) self.now = datetime.datetime(2015, 1, 1) self.patch('components.utils.utcnow', side_effect=lambda: self.now) self.chromium_try = test_util.parse_bucket_cfg(''' name: "luci.chromium.try" swarming { builders { name: "linux" build_numbers: YES swarming_host: "chromium-swarm.appspot.com" recipe { name: "recipe" cipd_package: "infra/recipe_bundle" cipd_version: "refs/heads/master" } } builders { name: "mac" swarming_host: "chromium-swarm.appspot.com" recipe { name: "recipe" cipd_package: "infra/recipe_bundle" cipd_version: "refs/heads/master" } } builders { name: "win" swarming_host: "chromium-swarm.appspot.com" recipe { name: "recipe" cipd_package: "infra/recipe_bundle" cipd_version: "refs/heads/master" } } } ''') config.put_bucket('chromium', 'a' * 40, self.chromium_try) self.create_sync_task = self.patch( 'swarming.create_sync_task', autospec=True, return_value={'is_payload': True}, ) self.patch('swarming.cancel_task_async', return_value=future(None)) self.patch( 'google.appengine.api.app_identity.get_default_version_hostname', autospec=True, return_value='buildbucket.example.com') self.patch('tq.enqueue_async', autospec=True, return_value=future(None)) self.settings = service_config_pb2.SettingsCfg( swarming=dict(global_caches=[dict(path='git')]), logdog=dict(hostname='logs.example.com'), ) self.patch('config.get_settings_async', autospec=True, return_value=future(self.settings)) self.patch('creation._should_update_builder', side_effect=lambda p: p > 0.5) self.patch('creation._should_be_canary', side_effect=lambda p: p > 50) self.patch('search.TagIndex.random_shard_index', return_value=0)
def setUp(self): super(SwarmbucketApiTest, self).setUp() self.patch('components.utils.utcnow', autospec=True, return_value=datetime.datetime(2015, 11, 30)) self.patch( 'google.appengine.api.app_identity.get_default_version_hostname', return_value='cr-buildbucket.appspot.com') self.patch('creation._should_be_canary', side_effect=lambda p: p > 50) auth_testing.reset_local_state() auth.bootstrap_group('all', [auth.Anonymous]) user.clear_request_cache() chromium_cfg = test_util.parse_bucket_cfg(''' name: "luci.chromium.try" acls { role: SCHEDULER group: "all" } swarming { hostname: "swarming.example.com" builders { name: "linux" swarming_host: "swarming.example.com" category: "Chromium" build_numbers: YES recipe { cipd_package: "infra/recipe_bundle" cipd_version: "refs/heads/master" name: "presubmit" properties: "foo:bar" properties_j: "baz:1" } dimensions: "foo:bar" dimensions: "baz:baz" auto_builder_dimension: YES # Override builder cache without timeout to make tests # simpler. caches { path: "builder" name: "builder_cache_name" } } builders { name: "windows" category: "Chromium" swarming_host: "swarming.example.com" recipe { cipd_package: "infra/recipe_bundle" cipd_version: "refs/heads/master" name: "presubmit" } # Override builder cache without timeout to make tests # simpler. caches { path: "builder" name: "builder_cache_name" } } } ''') config.put_bucket('chromium', 'deadbeef', chromium_cfg) v8_cfg = test_util.parse_bucket_cfg(''' name: "luci.v8.try" acls { role: READER group: "all" } ''') config.put_bucket('v8', 'deadbeef', v8_cfg) self.settings = service_config_pb2.SettingsCfg( swarming=dict( milo_hostname='milo.example.com', bbagent_package=dict( package_name='infra/tools/bbagent', version='luci-runner-version', ), kitchen_package=dict( package_name='infra/tools/kitchen', version='kitchen-version', ), user_packages=[ dict( package_name='infra/tools/git', version='git-version', ), ], ), logdog=dict(hostname='logdog.example.com'), ) self.patch( 'config.get_settings_async', autospec=True, return_value=future(self.settings), )
def get_settings_async(): # pragma: no cover _, global_settings = yield config.get_self_config_async( 'settings.cfg', service_config_pb2.SettingsCfg, store_last_good=True) raise ndb.Return(global_settings or service_config_pb2.SettingsCfg())