예제 #1
0
파일: Euca4750.py 프로젝트: aliceh/eutester
class Euca4750(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf" 
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath) 
                
    def runSysCmd(self, cmd):
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd) 
         
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        # Set modify the property with a null value
        self.runSysCmd("euca-modify-property -p www.httpproxyhost=")
        self.runSysCmd("euca-describe-properties")
        # Check euca-describe-properties output for property
        self.count = str(self.out).count("www.httpproxyhost")
        # reset property to original value
        self.runSysCmd("euca-modify-property -r www.httpproxyhost")
        if self.count == 1:
            self.tester.debug("SUCCESS property with null value modified correctly")
            pass
        else:
            self.fail("FAIL value null value not modified correctly")
예제 #2
0
class EucaTest(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.STARTC = '\033[1m\033[1m\033[42m'
        self.ENDC = '\033[0m'

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def test(self):
        canonicalID = str(self.tester.s3.get_canonical_user_id())
        count = len(canonicalID)
        print self.STARTC + "canonicalId = " + canonicalID + self.ENDC
        print self.STARTC + "canonicalId size = " + str(count) + self.ENDC
        # make sure it is valid 64 character canonicalID
        if count == 64 :
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAIL")
예제 #3
0
파일: Euca4869.py 프로젝트: aliceh/eutester
class Euca4869(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf"
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath) 
                
    def runSysCmd(self, cmd):
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd) 
         
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        # Try and deregister a malforemd imageId (ie: emi, efi, eri followed by 8 chars)
        self.runSysCmd("euca-deregister emi-1234567")
        # Check for new error (Invalid id: "emi-1234567")
        self.new = str(self.out).count("Invalid id")
        # We should see the new error and not the old.
        if self.new > 0 :
            self.tester.debug("SUCCESS new error logged")
            pass
        else:
            self.fail("FAIL old error logged")
