def testAMIOwnerFilter(self): # if you only specify an owner, you get the image owned by any of the # owners that sorts last by the AMI's location. from buildbot.ec2buildslave import EC2LatentBuildSlave bot1 = EC2LatentBuildSlave('bot1', 'sekrit', 'm1.large', valid_ami_owners=[11111111111], identifier='publickey', secret_identifier='privatekey' ) self.assertEqual(bot1.get_image().location, 'test-f0a/image.manifest.xml') bot1 = EC2LatentBuildSlave('bot1', 'sekrit', 'm1.large', valid_ami_owners=[11111111111, 22222222222], identifier='publickey', secret_identifier='privatekey' ) self.assertEqual(bot1.get_image().location, 'test-f0a/image.manifest.xml') bot1 = EC2LatentBuildSlave('bot1', 'sekrit', 'm1.large', valid_ami_owners=[22222222222], identifier='publickey', secret_identifier='privatekey' ) self.assertEqual(bot1.get_image().location, 'test-e1b/image.manifest.xml') bot1 = EC2LatentBuildSlave('bot1', 'sekrit', 'm1.large', valid_ami_owners=12345667890, identifier='publickey', secret_identifier='privatekey' ) self.assertEqual(bot1.get_image().location, 'test-xx/image.manifest.xml')
def testAMISimpleRegexFilter(self): from buildbot.ec2buildslave import EC2LatentBuildSlave bot1 = EC2LatentBuildSlave( 'bot1', 'sekrit', 'm1.large', valid_ami_location_regex=r'test\-[a-z]\w+/image.manifest.xml', identifier='publickey', secret_identifier='privatekey') self.assertEqual(bot1.get_image().location, 'test-xx/image.manifest.xml') bot1 = EC2LatentBuildSlave( 'bot1', 'sekrit', 'm1.large', valid_ami_location_regex=r'test\-[a-z]\d+\w/image.manifest.xml', identifier='publickey', secret_identifier='privatekey') self.assertEqual(bot1.get_image().location, 'test-f0a/image.manifest.xml') bot1 = EC2LatentBuildSlave( 'bot1', 'sekrit', 'm1.large', valid_ami_owners=[22222222222], valid_ami_location_regex=r'test\-[a-z]\d+\w/image.manifest.xml', identifier='publickey', secret_identifier='privatekey') self.assertEqual(bot1.get_image().location, 'test-e1b/image.manifest.xml')
def testDefaultSeparateFile(self): # set up .ec2/aws_id for h in ['HOME', 'USERPROFILE']: if h in os.environ: home = os.environ[h] break else: home = None fake_home = self.basedir os.environ['HOME'] = fake_home dir = os.path.join(fake_home, '.ec2') os.mkdir(dir) f = open(os.path.join(dir, 'aws_id'), 'w') f.write('publickey\nprivatekey') f.close() # The Connection checks the file, so if the secret file is not parsed # correctly, *this* is where it would fail. This is the real test. from buildbot.ec2buildslave import EC2LatentBuildSlave bot1 = EC2LatentBuildSlave('bot1', 'sekrit', 'm1.large', 'ami-12345') # for completeness, we'll show that the connection actually exists. self.failUnless(isinstance(bot1.conn, Connection)) # clean up. if home is None: del os.environ['HOME'] else: os.environ['HOME'] = home self.rmtree(dir)
def testNewKeypairName(self): from buildbot.ec2buildslave import EC2LatentBuildSlave bot1 = EC2LatentBuildSlave( 'bot1', 'sekrit', 'm1.large', 'ami-12345', identifier='publickey', secret_identifier='privatekey', keypair_name='custom_keypair_name') self.assertIn('custom_keypair_name', self.boto.keys) self.assertEqual(bot1.keypair_name, 'custom_keypair_name')
def testAMIRegexIntSortFilter(self): from buildbot.ec2buildslave import EC2LatentBuildSlave bot1 = EC2LatentBuildSlave( 'bot1', 'sekrit', 'm1.large', valid_ami_owners=[11111111111, 22222222222], valid_ami_location_regex=r'test\-[a-z](\d+)[a-z]/image.manifest.xml', identifier='publickey', secret_identifier='privatekey') self.assertEqual(bot1.get_image().location, 'test-c30d/image.manifest.xml')
def testNewSecurityGroup(self): from buildbot.ec2buildslave import EC2LatentBuildSlave bot1 = EC2LatentBuildSlave( 'bot1', 'sekrit', 'm1.large', 'ami-12345', identifier='publickey', secret_identifier='privatekey', security_name='custom_security_name') self.assertEqual( self.boto.security_groups['custom_security_name'].value, 'custom_security_name') self.assertEqual(bot1.security_name, 'custom_security_name')
def testCustomSeparateFile(self): # set up .ec2/aws_id file_path = os.path.join(self.basedir, 'custom_aws_id') f = open(file_path, 'w') f.write('publickey\nprivatekey') f.close() # The Connection checks the file, so if the secret file is not parsed # correctly, *this* is where it would fail. This is the real test. from buildbot.ec2buildslave import EC2LatentBuildSlave bot1 = EC2LatentBuildSlave('bot1', 'sekrit', 'm1.large', 'ami-12345', aws_id_file_path=file_path) # for completeness, we'll show that the connection actually exists. self.failUnless(isinstance(bot1.conn, Connection))