Exemple #1
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")
Exemple #2
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")
Exemple #3
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")
Exemple #4
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")
Exemple #5
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
Exemple #6
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
Exemple #7
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")
Exemple #8
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")
Exemple #9
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)
Exemple #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")
Exemple #11
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"
Exemple #12
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')
Exemple #13
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")
Exemple #14
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
Exemple #15
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")
Exemple #16
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!")
Exemple #17
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" ) 
Exemple #18
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")
Exemple #19
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")
Exemple #20
0
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
Exemple #21
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")
Exemple #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")
Exemple #23
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
Exemple #24
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:")
Exemple #25
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:")
Exemple #26
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
Exemple #27
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
Exemple #28
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")
Exemple #29
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)
Exemple #30
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
Exemple #31
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.")
Exemple #32
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!")
Exemple #33
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
Exemple #34
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)
Exemple #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)
Exemple #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
Exemple #37
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.")
Exemple #38
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")
Exemple #39
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
Exemple #40
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)
Exemple #41
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.")
Exemple #42
0
class Euca5033(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.device = "/dev/sda1"
        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 testEBS(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.instance = instance
                self.zone = instance.placement
        # Run test
        self.rootVolume = self.tester.get_volume(attached_dev=self.device)
        self.tester.stop_instances(self.reservation)
        # EBS Instance now in stopped state, try and detach/attach root volume.
        self.tester.detach_volume(self.rootVolume)
        self.tester.attach_volume(self.instance, self.rootVolume, self.device)
        # Make sure instance will start.
        self.tester.start_instances(self.reservation)
        pass
Exemple #43
0
class Euca1057(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.iu = ImageUtils(tester=self.tester, config_file=self.conf)
        self.imgName = "bfebs-centos-vmwaretools-i386.img"
        self.imgUrl = "http://mirror.qa.eucalyptus-systems.com/bfebs-image/vmware/"
        self.errorMsg = "all associated instances must be in the terminated state."
        self.count = 0
        self.doAuth()

    def tearDown(self):
        if self.reservation is not None:
            self.tester.terminate_instances(self.reservation)
        self.out = self.runSysCmd("euca-deregister " + self.emi)
        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.iu.create_emi_from_url(self.imgUrl + self.imgName)
        self.reservation = self.tester.run_instance(image=self.emi,
                                                    is_reachable=False)

        self.runSysCmd("euca-deregister " + self.emi)
        self.count = +str(self.out).count(self.errorMsg)
        if self.count == 1:
            self.tester.debug("SUCCESS proper error thrown ")
            pass
        else:
            self.fail("FAIL incorrect error thrown ")
Exemple #44
0
class Euca1057(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf"
        self.tester  = Eucaops( config_file=self.conf, password="******" )
        self.iu = ImageUtils(tester=self.tester, config_file=self.conf )
        self.imgName = "bfebs-centos-vmwaretools-i386.img"
        self.imgUrl =  "http://mirror.qa.eucalyptus-systems.com/bfebs-image/vmware/"
        self.errorMsg = "all associated instances must be in the terminated state."
        self.count = 0
        self.doAuth()

    def tearDown(self):
        if self.reservation is not None:
            self.tester.terminate_instances(self.reservation)
        self.out = self.runSysCmd("euca-deregister " + self.emi)
        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.iu.create_emi_from_url( self.imgUrl + self.imgName)
        self.reservation = self.tester.run_instance(image=self.emi,is_reachable=False)

        self.runSysCmd("euca-deregister " + self.emi)
        self.count = + str(self.out).count(self.errorMsg)
        if self.count==1:
            self.tester.debug("SUCCESS proper error thrown ")
            pass
        else:
            self.fail("FAIL incorrect error thrown ")
Exemple #45
0
class Euca5033(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.device = "/dev/sda1"
        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 testEBS(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.instance = instance
                self.zone = instance.placement
        # Run test
        self.rootVolume = self.tester.get_volume(attached_dev=self.device)
        self.tester.stop_instances(self.reservation)
        # EBS Instance now in stopped state, try and detach/attach root volume.
        self.tester.detach_volume(self.rootVolume)
        self.tester.attach_volume(self.instance, self.rootVolume, self.device)
        # Make sure instance will start.
        self.tester.start_instances(self.reservation)
        pass
Exemple #46
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
Exemple #47
0
class Euca5430(unittest.TestCase):

    def setUp(self):
        self.conf = "cloud.conf" 
        self.cond = 1     
        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):
        #create the testGroup
        try:
            self.out = self.tester.create_group('Euca5430group')
        except Exception as detail:
            print str(detail)
        
        #try and create the testGroup again and check the error
        try:
            self.out = self.tester.create_group('Euca5430group')
        except Exception as detail:
            self.cond = str(detail).count('already exists')
        
        if self.cond >= 1:
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAIL")
Exemple #48
0
class Euca2366(unittest.TestCase):

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

    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()
        # Default Max volume size
        self.max_volume_size = int(self.props.get_property('storage.maxvolumesizeingb')[0])
        # Try and create volume larger than max_volume_size
        try:
            self.tester.create_volume(self.zone, self.max_volume_size + 1, timeout=10)
        except Exception as detail:
            print detail
            self.cond = str(detail).count('Max Volume Size Limit Exceeded')
       
        if self.cond >= 1:
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAIL")
Exemple #49
0
class Euca2366(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.cond = 1
        self.doAuth()
        self.props = EucaProperties(self.tester)

    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()
        # Default Max volume size
        self.max_volume_size = int(self.props.get_property("storage.maxvolumesizeingb")[0])
        # Try and create volume larger than max_volume_size
        try:
            self.tester.create_volume(self.zone, self.max_volume_size + 1, timeout=10)
        except Exception as detail:
            print detail
            self.cond = str(detail).count("Max Volume Size Limit Exceeded")

        if self.cond >= 1:
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAIL")
Exemple #50
0
class Euca5430(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.cond = 1
        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):
        #create the testGroup
        try:
            self.out = self.tester.create_group('Euca5430group')
        except Exception as detail:
            print str(detail)

        #try and create the testGroup again and check the error
        try:
            self.out = self.tester.create_group('Euca5430group')
        except Exception as detail:
            self.cond = str(detail).count('already exists')

        if self.cond >= 1:
            self.tester.debug("SUCCESS")
            pass
        else:
            self.fail("FAIL")
Exemple #51
0
class Euca7710(unittest.TestCase):

    def setUp(self):
        self.OK = '\033[1m\033[37m\033[42m'
        self.ENDC = '\033[0m'
        self.conf = 'cloud.conf'
        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.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 runInstances(self, numMax):
        #Start instance
        self.reservation = self.tester.run_instance(self.emi,type='m1.large', 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
                self.instanceid = instance.id

    def runCmdTest (self, cmd):
        self.out = self.clc1.machine.cmd(self.source + self.cmd)
        print self.OK + self.out['output'] + self.ENDC
        # make sure InvalidParameterValue error was thrown
        assert str(self.out).count('InvalidParameterValue') > 0

    def test(self):
        self.emi = self.tester.get_emi()
        self.runInstances(1)
        # Attempt to bundle the running instance with invalid parameters
        # regex used to validate bucket and prefix parameters = ( ^[a-zA-Z\d\.\-_]{3,255}$ )
        # two few chars
        self.badBucket = 'xx'
        # invalid char
        self.badPrefix = 'xx$'

        self.cmd = 'euca-bundle-instance ' + self.instanceid + ' -b ' + self.badBucket + ' -p goodPrefix -o ' + self.akey + ' -w ' + self.skey
        self.runCmdTest(self.cmd)
        self.cmd = 'euca-bundle-instance ' + self.instanceid + ' -b goodBucket -p ' + self.badPrefix + ' -o ' + self.akey + ' -w ' + self.skey
        self.runCmdTest(self.cmd)

        # Attempt  to attach and detach volume with invalid device name
        # regex used to device parameter = ( ^[a-zA-Z\d/]{3,10}$ )
        self.volume = 'vol-BOGUS1'
        # invalid char
        self.badDevice1 = 'sd$'
        # invalid name too long
        self.badDevice2 = 'sdistoolong'
        self.cmd = 'euca-attach-volume -i ' + self.instanceid + ' -d ' + self.badDevice1 + ' ' + self.volume
        self.runCmdTest(self.cmd)
        self.cmd = 'euca-attach-volume -i ' + self.instanceid + ' -d ' + self.badDevice1 + ' ' + self.volume
        self.runCmdTest(self.cmd)
        self.cmd = 'euca-detach-volume -i ' + self.instanceid + ' -d ' + self.badDevice1 + ' ' + self.volume
        self.runCmdTest(self.cmd)
        self.cmd = 'euca-detach-volume -i ' + self.instanceid + ' -d ' + self.badDevice1 + ' ' + self.volume
        self.runCmdTest(self.cmd)

    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)
Exemple #52
0
class Euca4229(unittest.TestCase):
    def setUp(self):
        self.conf = "cloud.conf"
        self.cond = 0
        self.tester = Eucaops(config_file=self.conf, password="******")
        self.doAuth()
        self.sbin = self.tester.eucapath + "/usr/sbin/"
        self.source = "source " + self.tester.credpath + "/eucarc && "

    def tearDown(self):
        self.tester.sys(
            self.source + self.sbin +
            "euca-modify-property -p walrus.storagemaxtotalsnapshotsizeingb=50"
        )
        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.ip = instance.public_dns_name
                self.instanceid = instance.id

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

    def testEuca4229(self):
        # Get availibility zone
        self.zone = self.tester.get_zones().pop()
        # Get number of already existing snapshots:
        self.num_snaps_before = str(
            self.tester.sys(self.source +
                            "euca-describe-snapshots")).count("SNAPSHOT")
        # Set storagemaxtotalsnapshotsizeingb
        self.tester.sys(
            self.source + self.sbin +
            "euca-modify-property -p walrus.storagemaxtotalsnapshotsizeingb=1")
        # create volume larger than storagemaxtotalsnapshotsizeingb = 1GB
        self.volume = self.tester.create_volume(self.zone, 2, timeout=100)
        # make sure the exception is thrown
        try:
            self.snap = self.tester.create_snapshot(self.volume.id,
                                                    description="snap-4229")
        except Exception as detail:
            self.cond = str(detail).count('maximum allowed object size')
        # Get the current number of snapshots
        self.num_snaps_after = str(
            self.tester.sys(self.source +
                            "euca-describe-snapshots")).count("SNAPSHOT")
        # Check to see if the the error was thrown and make sure no new snapshot-matadata was created
        if self.cond >= 1 and self.num_snaps_after == self.num_snaps_before:
            self.tester.debug("SUCCESS no new snapshot-metadata")
            pass
        else:
            self.fail("FAIL new snapshot-metadata")
Exemple #53
0
class MyFirstTest(unittest.TestCase):
    def setUp(self):
        self.tester = Eucaops(credpath="/etc/eutester/.euca_cloud1_user/")
        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")
        self.reservation = None

    def testInstance(self):
        image = self.tester.get_emi("emi-5F87351C")
        ### 1) Run an instance
        try:
            self.reservation = self.tester.run_instance(
                image,
                self.keypair.name,
                self.group.name,
                user_data="echo 'userdata is working' > /tmp/userdata.txt",
                type="m1.large",
                min=1,
                max=1)
        except Exception, e:
            self.fail("Caught an exception when running the instance: " +
                      str(e))
        for instance in self.reservation.instances:
            ### 2) Ping the instance
            ping_result = self.tester.ping(instance.public_dns_name)
            self.assertTrue(ping_result, "Ping to instance failed")
            ### 3) Run command on instance
            uname_result = instance.sys("uname")
            self.assertNotEqual(len(uname_result), 0, "uname failed")
            ### 4) Check userdata
            self.tester.sleep(10)
            userdata_result = instance.sys("cat /tmp/userdata.txt")
            self.assertNotEqual(len(userdata_result), 0, "userdata failed")

            ### Ensure we know what device are on the instance before the attachment of a volume
            before_attach = instance.sys("ls -1 /dev/ | grep vd")

            ## Create the volume
            volume = self.tester.create_volume(
                self.tester.ec2.get_all_zones()[0].name, size=2)

            ### Attach the volume (need to write a routine to validate the attachment)
            volume.attach(instance.id, "/dev/vdb")

            self.tester.sleep(20)

            ### Check what devices are found after the attachment
            after_attach = instance.sys("ls -1 /dev/ | grep vd")

            ### Use the eutester diff functionality to find the newly attached device
            new_devices = self.tester.diff(after_attach, before_attach)
            attached_block_dev = new_devices[0].strip()

            ### Make a file system on the volume and mount it
            instance.sys("mkfs.ext4 -F /dev/" + attached_block_dev)
            instance.sys("mkdir /mnt/device")
            instance.sys("mount /dev/" + attached_block_dev + " /mnt/device")

            ### Test speed of EBS
            instance.sys("echo '[Info] Performing WRITE test'")
            instance.sys(
                "dd if=/dev/zero of=/mnt/device/speedtest.tmp bs=1M count=1000 conv=fdatasync 2>&1 | grep MB"
            )
            instance.sys("echo '[Info] Finished WRITE test'")
            instance.sys("echo '[Info] Performing READ test'")
            instance.sys(
                "dd if=/mnt/device/speedtest.tmp of=/dev/zero 2>&1 | grep MB")
            instance.sys("echo '[Info] Finished READ test'")
            instance.sys("echo '[Info] Removing tmp file'")
            instance.sys("rm -f /mnt/device/speedtest.tmp")

            ### Unmount the volume
            if instance.sys("umount /mnt/device") != []:
                self.tester.fail("Failure unmounting volume")

            ### Make a snapshot of the volume
            snapshot = self.tester.create_snapshot(volume.id)
            ### Delete the snapshot
            self.tester.delete_snapshot(snapshot)

            ### TEARDOWN INSTANCES, VOLUMES GROUP, KEYPAIR, AND ADDRESSES

            self.tester.detach_volume(volume)
            self.tester.delete_volume(volume)
            instance.terminate()
            self.tester.sleep(20)