예제 #4
0
class EucaTest(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.OK = '\033[1m\033[37m\033[42m'
        self.ENDC = '\033[0m'

    def tearDown(self):
        self.tester.modify_property('dns.tcp.timeout_seconds' , '30' )
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def print_time(self, start):
        elapsed = time.time() - start
        minutes = int(elapsed / 60)
        seconds = int(elapsed % 60)
        print self.OK + "Elapsed time = " +  str(minutes) + ' min ' + str(seconds) + ' sec ' + self.ENDC

    def test(self):
        # Set the timeout the default is 30
        self.tester.modify_property('dns.tcp.timeout_seconds' , '10' )
        self.start = time.time()
        # The DNS TCP HANDLER should timeout before the ssh timeout=120
        self.tester.sys("nc -w 120 " + str(self.tester.clc.hostname) + " 53",timeout=120)
        self.print_time(self.start)
예제 #5
0
class Euca5845(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.OK = "\033[1m\033[37m\033[42m"
        self.ENDC = "\033[0m"

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self, groupName):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group(groupName)
        self.tester.authorize_group(self.group)

    def testName(self):
        # Group name with NON ASCII Character
        badGroupName = "lin¢ux"
        try:
            self.doAuth(badGroupName)
        except Exception as err:
            if str(err).count("InvalidParameterValue") > 0:
                print self.OK + err.args[2] + self.ENDC
                pass
            else:
                self.fail("FAILED : NON ASCII Character allowed.")
        print "SUCCESS"
예제 #6
0
class LoadBalancing(EutesterTestCase):
    def __init__(self, extra_args= None):
        self.setuptestcase()
        self.setup_parser()
        if extra_args:
            for arg in extra_args:
                self.parser.add_argument(arg)
        self.get_args()

        # Setup basic eutester object
        if self.args.region:
            self.tester = ELBops( credpath=self.args.credpath, region=self.args.region)
        else:
            self.tester = Eucaops( credpath=self.args.credpath, config_file=self.args.config,password=self.args.password)
        self.tester.poll_count = 120

        ### Add and authorize a group for the instance
        self.group = self.tester.add_group(group_name="group-" + str(int(time.time())))
        self.tester.authorize_group_by_name(group_name=self.group.name )
        self.tester.authorize_group_by_name(group_name=self.group.name, port=-1, protocol="icmp" )
        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair( "keypair-" + str(int(time.time())))
        self.keypath = '%s/%s.pem' % (os.curdir, self.keypair.name)
        ### Get an image
        self.image = self.args.emi
        if not self.image:
            self.image = self.tester.get_emi(root_device_type="instance-store", not_platform="windows")

        ### Populate available zones
        zones = self.tester.ec2.get_all_zones()
        self.zone = random.choice(zones).name

        self.load_balancer_port = 80

        (self.web_servers, self.filename) = self.tester.create_web_servers(keypair=self.keypair,
                                                                          group=self.group,
                                                                          zone=self.zone,
                                                                          port=self.load_balancer_port,
                                                                          filename='instance-name',
                                                                          image=self.image)

        self.load_balancer = self.tester.create_load_balancer(zones=[self.zone],
                                                              name="test-" + str(int(time.time())),
                                                              load_balancer_port=self.load_balancer_port)
        assert isinstance(self.load_balancer, LoadBalancer)
        self.tester.register_lb_instances(self.load_balancer.name,
                                          self.web_servers.instances)

    def clean_method(self):
        self.tester.cleanup_artifacts()

    def GenerateRequests(self):
        """
        This will test the most basic use case for a load balancer.
        Uses to backend instances with httpd servers.
        """
        dns = self.tester.service_manager.get_enabled_dns()
        lb_ip = dns.resolve(self.load_balancer.dns_name)
        lb_url = "http://{0}:{1}/instance-name".format(lb_ip, self.load_balancer_port)
        self.tester.generate_http_requests(url=lb_url, count=1000)
예제 #7
0
class Euca3933(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.fakeId = "OOO000000000"
        self.cmdMod = " euca-modify-image-attribute --launch-permission "
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testValidation(self):
        self.emi = self.tester.get_emi()
        # Try and add --launch-permission with a bad userId
        self.out = self.tester.sys(self.source + self.cmdMod + " -a " +
                                   self.fakeId + " " + self.emi.id)
        # Check output
        self.count = str(self.out).count("Not a valid userId")
        if self.count == 1:
            self.tester.debug(
                "SUCCESS --launch-permission validation error thrown")
            pass
        else:
            self.fail("FAIL no error with bad userID")
        pass
예제 #8
0
class Euca2244(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf"
        self.bucket = "test-bucket"
        self.imgName = "bfebs-centos-vmwaretools-i386.img"
        self.imgUrl =  "http://mirror.qa.eucalyptus-systems.com/bfebs-image/vmware/"     
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.iu = ImageUtils(tester=self.tester, config_file=self.conf )
        self.doAuth()

    def tearDown(self):
        self.tester.sys(self.source + "euca-deregister " + self.emi)
        self.tester.sys(self.source + "euca-delete-bundle -b " + self.imgName + "test0")
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath)  
    
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        self.emi = self.iu.create_emi_from_url( self.imgUrl + self.imgName)
        self.out = self.tester.sys(self.source + "euca-describe-images " + self.emi)
        self.count = str(self.out).count("private")
        if self.count==1:
            self.tester.debug("SUCCESS The default image availability is private")
            pass
        else:
            self.fail("FAIL The default image availability is public not private")
예제 #9
0
class Euca4869(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        # Try and deregister a malforemd imageId (ie: emi, efi, eri followed by 8 chars)
        self.runSysCmd("euca-deregister emi-1234567")
        # Check for new error (Invalid id: "emi-1234567")
        self.new = str(self.out).count("Invalid id")
        # We should see the new error and not the old.
        if self.new > 0:
            self.tester.debug("SUCCESS new error logged")
            pass
        else:
            self.fail("FAIL old error logged")
예제 #10
0
class EucaTest(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.STARTC = "\033[1m\033[1m\033[42m"
        self.ENDC = "\033[0m"

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def test(self):
        canonicalID = str(self.tester.s3.get_canonical_user_id())
        count = len(canonicalID)
        print self.STARTC + "canonicalId = " + canonicalID + self.ENDC
        print self.STARTC + "canonicalId size = " + str(count) + self.ENDC
        # make sure it is valid 64 character canonicalID
        if count == 64:
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAIL")
예제 #11
0
class Euca2322(unittest.TestCase):

    def setUp(self):
        self.tester  = Eucaops( config_file="cloud.conf", password="******" )
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.sbin = self.tester.eucapath + "/usr/sbin/"
        self.cmd = "euca-modify-property -peuca=\'System.getProperty(\"file.encoding\")\'"
        self.doAuth()
    
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def tearDown(self):
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath)

    def testEncoding(self):
        #call euca-modify-property which in turn calls System.getProperty("file.encoding")
        prop_string = self.tester.sys(self.source + self.sbin + self.cmd)
        # parse out the  file.encoding value 
        if (prop_string != []):
            value = str(prop_string[0]).split()[2]
        # compare the return values pass it is "UTF-8" fail otherwise  
        if not cmp( value, "UTF-8"):
            self.tester.debug("Passed Euca2322 default file.encoding = " + value)
            pass
        else: 
            self.fail("Failed Euca2322 default file.encoding " + value + " != UTF-8" ) 
예제 #12
0
class Euca4735(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf"       
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath)
        
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        self.emi = self.tester.get_emi(root_device_type='instance-store')
        self.ins= self.tester.run_image(image=self.emi, keypair=self.keypair, max=4, monitor_to_running=False, clean_on_fail=True)
        for i in self.ins:
            print 'killing instance: '+ str(i.id)
            i.terminate()
        print self.ins
예제 #13
0
class Euca6559(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        self.emi = self.tester.get_emi()
        self.new_emi = self.tester.register_manifest(self.emi.location)
        self.tester.deregister_image(self.new_emi);
        self.runSysCmd('euca-describe-images ' + self.new_emi.id);
        ### make sure that the images in the deregistered state are not output to user.
        if  str(self.out).count('deregistered') == 0 :
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAIL")
예제 #14
0
class EucaTest(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.STARTC = '\033[1m\033[1m\033[42m'
        self.ENDC = '\033[0m'
        self.cc = self.tester.service_manager.get_all_cluster_controllers()[3]
        self.orig_name = self.cc.name

    def tearDown(self):
        # deregister cluster
        self.runSysCmd(
            "/opt/eucalyptus/usr/sbin/euca_conf --deregister-cluster --partition "
            + self.cc.partition + " --host " + self.cc.hostname +
            " --component " + self.cc.name + '_TEST')
        # register cluster
        self.runSysCmd(
            "/opt/eucalyptus/usr/sbin/euca_conf --register-cluster --partition "
            + self.cc.partition + " --host " + self.cc.hostname +
            " --component " + self.orig_name)
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def test(self):
        # deregister cluster
        self.runSysCmd(
            "/opt/eucalyptus/usr/sbin/euca_conf --deregister-cluster --partition "
            + self.cc.partition + " --host " + self.cc.hostname +
            " --component " + self.cc.name)
        # register cluster
        self.runSysCmd(
            "/opt/eucalyptus/usr/sbin/euca_conf --register-cluster --partition "
            + self.cc.partition + " --host " + self.cc.hostname +
            " --component " + self.cc.name + '_TEST')
        # Sleep for 10 seconds while cluster Enables
        print self.STARTC + " Sleep for 10 seconds while cluster Enables. " + self.ENDC
        self.tester.sleep(10)
        # Make sure newly registered cluster with a different name is ENABLED
        try:
            check_cc = self.tester.service_manager.get_all_cluster_controllers(
                hostname=self.cc.hostname,
                state="ENABLED",
                use_cached_list=False)[0]
            print self.STARTC + "Success " + str(
                check_cc.name) + " ENABLED " + self.ENDC
            pass
        except Exception, e:
            self.fail("Renamed cluster not enabled!")
예제 #15
0
class ResourceGeneration(EutesterTestCase):
    
    def __init__(self, credpath):
        self.tester = Eucaops(credpath=credpath)


    def CreateResources(self):
        users = self.tester.get_all_users() 
        testers = []
        for user in users:
            keys = self.tester.create_access_key(user_name=user['user_name'], delegate_account=user['account_name'])
            testers.append(Eucaops(aws_access_key_id=keys['access_key_id'], aws_secret_access_key=keys['secret_access_key'], ec2_ip=self.tester.ec2.host, s3_ip=self.tester.s3.host))
            
        for tester in testers:
            import random
            zone = random.choice(tester.get_zones())
            volume = self.tester.create_volume(size=1, azone=zone)
            snapshot = self.tester.create_snapshot(volume_id=volume.id)
            volume_from_snap = self.tester.create_volume(snapshot=snapshot, azone=zone)
            bucket = self.tester.create_bucket(self.tester.id_generator(12, string.ascii_lowercase  + string.digits))
            key = self.tester.upload_object(bucket_name= bucket.name, key_name= self.tester.id_generator(12, string.ascii_lowercase  + string.digits), contents= self.tester.id_generator(200))
            keypair = self.tester.add_keypair(self.tester.id_generator())
            group = self.tester.add_group(self.tester.id_generator())
    
    def run_suite(self):  
        self.testlist = [] 
        testlist = self.testlist
        testlist.append(self.create_testcase_from_method(self.CreateResources))
        self.run_test_case_list(testlist)  
예제 #16
0
class MyTestCase(EutesterTestCase):
    def __init__(self, config_file=None, password=None):
        self.setuptestcase()
        # Setup basic eutester object
        self.tester = Eucaops( config_file=config_file, password=password)
        self.reservation = None
        ### Add and authorize a group for the instance
        self.group = self.tester.add_group(group_name="group-" + str(time.time()))
        self.tester.authorize_group_by_name(group_name=self.group.name )
        self.tester.authorize_group_by_name(group_name=self.group.name, port=-1, protocol="icmp" )

        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair( "keypair-" + str(time.time()))

        ### Get an image to work with
        self.image = self.tester.get_emi(root_device_type="instance-store")
        self.clean_method = self.cleanup

    def cleanup(self):
        if self.reservation:
            self.assertTrue(self.tester.terminate_instances(self.reservation), "Unable to terminate instance(s)")
        self.tester.delete_group(self.group)
        self.tester.delete_keypair(self.keypair)

    def MyTestUnit(self):
        """
        A test description must go here......
        This test will simply run an instance and check that it is reachable via ssh
        """
        self.reservation = self.tester.run_instance(self.image, keypair=self.keypair.name, group=self.group.name)
        for instance in self.reservation.instances:
            instance.sys("uname -r")
예제 #17
0
class Euca3933(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf"
        self.fakeId = "OOO000000000"
        self.cmdMod =  " euca-modify-image-attribute --launch-permission "       
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath)  
    
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testValidation(self):
        self.emi = self.tester.get_emi()
        # Try and add --launch-permission with a bad userId
        self.out = self.tester.sys(self.source + self.cmdMod + " -a " + self.fakeId + " " + self.emi.id)
        # Check output
        self.count = str(self.out).count("Not a valid accountId")
        if self.count==1:
            self.tester.debug("SUCCESS --launch-permission validation error thrown")
            pass
        else:
            self.fail("FAIL no error with bad userID")
        pass
예제 #18
0
class Euca4750(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        # Set modify the property with a null value
        self.runSysCmd("euca-modify-property -p www.httpproxyhost=")
        self.runSysCmd("euca-describe-properties")
        # Check euca-describe-properties output for property
        self.count = str(self.out).count("www.httpproxyhost")
        # reset property to original value
        self.runSysCmd("euca-modify-property -r www.httpproxyhost")
        if self.count == 1:
            self.tester.debug(
                "SUCCESS property with null value modified correctly")
            pass
        else:
            self.fail("FAIL value null value not modified correctly")
예제 #19
0
class Euca2198(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.OK = '\033[1m\033[37m\033[42m'
        self.ENDC = '\033[0m'


    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)


    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        self.runSysCmd('euca-describe-regions')
        if not str(self.out).count('Walrus'):
           print self.OK + str(self.out) + self.ENDC
        else : self.fail( 'Walrus listed in output')
예제 #20
0
class Euca2322(unittest.TestCase):
    def setUp(self):
        self.tester = Eucaops(config_file="cloud.conf", password="******")
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.sbin = self.tester.eucapath + "/usr/sbin/"
        self.cmd = "euca-modify-property -peuca=\'System.getProperty(\"file.encoding\")\'"
        self.doAuth()

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def tearDown(self):
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def testEncoding(self):
        #call euca-modify-property which in turn calls System.getProperty("file.encoding")
        prop_string = self.tester.sys(self.source + self.sbin + self.cmd)
        # parse out the  file.encoding value
        if (prop_string != []):
            value = str(prop_string[0]).split()[2]
        # compare the return values pass it is "UTF-8" fail otherwise
        if not cmp(value, "UTF-8"):
            self.tester.debug("Passed Euca2322 default file.encoding = " +
                              value)
            pass
        else:
            self.fail("Failed Euca2322 default file.encoding " + value +
                      " != UTF-8")
예제 #21
0
class Euca(unittest.TestCase):
    def setUp(self):
        self.conf = "../cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.STARTC = '\033[1m\033[1m\033[42m'
        self.ENDC = '\033[0m'
        self.account = "9959-account"
        self.groupname = "9959-group"
        self.username = "******"

    def tearDown(self):
        self.tester.delete_account(self.account, recursive=True)
        self.tester.sys('rm -rf role-describe-instances-principle.json')
        self.tester.sys('rm -rf role-trust.json')
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def test(self):
        # create account, group and user
        self.tester.create_account(account_name=self.account)
        self.tester.create_group(self.groupname, "/", self.account)
        self.tester.create_user(self.username, "/", self.account)
        self.tester.add_user_to_group(self.groupname, self.username,
                                      self.account)
        # copy json to clc
        self.clc_ip = str(self.tester.clc.hostname)
        os.system('scp role-describe-instances-principle.json root@' +
                  self.clc_ip + ':role-describe-instances-principle.json')
        os.system('scp role-trust.json root@' + self.clc_ip +
                  ':role-trust.json')
        # create user role
        self.runSysCmd(
            "euare-rolecreate -r describe-instances -f role-trust.json --region "
            + self.account + "-" + self.username)
        self.runSysCmd(
            "euare-roleuploadpolicy -r describe-instances -p describe-instances-policy -f role-describe-instances-principle.json  --region "
            + self.account + "-" + self.username)
        print self.STARTC + "Success " + str(
            self.out) + " ENABLED " + self.ENDC
        # Check to see that the error message was thrown and not the text from the json file.
        count = str(
            self.out).count("Policy document should not specify a principal.")
        if count > 0:
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAILED : correct error message not thrown")
예제 #22
0
class Euca4268(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.cond = 1
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runInstances(self):
        #Start instance
        self.reservation = self.tester.run_instance(keypair=self.keypair.name,
                                                    group=self.group,
                                                    min=2,
                                                    max=2,
                                                    is_reachable=False)
        # Make sure the instance is running
        self.count = 0
        for instance in self.reservation.instances:
            self.count += 1
            if instance.state == "running":
                if self.count == 1:
                    self.ip_one = instance.public_dns_name
                    self.instanceid_one = instance.id
                else:
                    self.ip_two = instance.public_dns_name
                    self.instanceid_two = instance.id

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)
        self.tester.authorize_group(self.group, port=-1, protocol="icmp")

    def testName(self):
        self.runInstances()
        self.tester.ping(self.ip_one, 1)
        self.tester.ping(self.ip_two, 1)
        #make sure instance is reachable
        self.cmd = 'euca-reboot-instances ' + self.instanceid_one + " " + self.instanceid_two
        self.runSysCmd(self.cmd)
        #wait for reboot
        self.tester.sleep(2)
        self.pingable1 = self.tester.ping(self.ip_one, 1)
        self.pingable2 = self.tester.ping(self.ip_two, 1)

        if self.pingable1 == False and self.pingable2 == False:
            self.tester.debug("SUCCESS both instances were rebooted")
            pass
        else:
            self.fail("FAIL both instances not rebooted")
예제 #23
0
class HAtests(InstanceBasics, BucketTestSuite):
    def __init__(self, config_file="cloud.conf", password="******"):
        self.tester = Eucaops(config_file=config_file, password=password)
        self.servman = self.tester.service_manager
        self.tester.poll_count = 120
        ### Add and authorize a group for the instance
        self.start_time = str(int(time.time()))
        self.group = self.tester.add_group(group_name="group-" +
                                           self.start_time)
        self.tester.authorize_group_by_name(group_name=self.group.name)
        self.tester.authorize_group_by_name(group_name=self.group.name,
                                            port=-1,
                                            protocol="icmp")
        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair("keypair-" + self.start_time)
        self.keypath = os.curdir + "/" + self.keypair.name + ".pem"
        self.image = self.tester.get_emi(root_device_type="instance-store")
        self.reservation = None
        self.private_addressing = False
        self.bucket_prefix = "buckettestsuite-" + self.start_time + "-"
        self.test_user_id = self.tester.s3.get_canonical_user_id()
        zones = self.tester.ec2.get_all_zones()
        self.zone = random.choice(zones).name

        ### Create standing resources that will be checked after all failures
        ### Instance, volume, buckets
        ###
        self.standing_reservation = self.tester.run_instance(
            keypair=self.keypair.name, group=self.group.name, zone=self.zone)
        self.volume = self.tester.create_volume(self.zone)
        self.device = self.standing_reservation.instances[0].attach_volume(
            self.volume)
        self.standing_bucket_name = "failover-bucket-" + self.start_time
        self.standing_bucket = self.tester.create_bucket(
            self.standing_bucket_name)
        self.standing_key_name = "failover-key-" + self.start_time
        self.standing_key = self.tester.upload_object(
            self.standing_bucket_name, self.standing_key_name)
        self.standing_key = self.tester.get_objects_by_prefix(
            self.standing_bucket_name, self.standing_key_name)

    def run_testcase(self, testcase_callback, **kwargs):
        poll_count = 20
        poll_interval = 20
        while (poll_count > 0):
            try:
                testcase_callback(**kwargs)
                break
            except Exception, e:
                self.tester.debug("Attempt failed due to: " + str(e) +
                                  "\nRetrying testcase in " +
                                  str(poll_interval))
            self.tester.sleep(poll_interval)
            poll_count = poll_count - 1
        if poll_count is 0:
            self.fail("Could not run an instance after " + str(poll_count) +
                      " tries with " + str(poll_interval) +
                      "s sleep in between")
예제 #24
0
class Euca3460(unittest.TestCase):
    
    def setUp(self):

        self.conf = "cloud.conf"       
        self.imgName = "windowsserver2003r2_ent_x64.kvm.img"
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.clc1 = self.tester.service_manager.get_enabled_clc() 
        self.iu = ImageUtils(tester=self.tester, config_file=self.conf )
        self.iu.create_emi_from_url( "http://192.168.7.65/windows_images/" + self.imgName )
        self.doAuth()
        
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)
        self.tester.authorize_group(self.group, port=3389, protocol="tcp")
        self.skey = self.tester.get_secret_key()
        self.akey = self.tester.get_access_key()
                   
    def test_EUCA_3460(self):      
        self.emi = self.tester.get_emi(location=self.imgName)
        #Start the windows instance
        self.reservation = self.tester.run_instance(self.emi,type="m1.large", keypair=self.keypair.name, group=self.group, is_reachable=False,timeout=720)
        # Make sure the windows instance is running
        
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.ip = instance.public_dns_name
                self.instanceid = instance.id
                                
        # Attempt to bundle the running windows instance
        print "Access  = " + self.akey 
        print "Secret  = " + self.skey 
        self.cmd = "euca-bundle-instance " + self.instanceid + " -b " + str(self.keypair) + " -p windows -o " + self.akey + " -w " + self.skey
        self.out = self.clc1.machine.cmd(self.source + self.cmd)
        
        # Check for Bundle ID
        match = re.search(r'bun-........', self.out["output"])
        if match:
            self.tester.debug("Passed test_EUCA_3460: Bundle ID = " + match.group())
        else: 
            self.fail("Failed test_EUCA_3460: Bundle ID not returned") 
         
                       
    def tearDown(self):
        if self.reservation is not None:
            self.tester.terminate_instances(self.reservation)  
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath)  
              
                 
    if __name__ == '__main__':
        unittest.main("Euca3460")
예제 #25
0
파일: Euca3456.py 프로젝트: aliceh/eutester
class Euca3456(unittest.TestCase):

    def setUp(self):
        #This bug is intermittent.
        #To reproduce this consistently I used 6 nodes 24 instances and 50 iterations
        #These can be adjusted, the more nodes and instances the quicker you will see the problem.
        #runInstances is run twice for a total of (2 * numIntances ) this done
        #to avoid out of resources error.
        self.numNodes = 6
        self.numIntances = 12
        self.numIterations = 1
        self.conf = "cloud.conf"       
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.doAuth()

    def tearDown(self):
        #self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath) 
         
    def runInstances(self, numMax):
        #Start instance
        self.reservation = self.tester.run_instance(keypair=self.keypair.name, group=self.group, min=0, max=numMax, is_reachable=False, timeout=480)
        # Make sure the instance is running       
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.ip = instance.public_dns_name
                self.instanceid = instance.id
                
    def runSysCmd(self, cmd):
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd) 
         
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testDescribeNodes(self):
        self.emi = self.tester.get_emi()
        self.runInstances(self.numIntances)
        #self.runInstances(self.numIntances)
        i = 0
        while i < self.numIterations :
            i += 1
            self.tester.debug("Running iteration " + str(i))
            self.runSysCmd("/opt/eucalyptus/usr/sbin/euca_conf --list-nodes")
            #count the returned nodes
            count = str(self.out).count("NODE")
            if count != self.numNodes :
                self.tester.debug("FAILURE only " + str(count) + " nodes listed.")
                self.fail("FAIL Incorrect number of nodes listed!")
            else :             
                self.tester.debug("SUCCESS " + str(count) + " nodes listed.")
                pass
예제 #26
0
파일: Euca4268.py 프로젝트: aliceh/eutester
class Euca4268(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf"       
        self.tester = Eucaops( config_file=self.conf, password="******" )
        self.cond = 1 
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath) 
         
    def runInstances(self):
        #Start instance
        self.reservation = self.tester.run_instance(keypair=self.keypair.name, group=self.group,min=2,max=2,is_reachable=False)
        # Make sure the instance is running       
        self.count = 0;
        for instance in self.reservation.instances:
            self.count += 1
            if instance.state == "running":
                if self.count == 1 :
                    self.ip_one = instance.public_dns_name
                    self.instanceid_one = instance.id
                else:
                    self.ip_two = instance.public_dns_name
                    self.instanceid_two = instance.id
                    
    def runSysCmd(self, cmd):
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd) 
         
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)
        self.tester.authorize_group(self.group, port=-1, protocol="icmp")

    def testName(self):
        self.runInstances()
        self.tester.ping(self.ip_one, 1)
        self.tester.ping(self.ip_two, 1)
        #make sure instance is reachable
        self.cmd = 'euca-reboot-instances ' + self.instanceid_one + " " + self.instanceid_two
        self.runSysCmd(self.cmd)
        #wait for reboot
        self.tester.sleep(2)
        self.pingable1 = self.tester.ping(self.ip_one, 1)
        self.pingable2 = self.tester.ping(self.ip_two, 1)
        
        if self.pingable1 == False and self.pingable2 == False :
            self.tester.debug("SUCCESS both instances were rebooted")
            pass
        else:
            self.fail("FAIL both instances not rebooted")
예제 #27
0
class HAtests(InstanceBasics, BucketTestSuite):
    def __init__(self):
        self.setuptestcase()
        self.setup_parser()
        self.get_args()
        self.tester = Eucaops(config_file=self.args.config_file,
                              password=self.args.password)
        self.servman = self.tester.service_manager
        self.tester.poll_count = 120
        ### Add and authorize a group for the instance
        self.start_time = str(int(time.time()))
        try:
            self.group = self.tester.add_group(group_name="group-" +
                                               self.start_time)
            self.tester.authorize_group_by_name(group_name=self.group.name)
            self.tester.authorize_group_by_name(group_name=self.group.name,
                                                port=-1,
                                                protocol="icmp")
            ### Generate a keypair for the instance
            self.keypair = self.tester.add_keypair("keypair-" +
                                                   self.start_time)
            self.keypath = os.curdir + "/" + self.keypair.name + ".pem"
            self.image = self.tester.get_emi(root_device_type="instance-store")
            self.reservation = None
            self.private_addressing = False
            self.bucket_prefix = "buckettestsuite-" + self.start_time + "-"
            self.test_user_id = self.tester.s3.get_canonical_user_id()
            zones = self.tester.ec2.get_all_zones()
            self.zone = random.choice(zones).name

            self.tester.clc = self.tester.service_manager.get_enabled_clc(
            ).machine
            self.version = self.tester.clc.sys(
                "cat " + self.tester.eucapath +
                "/etc/eucalyptus/eucalyptus-version")[0]
            ### Create standing resources that will be checked after all failures
            ### Instance, volume, buckets
            ###
            self.standing_reservation = self.tester.run_instance(
                keypair=self.keypair.name,
                group=self.group.name,
                zone=self.zone)
            self.volume = self.tester.create_volume(self.zone)
            self.device = self.standing_reservation.instances[0].attach_volume(
                self.volume)
            self.standing_bucket_name = "failover-bucket-" + self.start_time
            self.standing_bucket = self.tester.create_bucket(
                self.standing_bucket_name)
            self.standing_key_name = "failover-key-" + self.start_time
            self.standing_key = self.tester.upload_object(
                self.standing_bucket_name, self.standing_key_name)
            self.standing_key = self.tester.get_objects_by_prefix(
                self.standing_bucket_name, self.standing_key_name)
        except Exception, e:
            self.clean_method()
예제 #28
0
class InstanceBasics(unittest.TestCase):
    def setUp(self, credpath=None):
        # Setup basic eutester object
        if credpath is None:
            credpath = arg_credpath
        self.tester = Eucaops(credpath=credpath)
        self.tester.poll_count = 120

        ### Add and authorize a group for the instance
        self.group = self.tester.add_group(group_name="group-" +
                                           str(time.time()))
        self.tester.authorize_group_by_name(group_name=self.group.name)
        self.tester.authorize_group_by_name(group_name=self.group.name,
                                            port=-1,
                                            protocol="icmp")
        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair("keypair-" + str(time.time()))
        self.keypath = os.curdir + "/" + self.keypair.name + ".pem"
        self.image = self.tester.get_emi(root_device_type="instance-store")
        self.reservation = None
        self.private_addressing = False
        zones = self.tester.ec2.get_all_zones()
        self.zone = random.choice(zones).name

    def tearDown(self):
        if self.reservation is not None:
            self.assertTrue(self.tester.terminate_instances(self.reservation),
                            "Unable to terminate instance(s)")
        self.tester.delete_group(self.group)
        self.tester.delete_keypair(self.keypair)
        os.remove(self.keypath)
        self.reservation = None
        self.group = None
        self.keypair = None
        self.tester = None
        self.ephemeral = None

    def create_attach_volume(self, instance, size):
        self.volume = self.tester.create_volume(instance.placement, size)
        device_path = "/dev/" + instance.block_device_prefix + "j"
        before_attach = instance.get_dev_dir()
        try:
            self.assertTrue(
                self.tester.attach_volume(instance, self.volume, device_path),
                "Failure attaching volume")
        except AssertionError, e:
            self.assertTrue(self.tester.delete_volume(self.volume))
            return False
        after_attach = instance.get_dev_dir()
        new_devices = self.tester.diff(after_attach, before_attach)
        if len(new_devices) is 0:
            return False
        self.volume_device = "/dev/" + new_devices[0].strip()
        instance.assertFilePresent(self.volume_device)
        return True
예제 #29
0
class Euca3949(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.cond = 1
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.clc1 = self.tester.service_manager.get_enabled_clc()
        self.IP = self.tester.get_ec2_ip()

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runInstances(self, numMax):
        #Start instance
        self.reservation = self.tester.run_instance(keypair=self.keypair.name,
                                                    group=self.group,
                                                    min=1,
                                                    max=numMax,
                                                    is_reachable=False)
        # Make sure the instance is running
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.instance = instance

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def check_for_error_msg(self, error):
        self.logFile = self.tester.eucapath + "/var/log/eucalyptus/cloud-output.log"
        if self.clc1.machine.found(" grep " + error + " " + self.logFile,
                                   error):
            self.fail("FAILURE! PersistentObjectException error thrown.")
        else:
            self.tester.debug("SUCCESS! No confusing error logged!")

    def testName(self):
        self.emi = self.tester.get_emi()
        self.runInstances(1)
        self.tester.terminate_single_instance(self.instance)
        self.runSysCmd("euca-describe-instances")
        #check log file to see if PersistentObjectException error was thrown
        self.check_for_error_msg("PersistentObjectException")

        pass
예제 #30
0
class InstanceBasics(unittest.TestCase):
    def setUp(self):
        # Setup basic eutester object
        eucarc_regex = re.compile("eucarc-")
        eucarc_dirs = [path for path in os.listdir(".") if eucarc_regex.search(path)]
        eucarc_path = None
        if len(eucarc_dirs) > 0:
            eucarc_path = eucarc_dirs[0]
        self.tester = Eucaops( config_file="../input/2b_tested.lst", password="******", credpath=eucarc_path)
        self.tester.poll_count = 120
        
        ### Add and authorize a group for the instance
        self.group = self.tester.add_group(group_name="group-" + str(time.time()))
        self.tester.authorize_group_by_name(group_name=self.group.name )
        self.tester.authorize_group_by_name(group_name=self.group.name, port=-1, protocol="icmp" )
        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair( "keypair-" + str(time.time()))
        self.keypath = os.curdir + "/" + self.keypair.name + ".pem"
        self.image = self.tester.get_emi(root_device_type="instance-store")
        self.reservation = None
        self.private_addressing = False
        zones = self.tester.ec2.get_all_zones()
        self.zone = random.choice(zones).name

    
    def tearDown(self):
        if self.reservation is not None:
            self.assertTrue(self.tester.terminate_instances(self.reservation), "Unable to terminate instance(s)")
        self.tester.delete_group(self.group)
        self.tester.delete_keypair(self.keypair)
        os.remove(self.keypath)
        self.reservation = None
        self.group = None
        self.keypair = None
        self.tester = None
        self.ephemeral = None
        
    def create_attach_volume(self, instance, size):
            self.volume = self.tester.create_volume(instance.placement, size)
            device_path = "/dev/" + instance.block_device_prefix  +"j"
            before_attach = instance.get_dev_dir()
            try:
                self.assertTrue(self.tester.attach_volume(instance, self.volume, device_path), "Failure attaching volume")
            except AssertionError, e:
                self.assertTrue( self.tester.delete_volume(self.volume))
                return False
            after_attach = instance.get_dev_dir()
            new_devices = self.tester.diff(after_attach, before_attach)
            if len(new_devices) is 0:
                return False
            self.volume_device = "/dev/" + new_devices[0].strip()
            instance.assertFilePresent(self.volume_device)
            return True
예제 #31
0
파일: ha.py 프로젝트: aliceh/eutester
class HAtests(InstanceBasics, BucketTestSuite):
    def __init__(self):
        self.setuptestcase()
        self.setup_parser()
        self.get_args()
        if not boto.config.has_section('Boto'):
            boto.config.add_section('Boto')
            boto.config.set('Boto', 'num_retries', '1')
            boto.config.set('Boto', 'http_socket_timeout', '20')
        self.tester = Eucaops( config_file=self.args.config_file, password=self.args.password)
        self.tester.ec2.connection.timeout = 30
        self.servman = self.tester.service_manager
        self.instance_timeout = 120
        ### Add and authorize a group for the instance
        self.start_time = str(int(time.time()))
        try:
            self.group = self.tester.add_group(group_name="group-" + self.start_time )
            self.tester.authorize_group_by_name(group_name=self.group.name )
            self.tester.authorize_group_by_name(group_name=self.group.name, port=-1, protocol="icmp" )
            ### Generate a keypair for the instance
            self.keypair = self.tester.add_keypair( "keypair-" + self.start_time)
            self.keypath = os.curdir + "/" + self.keypair.name + ".pem"
            if self.args.emi:
                self.image = self.tester.get_emi(self.args.emi)
            else:
                self.image = self.tester.get_emi(root_device_type="instance-store")
            self.reservation = None
            self.private_addressing = False
            self.bucket_prefix = "buckettestsuite-" + self.start_time + "-"
            self.test_user_id = self.tester.s3.get_canonical_user_id()
            zones = self.tester.ec2.get_all_zones()
            self.zone = random.choice(zones).name

            self.tester.clc = self.tester.service_manager.get_enabled_clc().machine
            self.version = self.tester.clc.sys("cat " + self.tester.eucapath + "/etc/eucalyptus/eucalyptus-version")[0]
            ### Create standing resources that will be checked after all failures
            ### Instance, volume, buckets
            ###
            self.standing_reservation = self.tester.run_instance(image=self.image ,keypair=self.keypair.name,group=self.group.name, zone=self.zone)
            self.volume = self.tester.create_volume(self.zone)
            self.device = self.standing_reservation.instances[0].attach_volume(self.volume)
            for instance in self.standing_reservation.instances:
                instance.sys("echo " + instance.id  + " > " + self.device)
            self.standing_bucket_name = "failover-bucket-" + self.start_time
            self.standing_bucket = self.tester.create_bucket(self.standing_bucket_name)
            self.standing_key_name = "failover-key-" + self.start_time
            self.standing_key = self.tester.upload_object(self.standing_bucket_name, self.standing_key_name)
            self.standing_key = self.tester.get_objects_by_prefix(self.standing_bucket_name, self.standing_key_name)
            self.run_instance_params = {'image': self.image, 'keypair': self.keypair.name, 'group': self.group.name,
                                        'zone': self.zone, 'timeout': self.instance_timeout}
        except Exception, e:
            self.clean_method()
            raise Exception("Init for testcase failed. Reason: " + str(e))
예제 #32
0
class InstanceRestore(EutesterTestCase):
    def __init__(self):
        self.setuptestcase()
        self.setup_parser()
        self.get_args()
        # Setup basic eutester object
        self.tester = Eucaops(config_file=self.args.config_file,
                              password=self.args.password)
        self.tester.poll_count = 120

        ### Add and authorize a group for the instance
        self.group = self.tester.add_group(group_name="group-" +
                                           str(time.time()))
        self.tester.authorize_group_by_name(group_name=self.group.name)
        self.tester.authorize_group_by_name(group_name=self.group.name,
                                            port=-1,
                                            protocol="icmp")
        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair("keypair-" + str(time.time()))
        self.keypath = '%s/%s.pem' % (os.curdir, self.keypair.name)
        self.image = self.tester.get_emi(root_device_type="instance-store")
        self.reservation = None
        self.private_addressing = False
        zones = self.tester.ec2.get_all_zones()
        self.zone = random.choice(zones).name
        clcs = self.tester.get_component_machines("clc")
        if len(clcs) is 0:
            raise Exception("No CLC found")
        else:
            self.clc = clcs[0]
        self.cur_time = str(int(time.time()))
        self.ncs = self.tester.get_component_machines("nc")

    def clean_method(self):
        ncs = self.tester.get_component_machines("nc")
        for nc in ncs:
            nc.sys("service eucalyptus-nc start")

        ### RESET vmstate properties
        self.tester.modify_property("cloud.vmstate.instance_timeout", "60")
        self.tester.modify_property("cloud.vmstate.terminated_time", "60")
        for nc in self.ncs:
            nc.sys("service eucalyptus-nc start")
        self.tester.cleanup_artifacts()
        try:
            image = self.tester.get_emi(self.image)
        except Exception, e:
            self.tester.register_image(
                image_location=self.image.location,
                ramdisk=self.image.ramdisk_id,
                kernel=self.image.kernel_id,
                virtualization_type=self.image.virtualization_type)
예제 #33
0
class InstanceBasicsTest(EutesterTestCase):
    def __init__(self):
        #### Pre-conditions
        self.setuptestcase()
        self.setup_parser()
        self.parser.add_argument("--test-zone", default="PARTI00")
        self.parser.add_argument("--test-emi", default=None)
        self.parser.add_argument("--build-number", default='')
        self.get_args()

        # Setup basic eutester object
        if not self.args.credpath:
            self.tester = Eucaops(config_file=self.args.config,
                                  password=self.args.password)
        else:
            self.tester = Eucaops(credpath=self.args.credpath)
        self.reservation = None

        ### Generate a group for the instance
        self.group = self.tester.add_group(
            group_name="inst-kvm-grp-" + str(time.time()).replace(".", "") +
            self.tester.id_generator() + "-" + self.args.build_number)
        self.tester.authorize_group_by_name(group_name=self.group.name)
        self.tester.authorize_group_by_name(group_name=self.group.name,
                                            port=-1,
                                            protocol="icmp")

        self.keypair = self.tester.add_keypair(
            "inst-kvm-" + str(time.time()).replace(".", "") +
            self.tester.id_generator() + "-" + self.args.build_number)

        if not self.args.emi:
            self.image = self.tester.get_emi(root_device_type="instance-store")
        else:
            self.image = self.tester.get_emi(self.args.test_emi)

    def clean_method(self):
        """
        Description: Attempts to clean up resources created in this test
        """
        self.tester.cleanup_artifacts()

    def stress_instance_test(self):
        self.reservation = self.tester.run_image(self.image,
                                                 zone=self.args.test_zone,
                                                 min=1,
                                                 max=1,
                                                 keypair=self.keypair.name,
                                                 group=self.group,
                                                 timeout=600)
예제 #34
0
class Euca2264(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()

    def tearDown(self):
        self.runSysCmd("euca-terminate-instances " + self.instanceid)
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        # Save command output in self.out
        self.out = self.tester.sys(self.source + cmd)

    def testName(self):
        self.emi = self.tester.get_emi()
        # start instances with multiple block devices
        self.runSysCmd("euca-run-instances " + self.emi.id +
                       " -b /dev/sda2=:20 -b /dev/sda3=:20")
        # Search for error message
        self.count = str(self.out).count("412 Precondition Failed:")
        # Get instance id
        self.index = str(self.out).find("i-")
        self.instanceid = str(self.out)[self.index:self.index + 10]
        # if error not found pass else fail
        if self.count == 0:
            self.index = str(self.out).find("i-")
            self.instanceid = str(self.out)[self.index:self.index + 10]
            self.time = 0
            #Wait for instance to start
            while (self.count != 1 and self.time < 60):
                self.tester.sleep(5)
                self.time = self.time + 5
                self.runSysCmd("euca-describe-instances " + self.instanceid)
                self.count = str(self.out).count('running')
                self.tester.debug("Elapsed time " + str(self.time) +
                                  " seconds.")
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAIL 412 Precondition Failed:")
예제 #35
0
class Euca5338(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.startDate = date.today()
        self.endDate = date.today() + timedelta(days=1)
        self.dates = "-s " + str(self.startDate) + " -e " + str(self.endDate)
        self.cmd = "eureport-generate-report " + self.dates + " --time-unit=seconds --format=csv -t volume"
        self.source = "source " + self.tester.credpath + "/eucarc && "

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        # Get availibility zone
        self.zone = self.tester.get_zones().pop()
        # Create and delete a volume
        self.volume = self.tester.create_volume(self.zone)
        self.tester.delete_volume(self.volume)
        # run report, save output and wait 10 seconds
        self.out1 = self.tester.sys(self.source + self.cmd)
        self.tester.sleep(10)
        # run report again
        self.out2 = self.tester.sys(self.source + self.cmd)
        # Get the string index for the volume specific information from the report
        self.index = str(self.out1).find(self.volume.id)
        # get the newly created/deleted volume information from the two reports
        self.volStringOne = str(self.out1)[self.index:self.index + 21]
        self.volStringTwo = str(self.out2)[self.index:self.index + 21]

        # Compare strings to make sure the GB-Secs is not increasing for the deleted volume.
        self.tester.debug("Report 1 = " + self.volStringOne + "  Report 2 = " +
                          self.volStringTwo)
        if self.volStringOne == self.volStringTwo:
            self.tester.debug(
                "SUCCESS the GB-Secs did not increase for deleted volume " +
                self.volume.id)
            pass
        else:
            self.fail("FAIL GB-Secs increased for deleted volume " +
                      self.volume.id)
예제 #36
0
class Euca4128(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud2.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.cond = 1
        self.doAuth()

    def tearDown(self):
        #self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runInstances(self):
        #Start instance
        self.reservation = self.tester.run_instance(keypair=self.keypair.name,
                                                    group=self.group,
                                                    min=4,
                                                    max=4,
                                                    is_reachable=False)
        # Make sure the instance is running
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.ip = instance.public_dns_name
                self.instanceid = instance.id

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        #self.emi = self.tester.get_emi()
        #self.zone = self.tester.get_zones().pop()
        #self.runInstances()
        #self.tester.create_volumes(self.zone, count=85)
        self.total = 0
        i = 0
        while i < 10:
            i += 1
            self.startTime = time.time()
            self.runSysCmd("euca-describe-volumes")
            self.time = time.time() - self.startTime
            self.total += self.time

        print self.total / 10
예제 #37
0
class Euca(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.OK = '\033[1m\033[37m\033[42m'
        self.ENDC = '\033[0m'

    def tearDown(self):
        self.runSysCmd(
            'euca-modify-property --property-to-reset authentication.ldap_integration_configuration'
        )
        self.tester.delete_account('account-euca5876', recursive=True)
        self.tester.sys('rm -rf euca5876.lic')
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runSysCmd(self, cmd):
        self.source = 'export EUCALYPTUS=' + self.tester.eucapath + " && source " + self.tester.credpath + "/eucarc && " + self.tester.eucapath + "/usr/sbin/"
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def test(self):
        self.clc_ip = str(self.tester.clc.hostname)
        os.system('scp euca5876.lic root@' + self.clc_ip + ':euca5876.lic')
        self.runSysCmd(
            'euca-modify-property --property-to-reset authentication.ldap_integration_configuration'
        )
        self.runSysCmd(
            'euca-lictool --password password --custom euca5876.lic --out euca5876.lic --nocomment'
        )
        self.runSysCmd(
            'euca-modify-property -f authentication.ldap_integration_configuration=euca5876.lic'
        )
        # Wait for LDAP to sync
        self.tester.sleep(20)
        # Count the numbers of users in the euca5876 group and make sure it is over 100
        self.out = str(
            self.tester.sys(
                'euare-grouplistusers -g euca5876 --as-account account-euca5876'
            )).count('arn:aws:iam::')
        print self.OK + 'Number of users created = ' + str(
            self.out) + self.ENDC
        assert self.out > 100
예제 #38
0
파일: Euca2264.py 프로젝트: aliceh/eutester
class Euca2264(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf"   
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.doAuth()

    def tearDown(self):
        self.runSysCmd("euca-terminate-instances " + self.instanceid)
        self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath)  
    
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)
        
    def runSysCmd(self, cmd):
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        # Save command output in self.out
        self.out = self.tester.sys(self.source + cmd)
         

    def testName(self):
        self.emi = self.tester.get_emi()
        # start instances with multiple block devices
        self.runSysCmd("euca-run-instances " + self.emi.id + " -b /dev/sda2=:20 -b /dev/sda3=:20")
        # Search for error message
        self.count = str(self.out).count("412 Precondition Failed:")
        # Get instance id
        self.index = str(self.out).find("i-")
        self.instanceid = str(self.out)[self.index:self.index + 10]
        # if error not found pass else fail
        if self.count == 0 :
            self.index = str(self.out).find("i-")
            self.instanceid = str(self.out)[self.index:self.index + 10]
            self.time = 0
            #Wait for instance to start
            while(self.count != 1 and self.time < 60):
                self.tester.sleep(5)
                self.time = self.time + 5
                self.runSysCmd("euca-describe-instances " + self.instanceid)
                self.count = str(self.out).count('running') 
                self.tester.debug("Elapsed time " + str(self.time) + " seconds.")        
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAIL 412 Precondition Failed:")
예제 #39
0
파일: ha.py 프로젝트: kedwards3/eutester
class HAtests(InstanceBasics, BucketTestSuite):
    def __init__(self, config_file="cloud.conf", password="******"):
        self.tester = Eucaops( config_file=config_file, password=password)
        self.servman = self.tester.service_manager
        self.tester.poll_count = 120
        ### Add and authorize a group for the instance
        self.start_time = str(int(time.time()))
        self.group = self.tester.add_group(group_name="group-" + self.start_time )
        self.tester.authorize_group_by_name(group_name=self.group.name )
        self.tester.authorize_group_by_name(group_name=self.group.name, port=-1, protocol="icmp" )
        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair( "keypair-" + self.start_time)
        self.keypath = os.curdir + "/" + self.keypair.name + ".pem"
        self.image = self.tester.get_emi(root_device_type="instance-store")
        self.reservation = None
        self.private_addressing = False
        self.bucket_prefix = "buckettestsuite-" + self.start_time + "-"
        self.test_user_id = self.tester.s3.get_canonical_user_id()
        zones = self.tester.ec2.get_all_zones()
        self.zone = random.choice(zones).name
        
        
        ### Create standing resources that will be checked after all failures
        ### Instance, volume, buckets
        ### 
        self.standing_reservation = self.tester.run_instance(keypair=self.keypair.name,group=self.group.name, zone=self.zone)
        self.volume = self.tester.create_volume(self.zone)
        self.device = self.standing_reservation.instances[0].attach_volume(self.volume)
        self.standing_bucket_name = "failover-bucket-" + self.start_time
        self.standing_bucket = self.tester.create_bucket(self.standing_bucket_name)
        self.standing_key_name = "failover-key-" + self.start_time
        self.standing_key = self.tester.upload_object(self.standing_bucket_name, self.standing_key_name)
        self.standing_key = self.tester.get_objects_by_prefix(self.standing_bucket_name, self.standing_key_name)
        

        
            
    def run_testcase(self, testcase_callback, **kwargs):
        poll_count = 20
        poll_interval = 20       
        while (poll_count > 0):
            try:
                testcase_callback(**kwargs)
                break
            except Exception, e:
                self.tester.debug("Attempt failed due to: " + str(e)  + "\nRetrying testcase in " + str(poll_interval) )
            self.tester.sleep(poll_interval)     
            poll_count = poll_count - 1  
        if poll_count is 0:
            self.fail("Could not run an instance after " + str(poll_count) +" tries with " + str(poll_interval) + "s sleep in between")
예제 #40
0
class EucaTest(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.OK = '\033[1m\033[37m\033[42m'
        self.ENDC = '\033[0m'

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.modify_property('bootstrap.webservices.use_instance_dns',
                                    'false')
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runInstances(self, numMax):
        self.emi = self.tester.get_emi(root_device_type='ebs')
        #Start instance
        self.reservation = self.tester.run_instance(self.emi,
                                                    keypair=self.keypair.name,
                                                    group=self.group,
                                                    min=1,
                                                    max=numMax,
                                                    is_reachable=False)
        # Make sure the instance is running
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.ip = instance.public_dns_name
                self.instanceid = instance.id

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def test(self):
        self.tester.modify_property('bootstrap.webservices.use_instance_dns',
                                    'true')
        self.runInstances(1)
        self.tester.stop_instances(self.reservation)
        self.runSysCmd('euca-describe-instances ' + self.instanceid)
        # make sure publicdnsname and privatednsname fields are empty in euca-descibe-instances output
        assert str(self.out).count('eucalyptus.internal') == 0
        assert str(self.out).count('eucalyptus.localhost') == 0
        print self.OK + 'SUCCESS: publicdns and privatedns fields are empty in euca-descibe-instances output' + self.ENDC
예제 #41
0
class Euca(unittest.TestCase):
    def setUp(self):
        self.conf = "../cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.STARTC = '\033[1m\033[1m\033[42m'
        self.ENDC = '\033[0m'
        self.account = "9959-account"
        self.groupname = "9959-group"
        self.username ="******"

    def tearDown(self):
        self.tester.delete_account(self.account, recursive=True)
        self.tester.sys('rm -rf role-describe-instances-principle.json')
        self.tester.sys('rm -rf role-trust.json')
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def test(self):
        # create account, group and user
        self.tester.create_account(account_name=self.account)
        self.tester.create_group(self.groupname, "/", self.account)
        self.tester.create_user(self.username, "/", self.account)
        self.tester.add_user_to_group(self.groupname,self.username,self.account)
        # copy json to clc
        self.clc_ip = str(self.tester.clc.hostname)
        os.system('scp role-describe-instances-principle.json root@' + self.clc_ip + ':role-describe-instances-principle.json')
        os.system('scp role-trust.json root@' + self.clc_ip + ':role-trust.json')
        # create user role
        self.runSysCmd("euare-rolecreate -r describe-instances -f role-trust.json --region " + self.account + "-" + self.username)
        self.runSysCmd("euare-roleuploadpolicy -r describe-instances -p describe-instances-policy -f role-describe-instances-principle.json  --region " + self.account + "-" + self.username)
        print self.STARTC + "Success " + str(self.out) + " ENABLED " + self.ENDC
        # Check to see that the error message was thrown and not the text from the json file.
        count = str(self.out).count("Policy document should not specify a principal.")
        if count > 0 :
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAILED : correct error message not thrown")
예제 #42
0
class Euca2184(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testOutput(self):
        # Get the existing EBS emi
        self.emi = self.tester.get_emi(root_device_type='ebs')
        # Start instance
        self.reservation = self.tester.run_instance(self.emi,
                                                    keypair=self.keypair.name,
                                                    group=self.group,
                                                    is_reachable=False)
        # Make sure the instance is running set instance variables
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.dns = instance.public_dns_name
                self.pub_ip = instance.ip_address
                self.priv_ip = instance.private_ip_address

        # Stop Instance
        self.tester.stop_instances(self.reservation)
        for instance in self.reservation.instances:
            if instance.state == "stopped":
                self.instance = instance
                self.pub_ip = instance.ip_address
                self.priv_ip = instance.private_ip_address

        self.tester.debug("Public  IP = " + self.pub_ip)
        self.tester.debug("Private IP = " + self.priv_ip)

        # Check Ip address to make sure they are empty
        if (len(self.pub_ip) == 0 and len(self.priv_ip) == 0):
            self.tester.debug("Success ips are empty.")
            pass
        else:
            self.fail("Fail ip addresses still displayed.")
예제 #43
0
class EucaTest(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.STARTC = '\033[1m\033[1m\033[42m'
        self.ENDC = '\033[0m'
        self.cc= self.tester.service_manager.get_all_cluster_controllers()[3]
        self.orig_name = self.cc.name

    def tearDown(self):
        # deregister cluster
        self.runSysCmd("/opt/eucalyptus/usr/sbin/euca_conf --deregister-cluster --partition "
                       + self.cc.partition + " --host " +  self.cc.hostname + " --component " + self.cc.name + '_TEST' )
        # register cluster
        self.runSysCmd("/opt/eucalyptus/usr/sbin/euca_conf --register-cluster --partition "
                       + self.cc.partition + " --host " +  self.cc.hostname + " --component " + self.orig_name)
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runSysCmd(self, cmd):
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def test(self):
        # deregister cluster
        self.runSysCmd("/opt/eucalyptus/usr/sbin/euca_conf --deregister-cluster --partition "
                       + self.cc.partition + " --host " +  self.cc.hostname + " --component " + self.cc.name)
        # register cluster
        self.runSysCmd("/opt/eucalyptus/usr/sbin/euca_conf --register-cluster --partition "
                       + self.cc.partition + " --host " +  self.cc.hostname + " --component " + self.cc.name + '_TEST' )
        # Sleep for 10 seconds while cluster Enables
        print self.STARTC +  " Sleep for 10 seconds while cluster Enables. " + self.ENDC
        self.tester.sleep(10)
        # Make sure newly registered cluster with a different name is ENABLED
        try :
            check_cc = self.tester.service_manager.get_all_cluster_controllers(hostname=self.cc.hostname,
                     state="ENABLED", use_cached_list=False)[0]
            print self.STARTC + "Success " + str(check_cc.name) + " ENABLED " + self.ENDC
            pass
        except Exception, e:
            self.fail("Renamed cluster not enabled!")
예제 #44
0
파일: Euca3949.py 프로젝트: aliceh/eutester
class Euca3949(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf" 
        self.cond = 1     
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.doAuth()
        self.clc1 = self.tester.service_manager.get_enabled_clc()
        self.IP = self.tester.get_ec2_ip()

    def tearDown(self):
        self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath) 
         
    def runInstances(self, numMax):
        #Start instance
        self.reservation = self.tester.run_instance(keypair=self.keypair.name, group=self.group, min=1, max=numMax, is_reachable=False)
        # Make sure the instance is running       
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.instance = instance
                
    def runSysCmd(self, cmd):
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd) 
         
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)
        
    def check_for_error_msg(self, error):
        self.logFile = self.tester.eucapath + "/var/log/eucalyptus/cloud-output.log"
        if self.clc1.machine.found(" grep " + error + " " + self.logFile, error) :
            self.fail("FAILURE! PersistentObjectException error thrown.")
        else : self.tester.debug("SUCCESS! No confusing error logged!")

    def testName(self):
        self.emi = self.tester.get_emi()
        self.runInstances(1)
        self.tester.terminate_single_instance(self.instance)
        self.runSysCmd("euca-describe-instances")
        #check log file to see if PersistentObjectException error was thrown
        self.check_for_error_msg("PersistentObjectException")

        pass
예제 #45
0
파일: Euca5338.py 프로젝트: aliceh/eutester
class Euca5338(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf" 
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.doAuth()
        self.startDate = date.today()
        self.endDate = date.today() + timedelta(days=1)
        self.dates  = "-s " + str(self.startDate) +  " -e " + str(self.endDate)
        self.cmd = "eureport-generate-report " + self.dates + " --time-unit=seconds --format=csv -t volume"
        self.source  = "source " + self.tester.credpath + "/eucarc && "

    def tearDown(self):
        self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath) 
        
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        # Get availibility zone
        self.zone = self.tester.get_zones().pop()
        # Create and delete a volume
        self.volume = self.tester.create_volume(self.zone)
        self.tester.delete_volume(self.volume)
        # run report, save output and wait 10 seconds
        self.out1 = self.tester.sys(self.source + self.cmd)
        self.tester.sleep(10)
        # run report again
        self.out2 = self.tester.sys(self.source + self.cmd)
        # Get the string index for the volume specific information from the report
        self.index = str(self.out1).find(self.volume.id)
        # get the newly created/deleted volume information from the two reports
        self.volStringOne = str(self.out1)[self.index:self.index + 21]
        self.volStringTwo = str(self.out2)[self.index:self.index + 21]
        
        # Compare strings to make sure the GB-Secs is not increasing for the deleted volume.
        self.tester.debug("Report 1 = " + self.volStringOne + "  Report 2 = " + self.volStringTwo)
        if self.volStringOne == self.volStringTwo :
            self.tester.debug("SUCCESS the GB-Secs did not increase for deleted volume " + self.volume.id)
            pass
        else:
            self.fail("FAIL GB-Secs increased for deleted volume " + self.volume.id)
예제 #46
0
class Euca2185(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.clc1 = self.tester.service_manager.get_enabled_clc()
        # Enable DNS
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.sbin = self.tester.eucapath + "/usr/sbin/"
        self.cmd = "euca-modify-property -p bootstrap.webservices.use_instance_dns="
        self.tester.sys(self.source + self.sbin + self.cmd + "true")
        self.doAuth()

    def tearDown(self):
        # Restore default dns
        self.tester.sys(self.source + self.sbin + self.cmd + "false")
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):

        self.emi = self.tester.get_emi()
        # Start instance
        self.reservation = self.tester.run_instance(keypair=self.keypair.name,
                                                    group=self.group,
                                                    is_reachable=False)
        # Make sure the instance is running
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.dns = instance.public_dns_name
                self.instanceid = instance.id

        self.out = self.tester.sys(self.source + "euca-describe-instances " +
                                   self.instanceid)
        # Count the number of times the public dns is in the return string
        self.count = str(self.out).count(str(self.dns))
        # The public dns name should only be listed once with the fix not twice
        if self.count == 1:
            pass
        else:
            self.fail(" euca-describe-instances instance ip=" + self.dns)
예제 #47
0
파일: Euca4128.py 프로젝트: aliceh/eutester
class Euca4128(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud2.conf"       
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.cond = 1 
        self.doAuth()

    def tearDown(self):
        #self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath) 
         
    def runInstances(self):
        #Start instance
        self.reservation = self.tester.run_instance(keypair=self.keypair.name, group=self.group, min=4, max=4, is_reachable=False)
        # Make sure the instance is running       
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.ip = instance.public_dns_name
                self.instanceid = instance.id
                
    def runSysCmd(self, cmd):
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.out = self.tester.sys(self.source + cmd) 
         
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):
        #self.emi = self.tester.get_emi()
        #self.zone = self.tester.get_zones().pop()
        #self.runInstances()
        #self.tester.create_volumes(self.zone, count=85)
        self.total = 0
        i = 0
        while i < 10 :
            i += 1
            self.startTime = time.time()
            self.runSysCmd("euca-describe-volumes")
            self.time = time.time() - self.startTime
            self.total += self.time
            
        print self.total / 10
예제 #48
0
class InstanceRestore(EutesterTestCase):
    def __init__(self):
        self.setuptestcase()
        self.setup_parser()
        self.get_args()
        # Setup basic eutester object
        self.tester = Eucaops( config_file=self.args.config_file, password=self.args.password)
        self.tester.poll_count = 120

        ### Add and authorize a group for the instance
        self.group = self.tester.add_group(group_name="group-" + str(time.time()))
        self.tester.authorize_group_by_name(group_name=self.group.name )
        self.tester.authorize_group_by_name(group_name=self.group.name, port=-1, protocol="icmp" )
        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair( "keypair-" + str(time.time()))
        self.keypath = '%s/%s.pem' % (os.curdir, self.keypair.name)
        self.image = self.tester.get_emi(root_device_type="instance-store")
        self.reservation = None
        self.private_addressing = False
        zones = self.tester.ec2.get_all_zones()
        self.zone = random.choice(zones).name
        clcs = self.tester.get_component_machines("clc")
        if len(clcs) is 0:
            raise Exception("No CLC found")
        else:
            self.clc = clcs[0]
        self.cur_time = str(int(time.time()))
        self.ncs = self.tester.get_component_machines("nc")

    def clean_method(self):
        ncs = self.tester.get_component_machines("nc")
        for nc in ncs:
            nc.sys("service eucalyptus-nc start")

        ### RESET vmstate properties
        self.tester.modify_property("cloud.vmstate.instance_timeout","60")
        self.tester.modify_property("cloud.vmstate.terminated_time","60")
        for nc in self.ncs:
            nc.sys("service eucalyptus-nc start")
        self.tester.cleanup_artifacts()
        try:
            image = self.tester.get_emi(self.image)
        except Exception,e:
            self.tester.register_image(image_location=self.image.location,
                                       ramdisk=self.image.ramdisk_id,
                                       kernel=self.image.kernel_id,
                                       virtualization_type=self.image.virtualization_type)
예제 #49
0
파일: Euca2184.py 프로젝트: aliceh/eutester
class Euca2184(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf"      
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.doAuth()
       
    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath)
        
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)
        
    def testOutput(self):
        # Get the existing EBS emi 
        self.emi = self.tester.get_emi(root_device_type='ebs')
        # Start instance
        self.reservation = self.tester.run_instance(self.emi, keypair=self.keypair.name, group=self.group, is_reachable=False)
        # Make sure the instance is running set instance variables
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.dns = instance.public_dns_name
                self.pub_ip = instance.ip_address
                self.priv_ip = instance.private_ip_address                
        
        # Stop Instance       
        self.tester.stop_instances(self.reservation)
        for instance in self.reservation.instances:
            if instance.state == "stopped":
                self.instance = instance
                self.pub_ip = instance.ip_address
                self.priv_ip = instance.private_ip_address
                
        self.tester.debug("Public  IP = " +  self.pub_ip)
        self.tester.debug("Private IP = " +  self.priv_ip)
        
        # Check Ip address to make sure they are empty
        if(len(self.pub_ip) == 0 and len(self.priv_ip) == 0):
            self.tester.debug("Success ips are empty.")
            pass
        else:
            self.fail("Fail ip addresses still displayed.")
예제 #50
0
class Euca2185(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.clc1 = self.tester.service_manager.get_enabled_clc()
        # Enable DNS
        self.source = "source " + self.tester.credpath + "/eucarc && "
        self.sbin = self.tester.eucapath + "/usr/sbin/"
        self.cmd = "euca-modify-property -p bootstrap.webservices.use_instance_dns="
        self.tester.sys(self.source + self.sbin + self.cmd + "true")
        self.doAuth()

    def tearDown(self):
        # Restore default dns
        self.tester.sys(self.source + self.sbin + self.cmd + "false")
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def testName(self):

        self.emi = self.tester.get_emi()
        # Start instance
        self.reservation = self.tester.run_instance(keypair=self.keypair.name, group=self.group, is_reachable=False)
        # Make sure the instance is running
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.dns = instance.public_dns_name
                self.instanceid = instance.id

        self.out = self.tester.sys(self.source + "euca-describe-instances " + self.instanceid)
        # Count the number of times the public dns is in the return string
        self.count = str(self.out).count(str(self.dns))
        # The public dns name should only be listed once with the fix not twice
        if self.count == 1:
            pass
        else:
            self.fail(" euca-describe-instances instance ip=" + self.dns)
예제 #51
0
class Euca(unittest.TestCase):
    def setUp(self):
        self.conf = "../cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.STARTC = '\033[1m\033[1m\033[42m'
        self.ENDC = '\033[0m'

    def tearDown(self):
        self.tester.cleanup_artifacts()
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem")
        shutil.rmtree(self.tester.credpath)

    def runInstances(self, numMax):
        self.emi = self.tester.get_emi()
        #Start instance
        self.reservation = self.tester.run_instance(self.emi, keypair=self.keypair.name, group=self.group, min=1, max=numMax,
                                                    is_reachable=False)
        # Make sure the instance is running
        for instance in self.reservation.instances:
            if instance.state == "running":
                self.ip = instance.public_dns_name
                self.instanceid = instance.id

    def runSysCmd(self, cmd):
        self.source =  'export EUCALYPTUS=' + self.tester.eucapath + " && source " + self.tester.credpath + "/eucarc && "  + self.tester.eucapath + "/usr/sbin/"
        self.out = self.tester.sys(self.source + cmd)

    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)

    def test(self):
        self.runSysCmd('euca-describe-components')
        count = str(self.out).count("PRIMORDIAL")
        print self.STARTC + " The number of components listed in the PRIMORDIAL state = " + str(count) + self.ENDC
        #Fail if there are any components listed in the PRIMORDIAL state
        if count == 0 :
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAILED : components listed in the PRIMORDIAL state")
예제 #52
0
class CloudFormations(EutesterTestCase):
    def __init__(self, extra_args= None):
        self.setuptestcase()
        self.setup_parser()
        if extra_args:
            for arg in extra_args:
                self.parser.add_argument(arg)
        self.get_args()
        # Setup basic eutester object
        if self.args.region:
            self.tester = CFNops( credpath=self.args.credpath, region=self.args.region)
        else:
            self.tester = Eucaops( credpath=self.args.credpath, config_file=self.args.config,password=self.args.password)
        self.group = self.tester.add_group(group_name="group-" + str(time.time()))
        self.tester.authorize_group_by_name(group_name=self.group.name)
        self.tester.authorize_group_by_name(group_name=self.group.name, port=-1, protocol="icmp")
        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair("keypair-" + str(time.time()))
        self.keypath = '%s/%s.pem' % (os.curdir, self.keypair.name)

    def InstanceVolumeTemplate(self):
        self.stack_name = "volumeTest{0}".format(int(time.time()))
        template = Template()
        keyname_param = template.add_parameter(Parameter("KeyName", Description="Name of an existing EC2 KeyPair "
                                                                                "to enable SSH access to the instance",
                                                         Type="String",))
        template.add_mapping('RegionMap', {"": {"AMI": self.tester.get_emi().id}})
        for i in xrange(2):
            ec2_instance = template.add_resource(ec2.Instance("Instance{0}".format(i),
                                                              ImageId=FindInMap("RegionMap", Ref("AWS::Region"), "AMI"),
                                                              InstanceType="t1.micro", KeyName=Ref(keyname_param),
                                                              SecurityGroups=[self.group.name], UserData=Base64("80")))
            vol = template.add_resource(ec2.Volume("Volume{0}".format(i), Size="8",
                                                   AvailabilityZone=GetAtt("Instance{0}".format(i), "AvailabilityZone")))
            mount = template.add_resource(ec2.VolumeAttachment("MountPt{0}".format(i), InstanceId=Ref("Instance{0}".format(i)),
                                                               VolumeId=Ref("Volume{0}".format(i)), Device="/dev/vdc"))
        stack = self.tester.create_stack(self.stack_name, template.to_json(), parameters=[("KeyName",self.keypair.name)])
        def stack_completed():
            return self.tester.cloudformation.describe_stacks(self.stack_name).status == "CREATE_COMPLETE"
        self.tester.wait_for_result(stack_completed, True, timeout=600)
        self.tester.delete_stack(self.stack_name)

    def clean_method(self):
        self.tester.cleanup_artifacts()
예제 #53
0
파일: ha.py 프로젝트: mohitsethi/eutester
class HAtests(InstanceBasics, BucketTestSuite):
    def __init__(self):
        self.setuptestcase()
        self.setup_parser()
        self.get_args()
        self.tester = Eucaops( config_file=self.args.config_file, password=self.args.password)
        self.servman = self.tester.service_manager
        self.tester.poll_count = 120
        ### Add and authorize a group for the instance
        self.start_time = str(int(time.time()))
        self.group = self.tester.add_group(group_name="group-" + self.start_time )
        self.tester.authorize_group_by_name(group_name=self.group.name )
        self.tester.authorize_group_by_name(group_name=self.group.name, port=-1, protocol="icmp" )
        ### Generate a keypair for the instance
        self.keypair = self.tester.add_keypair( "keypair-" + self.start_time)
        self.keypath = os.curdir + "/" + self.keypair.name + ".pem"
        self.image = self.tester.get_emi(root_device_type="instance-store")
        self.reservation = None
        self.private_addressing = False
        self.bucket_prefix = "buckettestsuite-" + self.start_time + "-"
        self.test_user_id = self.tester.s3.get_canonical_user_id()
        zones = self.tester.ec2.get_all_zones()
        self.zone = random.choice(zones).name

        self.tester.clc = self.tester.service_manager.get_enabled_clc().machine
        self.old_version = self.tester.clc.sys("cat " + self.tester.eucapath + "/etc/eucalyptus/eucalyptus-version")[0]
        ### Create standing resources that will be checked after all failures
        ### Instance, volume, buckets
        ### 
        self.standing_reservation = self.tester.run_instance(keypair=self.keypair.name,group=self.group.name, zone=self.zone)
        self.volume = self.tester.create_volume(self.zone)
        self.device = self.standing_reservation.instances[0].attach_volume(self.volume)
        self.standing_bucket_name = "failover-bucket-" + self.start_time
        self.standing_bucket = self.tester.create_bucket(self.standing_bucket_name)
        self.standing_key_name = "failover-key-" + self.start_time
        self.standing_key = self.tester.upload_object(self.standing_bucket_name, self.standing_key_name)
        self.standing_key = self.tester.get_objects_by_prefix(self.standing_bucket_name, self.standing_key_name)

    def clean_method(self):
        try:
            self.tester.terminate_instances()
        except Exception, e:
            self.tester.critical("Unable to terminate all instances")
        self.servman.start_all()
예제 #54
0
class Euca3932(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf"
        self.acctName = "test-account" 
        self.cmdMod =  " euca-modify-image-attribute --launch-permission "
        self.cmdDes =  " euca-describe-image-attribute --launch-permission "     
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.out = self.tester.create_account(self.acctName)
        self.source  = "source " + self.tester.credpath + "/eucarc && "
        self.doAuth()

    def tearDown(self):
        self.tester.delete_account(self.acctName,recursive=True)
        self.tester.cleanup_artifacts() 
        self.tester.delete_keypair(self.keypair)
        self.tester.local("rm " + self.keypair.name + ".pem") 
        shutil.rmtree(self.tester.credpath)  
    
    def doAuth(self):
        self.keypair = self.tester.add_keypair()
        self.group = self.tester.add_group()
        self.tester.authorize_group(self.group)
               
    def testLaunchPermission(self):
        self.emi = self.tester.get_emi()
        #Get new userId (AccountId)
        self.outAccts = self.tester.get_all_accounts(account_name=self.acctName)
        for u in self.outAccts:
            self.testAccountId = u.account_id            
        # Add --launch-permission
        self.tester.sys(self.source + self.cmdMod + " -a " + self.testAccountId + " " + self.emi.id)
        # Describe --launch-permissions
        self.outDes = self.tester.sys(self.source + self.cmdDes + self.emi.id)
        # Check --launch-permissions for added userId
        self.count = str(self.outDes).count(self.testAccountId)
        # Remove added --launch-permission
        self.tester.sys(self.source + self.cmdMod + " -r " + self.testAccountId + " " + self.emi.id)
        if self.count==1:
            self.tester.debug("SUCCESS The --launch-permission for " + self.testAccountId + " was added.")
            pass
        else:
            self.fail("FAIL The --launch-permission for " + self.testAccountId + " not added.")