Exemplo n.º 1
0
    def post(self):

        self.reservation.instances[0].terminate()
        #ec2_conn.terminate_instances([self.reservation.instances[0].id])
        util.wait(
            lambda: self.reservation.instances[0].update() == 'terminated',
            timeout=60 * 2
        )

        assert util.retry(
            lambda: not self.testSSH(
                self.key_pairs.keypair.material.encode('ascii'),
                config['ec2']['test_username'],
                self.reservation.instances[0].public_dns_name
            ),
            wait_exp=2
        )
Exemplo n.º 2
0
    def pre(self, key_pairs=None, security_group=None):
        image_id = config['ec2']['test_image_id']
        instance_config = config['ec2']['test_instance']

        self.image = ec2_conn.get_all_images(image_ids=[image_id])[0]
        self.security_group = security_group
        self.key_pairs = key_pairs

        self.security_group.group.authorize('tcp', 22, 22, '0.0.0.0/0')
        self.reservation = self.image.run(
            security_groups=[self.security_group.group_name],
            key_name=self.key_pairs.key_name,
            **instance_config
        )

        util.wait(
            lambda: self.reservation.instances[0].update() == 'running',
            timeout=60 * 3
        )

        util.wait(
            lambda: self.testTelnet(
                self.reservation.instances[0].public_dns_name,
                22
            ),
            timeout = 60 * 5
        )

        assert util.retry(
            lambda: self.testSSH(
                self.key_pairs.keypair.material.encode('ascii'),
                config['ec2']['test_username'],
                self.reservation.instances[0].public_dns_name
            ),
            wait_exp=2
        )
Exemplo n.º 3
0
 def test_loop(self):
     mock = functools.partial(self.mock, succeed_on_try=2)
     util.wait(mock, interval=None)
     self.assertTrue(self.mock.testCalled(2))