def run_test(instance_name, instance_type=None): # prepare print 'Preparing environment...' prepare_on_instance(TSCFG, instance_name) # run test print 'Running test on instance...' result = run_shell_command_on_instance( region=TSCFG['REGION'], instance_name=instance_name, cmd_line='/bin/bash ~/workspace/bin/test1.sh') #print 'status:\n----------\n%s\nstdout:\n----------\n%s\nstderr:\n----------\n%s\n' % (result) waiting_for_instance_online(region=TSCFG['REGION'], instance_name=instance_name, user_name=TSCFG['USER_NAME']) result = run_shell_command_on_instance( region=TSCFG['REGION'], instance_name=instance_name, cmd_line='/bin/bash ~/workspace/bin/test2.sh') #print 'status:\n----------\n%s\nstdout:\n----------\n%s\nstderr:\n----------\n%s\n' % (result) # get log print 'Getting log files...' collect_log_from_instance(TSCFG, instance_name) return
def run_test(instance_name, instance_type=None): # prepare print 'Preparing environment...' prepare_on_instance(TSCFG, instance_name + '-s') prepare_on_instance(TSCFG, instance_name + '-c') # run test print 'Running test on instance...' ## step 1: basic information result = run_shell_command_on_instance( region=TSCFG['REGION'], instance_name=instance_name + '-c', cmd_line='/bin/bash ~/workspace/bin/test.sh') #print 'status:\n----------\n%s\nstdout:\n----------\n%s\nstderr:\n----------\n%s\n' % (result) inst_id = get_instance_info_by_name(region=TSCFG['REGION'], instance_name=instance_name + '-c')['id'] log_save_path = TSCFG['LOG_SAVE_PATH'] + TSCFG['CASE_ID'] + '/' log_file = log_save_path + 'aws_check_' + instance_type + '.log' os.system('mkdir -p ' + log_save_path) os.system('aws ec2 describe-instances --instance-id {0} > {1}'.format( inst_id, log_file)) os.system( 'aws ec2 describe-instance-attribute --instance-id {0} --attribute sriovNetSupport >> {1}' .format(inst_id, log_file)) ## step 2: iperf test result = run_shell_command_on_instance( region=TSCFG['REGION'], instance_name=instance_name + '-s', cmd_line='/bin/bash ~/workspace/bin/iperf_server.sh') #print 'status:\n----------\n%s\nstdout:\n----------\n%s\nstderr:\n----------\n%s\n' % (result) server_ip = get_instance_info_by_name(region=TSCFG['REGION'], instance_name=instance_name + '-s')['private_ip_address'] result = run_shell_command_on_instance( region=TSCFG['REGION'], instance_name=instance_name + '-c', cmd_line='/bin/bash ~/workspace/bin/iperf_client.sh {0}'.format( server_ip)) #print 'status:\n----------\n%s\nstdout:\n----------\n%s\nstderr:\n----------\n%s\n' % (result) # get log print 'Getting log files...' collect_log_from_instance(TSCFG, instance_name + '-s') collect_log_from_instance(TSCFG, instance_name + '-c') return
def reboot_the_instance(instance_name): '''Reboot the instance.''' print 'Reboot the instance...' result = run_shell_command_on_instance(region=TSCFG['REGION'], instance_name=instance_name, user_name=TSCFG['USER_NAME'], cmd_line='sudo reboot&') return
def run_test(instance_name, instance_type=None): # prepare print 'Preparing environment...' prepare_on_instance(TSCFG, instance_name + '-s') prepare_on_instance(TSCFG, instance_name + '-c') # run test print 'Running test on instance...' ## get ip address server_ip = get_instance_info_by_name(region=TSCFG['REGION'], instance_name=instance_name+'-s')['private_ip_address'] client_ip = get_instance_info_by_name(region=TSCFG['REGION'], instance_name=instance_name+'-c')['private_ip_address'] response = get_ipv6_addresses(region=TSCFG['REGION'], instance_name=instance_name+'-s') server_ipv6 = response[0] if response else '' response = get_ipv6_addresses(region=TSCFG['REGION'], instance_name=instance_name+'-c') client_ipv6 = response[0] if response else '' ## run on server result = run_shell_command_on_instance(region=TSCFG['REGION'], instance_name=instance_name+'-s', user_name=TSCFG['USER_NAME'], cmd_line='/bin/bash ~/workspace/bin/test.sh server {0} {1}'.format(client_ip, client_ipv6)) #print 'status:\n----------\n%s\nstdout:\n----------\n%s\nstderr:\n----------\n%s\n' % (result) ## run on client result = run_shell_command_on_instance(region=TSCFG['REGION'], instance_name=instance_name+'-c', user_name=TSCFG['USER_NAME'], cmd_line='/bin/bash ~/workspace/bin/test.sh client {0} {1}'.format(server_ip, server_ipv6)) #print 'status:\n----------\n%s\nstdout:\n----------\n%s\nstderr:\n----------\n%s\n' % (result) # get log print 'Getting log files...' collect_log_from_instance(TSCFG, instance_name + '-s') collect_log_from_instance(TSCFG, instance_name + '-c') return
def collect_information(instance_name, tag='none'): '''Collect the information.''' waiting_for_instance_online(region=TSCFG['REGION'], instance_name=instance_name, user_name=TSCFG['USER_NAME']) print 'Collect boot time and resource information...' result = run_shell_command_on_instance( region=TSCFG['REGION'], instance_name=instance_name, user_name=TSCFG['USER_NAME'], cmd_line='/bin/bash ~/workspace/bin/test.sh {0}'.format(tag)) #print 'status:\n----------\n%s\nstdout:\n----------\n%s\nstderr:\n----------\n%s\n' % (result) return
def prepare_on_instance(tscfg, instance_name): '''Prepare environment for the test to run. Jobs: 1. mkdir workspace/bin workspace/log 2. upload test scripts to workspace/bin and chmod 755 3. clean logs under workspace/log Inputs: tscfg : dict, test suite configuration instance_name : string, the name of instance Retrun Value: Always None ''' run_shell_command_on_instance(region=tscfg['REGION'], instance_name=instance_name, user_name=tscfg['USER_NAME'], cmd_line='mkdir -p ~/workspace/bin/') upload_to_instance(region=tscfg['REGION'], instance_name=instance_name, user_name=tscfg['USER_NAME'], src='../global_bin/*', dst='~/workspace/bin/') upload_to_instance(region=tscfg['REGION'], instance_name=instance_name, user_name=tscfg['USER_NAME'], src='./bin/*', dst='~/workspace/bin/') run_shell_command_on_instance(region=tscfg['REGION'], instance_name=instance_name, user_name=tscfg['USER_NAME'], cmd_line='chmod 755 ~/workspace/bin/*') run_shell_command_on_instance( region=tscfg['REGION'], instance_name=instance_name, user_name=tscfg['USER_NAME'], cmd_line='mkdir -p ~/workspace/log/ && rm -rf ~/workspace/log/*') return
def run_test(instance_name, instance_type=None): # prepare print 'Preparing environment...' prepare_on_instance(TSCFG, instance_name) # run test # for volume in TSCFG['ATTACHED_VOLUME_IDS']: # volume_id = volume.split(';')[0] # volume_type = volume.split(';')[1] for volume_type in ('gp2', 'io1', 'st1', 'sc1'): iops = None if volume_type == 'gp2': # define gp2 volume volume_size = 3334 if volume_type == 'io1': # define io1 volume volume_size = 400 iops = 20000 if volume_type == 'st1': # define st1 volume volume_size = 12.5 * 1024 if volume_type == 'sc1': # define sc1 volume volume_size = 16 * 1024 # create the volume availability_zone = get_availability_zone(region=TSCFG['REGION'], instance_name=instance_name) volume = create_volume(region=TSCFG['REGION'], availability_zone=availability_zone, volume_type=volume_type, volume_size=volume_size, iops=iops) # attach the volume print 'Attaching test volume...' attach_volume_to_instance(region=TSCFG['REGION'], instance_name=instance_name, volume_id=volume.id, volume_delete_on_termination=True) # test the volume print 'Running test on instance...' result = run_shell_command_on_instance( region=TSCFG['REGION'], instance_name=instance_name, user_name=TSCFG['USER_NAME'], cmd_line='/bin/bash ~/workspace/bin/test.sh ' + volume_type) #print 'status:\n----------\n%s\nstdout:\n----------\n%s\nstderr:\n----------\n%s\n' % (result) # detach the volume print 'Detaching test volume...' detach_volume_from_instance(region=TSCFG['REGION'], instance_name=instance_name, volume_id=volume.id, force=True) # delete the volume delete_volume(volume_id=volume.id) # get log print 'Getting log files...' collect_log_from_instance(TSCFG, instance_name) return