Beispiel #1
0
 def testAssignWarmCacheHostWithNoRevision(self, mock_error, *_):
     cache_name = 'cache_name'
     tryjob = MockTryJob()
     del tryjob.properties['bad_revision']
     swarmbot_util.AssignWarmCacheHost(tryjob, cache_name, None)
     # Make sure that no bot was selected.
     self.assertEqual(2, len(tryjob.dimensions))
     # Make sure that an error was logged.
     self.assertTrue(mock_error.called)
Beispiel #2
0
    def testSelectWarmCacheNoOp(self, mock_fn):
        class MockTryJobBuildbot(object):
            is_swarmbucket_build = False

        try_job_buildbot = MockTryJobBuildbot()
        cache_name = 'some_other_cache_name'
        WfTryBotCache.Get(cache_name).recent_bots = ['slave1']
        swarmbot_util.AssignWarmCacheHost(try_job_buildbot, cache_name, None)
        self.assertFalse(mock_fn.called)
Beispiel #3
0
def TriggerTryJob(master_name, builder_name, tryserver_mastername,
                  tryserver_buildername, properties, try_job_type, cache_name,
                  dimensions, runner_id):
    """Triggers a try job through Buildbucket.

  Args:
    master_name (str): Name of the target master on Waterfall.
    builder_name (str): Name of the target builder/tester on Waterfall.
    tryserver_mastername (str): Name of the tryserver master for the try job.
    tryserver_buildername (str): Name of the tryserver builder for the try job.
    properties (dict): A key-value map of build properties for the try job.
    try_job_type (int): Type of the try job, either compile or test.
    cache_name (str): The name of the build cache.
    dimensions ([str]): The bot dimensions used to allocate a Swarming bot.
    runner_id (str): The id of the runner to trigger this try job. One runner
      could trigger only one try job.
  """

    # This could be a bucket name. Recipe code should use 'target_mastername' to
    # configure the recipe, 'mastername' may still be used by some code paths and
    # bucket is the logical successor to mastername.
    properties['mastername'] = tryserver_mastername

    try_job = buildbucket_client.TryJob(tryserver_mastername,
                                        tryserver_buildername, properties, [],
                                        cache_name, dimensions,
                                        CreatePubSubCallback(runner_id))
    swarmbot_util.AssignWarmCacheHost(try_job, cache_name, FinditHttpClient())
    error, build = buildbucket_client.TriggerTryJobs([try_job])[0]

    monitoring.OnTryJobTriggered(try_job_type, master_name, builder_name)

    if error:
        return None, error

    return build.id, None
Beispiel #4
0
 def testAssignWarmCacheOnlyIdleBots(self, *_):
     cache_name = 'cache_name'
     tryjob = MockTryJob()
     swarmbot_util.AssignWarmCacheHost(tryjob, cache_name, None)
     self.assertEqual('id:bot0', tryjob.dimensions[2])
Beispiel #5
0
 def testAssignWarmCacheNoIdleBots(self, *_):
     cache_name = 'cache_name'
     tryjob = MockTryJob()
     swarmbot_util.AssignWarmCacheHost(tryjob, cache_name, None)
     self.assertEqual(2, len(tryjob.dimensions))
Beispiel #6
0
 def testAssignWarmCacheHostNoCheckedOutRevision(self, *_):
     cache_name = 'cache_name'
     tryjob = MockTryJob()
     swarmbot_util.AssignWarmCacheHost(tryjob, cache_name, None)
     self.assertEqual('id:bot0', tryjob.dimensions[2])
Beispiel #7
0
 def testAssignWarmCacheHost(self, *_):
     cache_name = 'cache_name'
     tryjob = MockTryJob()
     swarmbot_util.AssignWarmCacheHost(tryjob, cache_name, None)
Beispiel #8
0
 def testAssignWarmCacheHostFlake(self, *_):
     cache_name = 'cache_name_flake'
     tryjob = MockFlakeTryJob()
     swarmbot_util.AssignWarmCacheHost(tryjob, cache_name, None)
     self.assertIn('id:' + SOME_BOTS[0]['bot_id'], tryjob.dimensions)