Bug 983939 - Allow to run retried jobs on spot instances. r=catlee
authorRail Aliiev <rail@mozilla.com>
Mon, 17 Mar 2014 11:04:29 -0400
changeset 3595 1c5967373837b56b75cb3ec7963d2d11cd4c299e
parent 3594 a3bdcf6f2f16a5beb6b2dc0c7b421962038829f9
child 3596 8607bfbeaa02b789422e30f7caa608cb74a25a5d
push id2918
push userraliiev@mozilla.com
push dateMon, 17 Mar 2014 15:05:26 +0000
reviewerscatlee
bugs983939
Bug 983939 - Allow to run retried jobs on spot instances. r=catlee
test/test_misc_nextslaves.py
--- a/test/test_misc_nextslaves.py
+++ b/test/test_misc_nextslaves.py
@@ -6,17 +6,17 @@ import shutil
 import mock
 
 from twisted.trial import unittest
 from buildbot.db import dbspec, connector
 from buildbot.db.schema.manager import DBSchemaManager
 
 import buildbotcustom.misc
 from buildbotcustom.misc import _nextIdleSlave, _nextAWSSlave, \
-    _classifyAWSSlaves, _getRetries
+    _classifyAWSSlaves, _getRetries, MAX_SPOT_RETRIES
 
 
 class TestNextSlaveFuncs(unittest.TestCase):
     def setUp(self):
         self.slaves = slaves = []
         for name in ('s1', 's2', 's3'):
             slave = mock.Mock()
             slave.slave.slavename = name
@@ -101,22 +101,22 @@ class TestNextAWSSlave(unittest.TestCase
                               f(self.builder, ondemand).slave.slavename)
             self.assertEquals(_getRetries.called, 0)
 
             # Spot instances should be preferred if there are no retries
             self.assertEquals("slave-spot-001",
                               f(self.builder, spot + ondemand).slave.slavename)
 
             # Otherwise ondemand should be preferred
-            _getRetries.return_value = [request], 1
+            _getRetries.return_value = [request], MAX_SPOT_RETRIES + 1
             self.assertEquals("slave-ec2",
                               f(self.builder, spot + ondemand).slave.slavename)
 
             # Or no slave if only spot are available
-            _getRetries.return_value = [request], 1
+            _getRetries.return_value = [request], MAX_SPOT_RETRIES + 1
             self.assertEquals(None, f(self.builder, spot))
 
     def test_nextAWSSlave_AWS_wait(self):
         """Test that we'll wait up to aws_wait for inhouse instances to become
         available"""
         f = _nextAWSSlave(aws_wait=60)
         inhouse, ondemand, spot = _classifyAWSSlaves(self.slaves)
         # We need to mock out _getRetries so that we don't have to create a db
@@ -137,17 +137,17 @@ class TestNextAWSSlave(unittest.TestCase
                 t.return_value = 61
                 self.assertEquals("slave-spot-001",
                                   f(self.builder,
                                     spot + ondemand).slave.slavename)
                 self.assertEquals("slave-ec2",
                                   f(self.builder,
                                     ondemand).slave.slavename)
 
-                _getRetries.return_value = [request], 1
+                _getRetries.return_value = [request], MAX_SPOT_RETRIES + 1
                 self.assertEquals("slave-ec2",
                                   f(self.builder,
                                     spot + ondemand).slave.slavename)
 
     def test_nextAWSSlave_noRequests(self):
         """Test that everything works if there are no pending requests to
         getRetries"""
         f = _nextAWSSlave()