Skip to content

Instantly share code, notes, and snippets.

@tonyhutter
Created May 3, 2021 18:31
Show Gist options
  • Save tonyhutter/63e1a8a0ae7cb442c685097969009083 to your computer and use it in GitHub Desktop.
Save tonyhutter/63e1a8a0ae7cb442c685097969009083 to your computer and use it in GitHub Desktop.
Partial work on test case for 5041
diff --git a/master/buildbot/test/unit/worker/test_ec2.py b/master/buildbot/test/unit/worker/test_ec2.py
index 3342671ed..0d91f8481 100644
--- a/master/buildbot/test/unit/worker/test_ec2.py
+++ b/master/buildbot/test/unit/worker/test_ec2.py
@@ -17,6 +17,7 @@
import os
from twisted.trial import unittest
+from twisted.python import log
from buildbot.test.util.decorators import flaky
from buildbot.test.util.warnings import assertNotProducesWarnings
@@ -437,6 +438,36 @@ class TestEC2LatentWorker(unittest.TestCase):
)
bs._poll_resolution = 0
instance_id, _, _ = bs._start_instance()
+
+ instances = r.instances.filter(
+ Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
+ instances = list(instances)
+ self.assertTrue(bs.spot_instance)
+ self.assertEqual(bs.product_description, product_description)
+ self.assertEqual(len(instances), 1)
+ self.assertEqual(instances[0].id, instance_id)
+ self.assertIsNone(instances[0].tags)
+
+ @mock_ec2
+ def test_start_spot_instance_slow_startup(self):
+ c, r = self.botoSetup('latent_buildbot_slave')
+ amis = list(r.images.all())
+ product_description = 'Linux/Unix'
+ bs = ec2.EC2LatentWorker('bot1', 'sekrit', 'm1.large',
+ identifier='publickey',
+ secret_identifier='privatekey',
+ keypair_name='keypair_name',
+ security_name='security_name',
+ ami=amis[0].id, spot_instance=True,
+ max_spot_price=1.5,
+ product_description=product_description,
+ region='us-west-1',
+ placement='b'
+ )
+ bs._poll_resolution = 0
+
+ instance_id, _, _ = bs._request_spot_instance()
+
instances = r.instances.filter(
Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
instances = list(instances)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment