#add/remove arguements to the default cli and config file argument list, see testcase class for all default cli args testcase.setup_parser(description="Attempts to test and provide info on focused areas related to Eucalyptus EBS related functionality.", testlist=False) testcase.parser.add_argument('--snap_count', type=int, help='Number of snapshots to create per zone',default=5) testcase.parser.add_argument('--snap_delay', type=int, help='Delay in seconds between each snapshot created',default=0) testcase.parser.add_argument('--snap_progress', type=int, help='Number of 10 second polls to allow without increase in snapshot progress',default=60) testcase.parser.add_argument('--timepergig', type=int, help='Time allowed per gig size of volume during volume creation',default=300) testcase.parser.add_argument('--snap_attached', dest='snap_attached', action='store_true', default=False) testcase.parser.add_argument('--delete_to', type=int, help="Timeout for volume deletion", default=120) testcase.parser.add_argument('--root_device_type', help="Type of instance to run, 'ebs' or 'instance-store'", default='instance-store') #Get arguments passed in through cli and/or config file(s), these will be stored in testcase.args testcase.get_args() #create the EbsTestSuite object, use 'do_with_args' to auto populate the object's init with testcase.args ebstestsuite= testcase.do_with_args(EbsTestSuite) #register a test cleanup method with the testcase... testcase.clean_method = ebstestsuite.clean_created_resources #add test methods and their arguments to be run to a list... testlist = ebstestsuite.test_consecutive_concurrent(run=False, count=int(testcase.args.snap_count), delay=testcase.args.snap_delay, tpg=testcase.args.timepergig, snap_attached = testcase.args.snap_attached, delete_to = testcase.args.delete_to, poll_progress=testcase.args.snap_progress) #finally, execute the list of test methods from the test case wrapper... ret = testcase.run_test_case_list(testlist)
## If given command line arguments, use them as test names to launch tc = EutesterTestCase() tc.setup_parser(testname='ebstestsuite.py', description='collection of ebs related tests', testlist=False) tc.parser.add_argument('--inst_pass', help="Instance password for ssh session if not key enabled", default=None) args = tc.get_args() #if file was not provided or is not found if not os.path.exists(args.config): print "Error: Mandatory Config File '"+str(args.config)+"' not found." tc.parser.print_help() exit(1) #ebssuite = EbsTestSuite(zone=args.zone, config_file= args.config, password=args.password,credpath=args.credpath, keypair=args.keypair, group=args.group, image=args.emi) ebssuite = tc.do_with_args(EbsTestSuite) kbtime=time.time() try: list = ebssuite.ebs_basic_test_suite(run=False) tc.run_test_case_list(list) except KeyboardInterrupt: ebssuite.debug("Caught keyboard interrupt...") if ((time.time()-kbtime) < 2): ebssuite.clean_created_resources() ebssuite.debug("Caught 2 keyboard interupts within 2 seconds, exiting test") ebssuite.clean_created_resources() tc.print_test_list_results(list) raise else: tc.print_test_list_results(list) kbtime=time.time()
raise Exception("Instance did not get stopped then started") bundled_image_reservation = self.tester.run_instance( **self.run_instance_params) for new_instance in bundled_image_reservation.instances: new_instance.sys("ls " + temp_file, code=0) self.tester.terminate_instances(bundled_image_reservation) self.run_instance_params['image'] = original_image if __name__ == "__main__": testcase = EutesterTestCase(name='instancetest') testcase.setup_parser( description= "Test the Eucalyptus EC2 instance store image functionality.") testcase.get_args() instancetestsuite = testcase.do_with_args(InstanceBasics) ### Either use the list of tests passed from config/command line to determine what subset of tests to run test_list = testcase.args.tests or [ "BasicInstanceChecks", "DNSResolveCheck", "Reboot", "MetaData", "ElasticIps", "MultipleInstances", "LargestInstance", "PrivateIPAddressing", "Churn" ] ### Convert test suite methods to EutesterUnitTest objects unit_list = [] for test in test_list: test = getattr(instancetestsuite, test) unit_list.append(testcase.create_testunit_from_method(test)) testcase.clean_method = instancetestsuite.clean_method result = testcase.run_test_case_list(unit_list) exit(result)
testcase.args.worker_password = testcase.args.worker_password or testcase.args.password testcase.args.worker_keypath = testcase.args.worker_keypath or testcase.args.keypair if (not testcase.args.url and not testcase.args.filepath) or (testcase.args.url and testcase.args.filepath): raise Exception('Must specify either a URL or FILE path to create Windows EMI from') #Set kernel to 'windows'. This result in the platform type resulting in 'windows' after registration. if str(testcase.args.image_type).lower() == "windows": testcase.args.kernel = "windows" def make_image_public(): emi = image_utils.tester.test_resources['images'][0] emi.set_launch_permissions(group_names=['all']) testcase.debug('\n---------------------------\nCreated EMI:' + str(emi) +'\n---------------------------') #Create an ImageUtils helper from the arguments provided in this testcase... image_utils = testcase.do_with_args(ImageUtils) #Create a single testcase to wrap and run the EMI creation task. Note by default all the overlapping args from # this testcase are fed to the testunit method when ran. test1 = testcase.create_testunit_from_method(image_utils.create_emi) test2 = testcase.create_testunit_from_method(make_image_public) result = testcase.run_test_case_list([test1, test2], eof=True, clean_on_exit=False, printresults=True) #By default created resources are stored in the eucaops/tester object's test_resources dict. See if our image is #prsent. If so print it out... if image_utils.tester.test_resources['images']: emi = image_utils.tester.test_resources['images'].pop() testcase.debug('\n---------------------------\nCreated EMI:' + str(emi) +'\n---------------------------') exit(result)
instance.sys('ls -la', code=0) not_rebooted_image = self.tester.create_image(instance, "BFEBS-test-create-image-noreboot-" + current_time, no_reboot=True) ending_uptime = instance.get_uptime() if ending_uptime < starting_uptime: raise Exception("Instance did get stopped then started when it shouldn't have") self.run_instance_params['image'] = not_rebooted_image new_image_reservation = self.tester.run_instance(**self.run_instance_params) for new_instance in new_image_reservation.instances: ## Check that our temp file exists new_instance.sys("ls -la") new_instance.sys("ls " + temp_file, code=0) self.tester.terminate_instances(new_image_reservation) if __name__ == "__main__": testcase= EutesterTestCase(name='bfebstest') testcase.setup_parser(description="Test the Eucalyptus EC2 BFEBS image functionality.") testcase.parser.add_argument('--imgurl', help="BFEBS Image to splat down", default=None) testcase.get_args() bfebstestsuite = testcase.do_with_args(BFEBSBasics) ### Either use the list of tests passed from config/command line to determine what subset of tests to run list = testcase.args.tests or ["RegisterImage", "StopStart", "MultipleBFEBSInstances"] ### Convert test suite methods to EutesterUnitTest objects unit_list = [] for test in list: test = getattr(bfebstestsuite,test) unit_list.append(testcase.create_testunit_from_method(test)) testcase.clean_method = bfebstestsuite.clean_method result = testcase.run_test_case_list(unit_list) exit(result)
testcase.parser.add_argument('--win_proxy_password', help='powershell proxy ssh password', default=None) testcase.parser.add_argument('--win_proxy_keypath', help='powershell proxy ssh keypath', default=None) testcase.parser.add_argument('--fof', help='freeze on failure, will not clean up test if set', default=False) testcase.parser.add_argument('--instance_id', dest='instance', help='Instance id. Must be a running instance and keyfile is local to this script', default=None) testcase.parser.add_argument('--recycle', help="re-use an instance who's keyfile is local to this test script",dest='recycle', action='store_true', default=None) args = testcase.get_args() recycle = testcase.args.recycle if testcase.args.fof is not None else False if not args.emi: raise Exception("Need a windows EMI to test against") if not (args.win_proxy_hostname and args.win_proxy_username and (args.win_proxy_password or args.win_proxy_keypath)): raise Exception("Need windows proxy hostname, and login credentials") WinTests = testcase.do_with_args(WindowsTests,work_component=machine) #WinTests = WindowsTests() emi = WinTests.tester.get_emi(args.emi) tests = [] if recycle or args.instance: tests.append(testcase.create_testunit_from_method(WinTests.get_windows_instance, eof=True)) else: tests.append(testcase.create_testunit_from_method(WinTests.test_run_windows_emi, eof=True)) tests.append(testcase.create_testunit_from_method(WinTests.test_get_windows_instance_password, eof=True)) tests.append(testcase.create_testunit_from_method(WinTests.update_proxy_info, eof=True)) tests.append(testcase.create_testunit_from_method(WinTests.test_wait_for_instance_boot)) tests.append(testcase.create_testunit_from_method(WinTests.test_poll_for_rdp_port_status, eof=True)) tests.append(testcase.create_testunit_from_method(WinTests.proxy.ps_login_test, eof=True))
'--count', type=int, help='Number of times to run attach/detach churn', default=None) testcase.parser.add_argument('--nodecount', type=int, help='Number of nodes in env', default=None) testcase.parser.add_argument( '--fof', dest='fof', help="Freeze test on fail, do not remove or tear down test items", action='store_true', default=None) testcase.get_args() count = testcase.args.count or 10 fof = testcase.args.fof if testcase.args.fof is not None else False nodecount = testcase.args.nodecount or 2 ebstestsuite = testcase.do_with_args(EbsTestSuite) if testcase.args.fof: testcase.clean_method = lambda: testcase.status( "Freeze on fail flag is set, not cleaning!") else: testcase.clean_method = ebstestsuite.clean_created_resources testlist = ebstestsuite.test_multi_node(run=False, count=int(count), nodecount=int(nodecount)) ret = testcase.run_test_case_list(testlist) print "mutli node test exiting:(" + str(ret) + ")" exit(ret)
if self.clc.found(command, property): self.debug("Properly modified property " + property) else: raise Exception("Setting property " + property + " failed") if __name__ == "__main__": testcase = EutesterTestCase() #### Adds argparse to testcase and adds some defaults args testcase.setup_parser() ### Get all cli arguments and any config arguments and merge them testcase.get_args() ### Instantiate an object of your test suite class using args found from above instance_basics_tests = testcase.do_with_args(ReportingBasics) ### Either use the list of tests passed from config/command line to determine what subset of tests to run list = testcase.args.tests or ["instance"] ### Convert test suite methods to EutesterUnitTest objects unit_list = [ ] for test in list: unit_list.append( instance_basics_tests.create_testunit_by_name(test) ) ### Run the EutesterUnitTest objects testcase.run_test_case_list(unit_list)
'--gigtime', dest='time_per_gig', help='Time allowed per gig size of image to be used', default=300) testcase.parser.add_argument('--interbundletime', dest='inter_bundle_timeout', help='Inter-bundle timeout', default=120) testcase.parser.add_argument('--bucket', dest='bucketname', help='bucketname', default=None) args = testcase.get_args() if (not args.url and not args.image_file) or (args.url and args.image_file): raise Exception( 'Must specify either a URL or FILE path to create Windows EMI from') if args.workip: machine = Machine(hostname=args.workip, password=args.password) WinTests = testcase.do_with_args(WindowsTests, work_component=machine) test = testcase.create_testunit_from_method( WinTests.create_windows_emi_from_url) testcase.run_test_case_list([test], eof=True, clean_on_exit=False, printresults=True)
prev_address = None if self.reservation: self.tester.terminate_instances(self.reservation) self.set_reservation(None) for i in xrange(5): reservation = self.tester.run_instance(**self.run_instance_params) for instance in reservation.instances: if prev_address is not None: self.assertTrue(re.search(str(prev_address) ,str(instance.ip_address)), str(prev_address) +" Address did not get reused but rather " + str(instance.public_dns_name)) prev_address = instance.ip_address self.tester.terminate_instances(reservation) if __name__ == "__main__": testcase= EutesterTestCase(name='instancetest') testcase.setup_parser(description="Test the Eucalyptus EC2 instance store image functionality.") testcase.get_args() instancetestsuite= testcase.do_with_args(InstanceBasics) ### Either use the list of tests passed from config/command line to determine what subset of tests to run list = testcase.args.tests or [ "BasicInstanceChecks", "DNSResolveCheck", "Reboot", "MetaData", "ElasticIps", "MultipleInstances", "LargestInstance", "PrivateIPAddressing", "Churn"] ### Convert test suite methods to EutesterUnitTest objects unit_list = [] for test in list: test = getattr(instancetestsuite,test) unit_list.append(testcase.create_testunit_from_method(test)) testcase.clean_method = instancetestsuite.clean_method result = testcase.run_test_case_list(unit_list) exit(result)
command = "source " + self.tester.credpath + "/eucarc && " + self.tester.eucapath + "/usr/sbin/euca-modify-property -p " + str( property) + "=" + str(value) if self.clc.found(command, property): self.debug("Properly modified property " + property) else: raise Exception("Setting property " + property + " failed") if __name__ == "__main__": testcase = EutesterTestCase() #### Adds argparse to testcase and adds some defaults args testcase.setup_parser() ### Get all cli arguments and any config arguments and merge them testcase.get_args() ### Instantiate an object of your test suite class using args found from above instance_basics_tests = testcase.do_with_args(ReportingBasics) ### Either use the list of tests passed from config/command line to determine what subset of tests to run list = testcase.args.tests or ["instance"] ### Convert test suite methods to EutesterUnitTest objects unit_list = [] for test in list: unit_list.append(instance_basics_tests.create_testunit_by_name(test)) ### Run the EutesterUnitTest objects testcase.run_test_case_list(unit_list)
if self.clc.found(command, property): self.debug("Properly modified property " + property) else: raise Exception("Setting property " + property + " failed") if __name__ == "__main__": testcase = EutesterTestCase() #### Adds argparse to testcase and adds some defaults args testcase.setup_parser() ### Get all cli arguments and any config arguments and merge them testcase.get_args() ### Instantiate an object of your test suite class using args found from above instance_basics_tests = testcase.do_with_args(InstanceRestore) ### Either use the list of tests passed from config/command line to determine what subset of tests to run list = testcase.args.tests or [ "restore_logic"] ### Convert test suite methods to EutesterUnitTest objects unit_list = [ ] for test in list: unit_list.append( instance_basics_tests.create_testunit_by_name(test) ) ### Run the EutesterUnitTest objects testcase.run_test_case_list(unit_list) instance_basics_tests.clean_method() __author__ = 'viglesias'