Example #1
0
    def test_run(self):
        # build ami AAA via ami_packer
        result_queue = Queue.Queue()
        config = ConfigParser.SafeConfigParser()
        config.read(os.path.join(os.getcwd(), 'config', 'config.ini'))
        try:
            packer_path = config.get('Packer_Config', 'path')
            packer_bin = os.path.join(packer_path, 'packer')       
        except:
            packer_bin = 'packer'   
        timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d')
        amipacker = AMIPacker(os.path.join(os.getcwd(), 'tests', 'template', 'test_template.json'),
                        'ubuntu/images/ebs/ubuntu-trusty-14.04-amd64-server-20140416.1', '123456', timestamp,
                        self.region, result_queue, self.aws_key.get_aws_access_key(), self.aws_key.get_aws_secret_key(), packer_bin)
        self._clean_previous_ami('test_omelet_ami')
        amipacker.run()
        if not result_queue.empty():   
            (region, result, message, existence) = result_queue.get()
        print message
        self.ami = message
        
        # launching instance B for check
        ami = AMI(self.region, self.aws_key.get_aws_access_key(), self.aws_key.get_aws_secret_key())
        assert ami.check_image(message, 'available')
        self.instance_id = self.helper.launch_instance(message, self.name, self.name)

        # check modules are in instance B
        std_out = self.helper.run_command(self.instance_id, 'dpkg -l | grep newrelic', self.name, 'ubuntu')
        print std_out
        assert 'newrelic-sysmond' in std_out