コード例 #1
0
  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)
    )
コード例 #2
0
 def test_builder_matches(self, regex, regex_exclude, expected):
     predicate = service_config_pb2.BuilderPredicate(
         regex=regex, regex_exclude=regex_exclude)
     builder_id = build_pb2.BuilderID(
         project='chromium',
         bucket='try',
         builder='linux-rel',
     )
     actual = swarming._builder_matches(builder_id, predicate)
     self.assertEqual(expected, actual)
コード例 #3
0
ファイル: swarmingcfg_test.py プロジェクト: xinghun61/infra
 def test_predicate(self):
     predicate = service_config_pb2.BuilderPredicate(
         regex=['a', ')'],
         regex_exclude=['b', '('],
     )
     swarmingcfg._validate_builder_predicate(predicate, self.ctx)
     self.assertErrors([
         'regex u\')\': invalid: unbalanced parenthesis',
         'regex_exclude u\'(\': invalid: unbalanced parenthesis',
     ])