Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
Merging from default
Browse files Browse the repository at this point in the history
changeset:   2971:163d9fc9dfe4
tag:         tip
parent:      2968:81a7d0437342
user:        Chris AtLee <catlee@mozilla.com>
date:        Fri Feb 01 14:49:08 2013 -0500
summary:     Bug 835371: remove nextL10nSlave support. r=bhearsum

--HG--
branch : production-0.8
  • Loading branch information
ccooper committed Feb 1, 2013
2 parents 8b76d83 + 95e94c8 commit 4d39e93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 56 deletions.
42 changes: 3 additions & 39 deletions misc.py
Expand Up @@ -317,42 +317,6 @@ def _nextFastSlave(builder, available_slaves, only_fast=False):
return random.choice(available_slaves) return random.choice(available_slaves)




def _nextL10nSlave(n=4):
"""Return a nextSlave function that restricts itself to choosing amongst
the first n connnected slaves. If there aren't enough slow slaves,
fallback to using fast slaves."""
def _nextslave(builder, available_slaves):
try:
# Determine our list of the first n connected slaves, preferring to use slow slaves
# if available.
connected_slaves = [s for s in builder.slaves if s.slave.slave_status.isConnected()]
# Sort the list so we're stable across reconfigs
connected_slaves.sort(key=lambda s: s.slave.slavename)
fast, slow = _partitionSlaves(connected_slaves)
slow = slow[:n]
# Choose enough fast slaves so that we're considering a total of n
# slaves
fast = fast[:n - (len(slow))]

# Now keep only those that are in available_slaves
slow = [s for s in slow if s in available_slaves]
fast = [s for s in fast if s in available_slaves]

# Now prefer slaves that most recently did this repack
if slow:
return sorted(slow, _recentSort(builder))[-1]
elif fast:
return sorted(fast, _recentSort(builder))[-1]
else:
# That's ok!
return None
except:
log.msg("Error choosing l10n slave for builder '%s', choosing randomly instead" % builder.name)
log.err()
return random.choice(available_slaves)
return _nextslave


def _nextSlowIdleSlave(nReserved): def _nextSlowIdleSlave(nReserved):
"""Return a nextSlave function that will only return a slave to run a build """Return a nextSlave function that will only return a slave to run a build
if there are at least nReserved slaves available.""" if there are at least nReserved slaves available."""
Expand Down Expand Up @@ -1341,7 +1305,7 @@ def generateBranchObjects(config, name, secrets=None):
'slavebuilddir': slavebuilddir, 'slavebuilddir': slavebuilddir,
'factory': factory, 'factory': factory,
'category': name, 'category': name,
'nextSlave': _nextL10nSlave(), 'nextSlave': _nextSlowSlave,
'properties': {'branch': '%s' % config['repo_path'], 'properties': {'branch': '%s' % config['repo_path'],
'builddir': '%s-l10n_%s' % (builddir, str(n)), 'builddir': '%s-l10n_%s' % (builddir, str(n)),
'stage_platform': stage_platform, 'stage_platform': stage_platform,
Expand Down Expand Up @@ -1580,7 +1544,7 @@ def generateBranchObjects(config, name, secrets=None):
'slavebuilddir': normalizeName('%s-%s-l10n-nightly' % (name, platform), pf['stage_product']), 'slavebuilddir': normalizeName('%s-%s-l10n-nightly' % (name, platform), pf['stage_product']),
'factory': mozilla2_l10n_nightly_factory, 'factory': mozilla2_l10n_nightly_factory,
'category': name, 'category': name,
'nextSlave': _nextL10nSlave(), 'nextSlave': _nextSlowSlave,
'properties': {'branch': name, 'properties': {'branch': name,
'platform': platform, 'platform': platform,
'product': pf['stage_product'], 'product': pf['stage_product'],
Expand Down Expand Up @@ -1678,7 +1642,7 @@ def generateBranchObjects(config, name, secrets=None):
'slavebuilddir': normalizeName('%s-%s-l10n-dep' % (name, platform), pf['stage_product']), 'slavebuilddir': normalizeName('%s-%s-l10n-dep' % (name, platform), pf['stage_product']),
'factory': mozilla2_l10n_dep_factory, 'factory': mozilla2_l10n_dep_factory,
'category': name, 'category': name,
'nextSlave': _nextL10nSlave(), 'nextSlave': _nextSlowSlave,
'properties': {'branch': name, 'properties': {'branch': name,
'platform': platform, 'platform': platform,
'stage_platform': stage_platform, 'stage_platform': stage_platform,
Expand Down
18 changes: 1 addition & 17 deletions test/test_misc_nextslaves.py
Expand Up @@ -5,7 +5,7 @@
from twisted.trial import unittest from twisted.trial import unittest


import buildbotcustom.misc import buildbotcustom.misc
from buildbotcustom.misc import _nextSlowIdleSlave, _nextL10nSlave,\ from buildbotcustom.misc import _nextSlowIdleSlave, \
_nextFastSlave, _nextSlowSlave _nextFastSlave, _nextSlowSlave




Expand Down Expand Up @@ -79,19 +79,3 @@ def test_nextSlowIdleSlave_unavail(self):
func = _nextSlowIdleSlave(5) func = _nextSlowIdleSlave(5)
slave = func(self.builder, self.slaves) slave = func(self.builder, self.slaves)
self.assert_(slave is None) self.assert_(slave is None)

def test_nextL10nSlave_avail(self):
"""Test that _nextL10nSlave returns a slow slave if the first slow
slave is available."""
func = _nextL10nSlave(1)
slave = func(self.builder, self.slaves)
self.assert_(slave.slave.slavename == 'slow1')

def test_nextL10nSlave_unavail(self):
"""Test that _nextL10nSlave returns None if the first slow slave is not
available."""
func = _nextL10nSlave(1)
available_slaves = [
s for s in self.slaves if s.slave.slavename != 'slow1']
slave = func(self.builder, available_slaves)
self.assert_(slave is None)

0 comments on commit 4d39e93

Please sign in to comment.