def _RunTest(self, expectation, ip_addresses, is_reachable=True): self.flags.ip_addresses = ip_addresses self.sending_vm.IsReachable.return_value = is_reachable self.assertEqual( expectation, vm_util.ShouldRunOnInternalIpAddress(self.sending_vm, self.receiving_vm))
def Run(benchmark_spec): """Measure TCP stream throughput between two VMs. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. Returns: A list of sample.Sample objects with the benchmark results. """ vms = benchmark_spec.vms results = [] # Send traffic in both directions for originator in [0, 1]: sending_vm = vms[originator] receiving_vm = vms[originator ^ 1] # Send using external IP addresses if vm_util.ShouldRunOnExternalIpAddress(): results.extend( ntttcp.RunNtttcp(sending_vm, receiving_vm, receiving_vm.ip_address, 'external')) # Send using internal IP addresses if vm_util.ShouldRunOnInternalIpAddress(sending_vm, receiving_vm): results.extend( ntttcp.RunNtttcp(sending_vm, receiving_vm, receiving_vm.internal_ip, 'internal')) return results
def Run(benchmark_spec): """Run iperf on the target vm. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. Returns: A list of sample.Sample objects. """ vms = benchmark_spec.vms results = [] logging.info('Iperf Results:') # Send traffic in both directions for sending_vm, receiving_vm in vms, reversed(vms): # Send using external IP addresses if vm_util.ShouldRunOnExternalIpAddress(): results.append( _RunIperf(sending_vm, receiving_vm, receiving_vm.ip_address, 'external')) # Send using internal IP addresses if vm_util.ShouldRunOnInternalIpAddress(sending_vm, receiving_vm): results.append( _RunIperf(sending_vm, receiving_vm, receiving_vm.internal_ip, 'internal')) return results
def _RunTest(sending_vm, receiving_vm): """Runs the tests depending on what is enabled. Args: sending_vm: The vm that will initiate the stream. receiving_vm: The vm that will act as server. """ if vm_util.ShouldRunOnExternalIpAddress(): if FLAGS.run_udp: results.extend( iperf3.RunIperf3UDPStream(sending_vm, receiving_vm, use_internal_ip=False)) if FLAGS.run_tcp: results.extend( iperf3.RunIperf3TCPMultiStream(sending_vm, receiving_vm, use_internal_ip=False)) if vm_util.ShouldRunOnInternalIpAddress(sending_vm, receiving_vm): if FLAGS.run_udp: results.extend( iperf3.RunIperf3UDPStream(sending_vm, receiving_vm, use_internal_ip=True)) if FLAGS.run_tcp: results.extend( iperf3.RunIperf3TCPMultiStream(sending_vm, receiving_vm, use_internal_ip=True))
def Run(benchmark_spec): """Run ping on the target vm. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. Returns: A list of sample.Sample objects. """ vms = benchmark_spec.vms results = [] for sending_vm, receiving_vm in vms, reversed(vms): if vm_util.ShouldRunOnExternalIpAddress(): ip_type = vm_util.IpAddressMetadata.EXTERNAL results = results + _RunPing(sending_vm, receiving_vm, receiving_vm.ip_address, ip_type) if vm_util.ShouldRunOnInternalIpAddress(sending_vm, receiving_vm): ip_type = vm_util.IpAddressMetadata.INTERNAL results = results + _RunPing(sending_vm, receiving_vm, receiving_vm.internal_ip, ip_type) return results
def _RunNuttcpTest(sending_vm, receiving_vm): if vm_util.ShouldRunOnExternalIpAddress(): results.extend( nuttcp.RunNuttcp(sending_vm, receiving_vm, exec_path, receiving_vm.ip_address, 'external')) if vm_util.ShouldRunOnInternalIpAddress(sending_vm, receiving_vm): results.extend( nuttcp.RunNuttcp(sending_vm, receiving_vm, exec_path, receiving_vm.internal_ip, 'internal'))
def _RunTest(sending_vm, receiving_vm): if vm_util.ShouldRunOnExternalIpAddress(): results.extend( psping.RunLatencyTest(sending_vm, receiving_vm, use_internal_ip=False)) if vm_util.ShouldRunOnInternalIpAddress(sending_vm, receiving_vm): results.extend( psping.RunLatencyTest(sending_vm, receiving_vm, use_internal_ip=True))
def _RunTest(sending_vm, receiving_vm): if vm_util.ShouldRunOnExternalIpAddress(): results.extend( iperf3.RunIperf3UDPStream(sending_vm, receiving_vm, use_internal_ip=False)) if vm_util.ShouldRunOnInternalIpAddress(sending_vm, receiving_vm): results.extend( iperf3.RunIperf3UDPStream(sending_vm, receiving_vm, use_internal_ip=True))
def RunScpSingleDirection(sending_vm, receiving_vm, cipher, data_size_in_mb, base_metadata): """Run scp from sending_vm to receiving_vm and parse results. If 'receiving_vm' is accessible via internal IP from 'sending_vm', throughput over internal IP addresses will be tested in addition to external IP addresses. Args: sending_vm: The originating VM for the scp command. receiving_vm: The destination VM for the scp command. cipher: Name of the SSH cipher to use. data_size_in_mb: The size of the data file in MB. base_metadata: The base metadata to attach to the sample. Returns: A list of sample.Sample objects. """ results = [] metadata = base_metadata.copy() for vm_specifier, vm in ('receiving', receiving_vm), ('sending', sending_vm): for k, v in six.iteritems(vm.GetResourceMetadata()): metadata['{0}_{1}'.format(vm_specifier, k)] = v cmd_template = ( 'sudo sync; sudo sysctl vm.drop_caches=3; ' 'time /usr/bin/scp -o StrictHostKeyChecking=no -i %s -c %s ' '%s %s@%%s:%%s/;') % (linux_virtual_machine.REMOTE_KEY_PATH, cipher, '%s/data/*' % sending_vm.GetScratchDir(0), receiving_vm.user_name) def RunForIpAddress(ip_address, ip_type): """Run SCP benchmark against a destination IP address.""" target_dir = posixpath.join(receiving_vm.GetScratchDir(0), ip_type) cmd = cmd_template % (ip_address, target_dir) receiving_vm.RemoteCommand('mkdir %s' % target_dir) meta = metadata.copy() meta['ip_type'] = ip_type _, res = sending_vm.RemoteCommand(cmd) time_used = vm_util.ParseTimeCommandResult(res) result = data_size_in_mb / time_used receiving_vm.RemoteCommand('rm -rf %s' % target_dir) return sample.Sample('scp throughput', result, UNIT, meta) if vm_util.ShouldRunOnExternalIpAddress(): results.append(RunForIpAddress(receiving_vm.ip_address, 'external')) if vm_util.ShouldRunOnInternalIpAddress(sending_vm, receiving_vm): results.append(RunForIpAddress(receiving_vm.internal_ip, 'internal')) return results
def RunScpSingleDirection(sending_vm, receiving_vm): """Run scp from sending_vm to receiving_vm and parse results. If 'receiving_vm' is accessible via internal IP from 'sending_vm', throughput over internal IP addresses will be tested in addition to external IP addresses. Args: sending_vm: The originating VM for the scp command. receiving_vm: The destination VM for the scp command. Returns: A list of sample.Sample objects. """ results = [] metadata = { 'sending_zone': sending_vm.zone, 'receiving_zone': receiving_vm.zone, 'server_machine_type': receiving_vm.machine_type, 'client_machine_type': sending_vm.machine_type, } cmd_template = ( 'sudo sync; sudo sysctl vm.drop_caches=3; ' 'time /usr/bin/scp -o StrictHostKeyChecking=no -i %s -c %s ' '%s %s@%%s:%%s/;') % (virtual_machine.REMOTE_KEY_PATH, CIPHER, '%s/data/*' % sending_vm.GetScratchDir(0), receiving_vm.user_name) def RunForIpAddress(ip_address, ip_type): """Run SCP benchmark against a destination IP address.""" target_dir = os.path.join(receiving_vm.GetScratchDir(0), ip_type) cmd = cmd_template % (ip_address, target_dir) receiving_vm.RemoteCommand('mkdir %s' % target_dir) meta = metadata.copy() meta['ip_type'] = ip_type _, res = sending_vm.RemoteCommand(cmd) time_used = vm_util.ParseTimeCommandResult(res) result = DATA_SIZE_IN_MB / time_used receiving_vm.RemoteCommand('rm -rf %s' % target_dir) return sample.Sample('scp throughput', result, UNIT, meta) if vm_util.ShouldRunOnExternalIpAddress(): results.append(RunForIpAddress(receiving_vm.ip_address, 'external')) if vm_util.ShouldRunOnInternalIpAddress(sending_vm, receiving_vm): results.append(RunForIpAddress(receiving_vm.internal_ip, 'internal')) return results
def Run(benchmark_spec): """Run netperf TCP_RR on the target vm. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. Returns: A list of sample.Sample objects. """ vms = benchmark_spec.vms client_vm = vms[0] # Client aka "sending vm" server_vm = vms[1] # Server aka "receiving vm" logging.info('netperf running on %s', client_vm) results = [] metadata = { 'sending_zone': client_vm.zone, 'sending_machine_type': client_vm.machine_type, 'receiving_zone': server_vm.zone, 'receiving_machine_type': server_vm.machine_type } for num_streams in FLAGS.netperf_num_streams: assert num_streams >= 1 for netperf_benchmark in FLAGS.netperf_benchmarks: if vm_util.ShouldRunOnExternalIpAddress(): external_ip_results = RunNetperf(client_vm, netperf_benchmark, server_vm.ip_address, num_streams, server_vm=server_vm) for external_ip_result in external_ip_results: external_ip_result.metadata['ip_type'] = 'external' external_ip_result.metadata.update(metadata) results.extend(external_ip_results) if vm_util.ShouldRunOnInternalIpAddress(client_vm, server_vm): internal_ip_results = RunNetperf(client_vm, netperf_benchmark, server_vm.internal_ip, num_streams, server_vm=server_vm) for internal_ip_result in internal_ip_results: internal_ip_result.metadata.update(metadata) internal_ip_result.metadata['ip_type'] = 'internal' results.extend(internal_ip_results) return results
def Run(benchmark_spec): """Run netperf TCP_RR on the target vm. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. Returns: A list of sample.Sample objects. """ vms = benchmark_spec.vms client_vm = vms[0] server_vm = vms[1] logging.info('netperf running on %s', client_vm) results = [] metadata = {'ip_type': 'external'} for vm_specifier, vm in ('receiving', server_vm), ('sending', client_vm): metadata['{0}_zone'.format(vm_specifier)] = vm.zone for k, v in vm.GetMachineTypeDict().iteritems(): metadata['{0}_{1}'.format(vm_specifier, k)] = v for num_streams in FLAGS.netperf_num_streams: assert (num_streams >= 1) for netperf_benchmark in FLAGS.netperf_benchmarks: if vm_util.ShouldRunOnExternalIpAddress(): external_ip_results = RunNetperf(client_vm, netperf_benchmark, server_vm.ip_address, num_streams) for external_ip_result in external_ip_results: external_ip_result.metadata.update(metadata) results.extend(external_ip_results) if vm_util.ShouldRunOnInternalIpAddress(client_vm, server_vm): internal_ip_results = RunNetperf(client_vm, netperf_benchmark, server_vm.internal_ip, num_streams) for internal_ip_result in internal_ip_results: internal_ip_result.metadata.update(metadata) internal_ip_result.metadata['ip_type'] = 'internal' results.extend(internal_ip_results) return results
def Run(benchmark_spec): """Run netperf TCP_RR on the target vm. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. Returns: A list of sample.Sample objects. """ # set client and server vms vm_dict = benchmark_spec.vm_groups client_vms = vm_dict['client'] server_vms = vm_dict['servers'] client_vm = client_vms[0] results = [] if vm_util.ShouldRunOnExternalIpAddress(): server_ips = list((vm.ip_address for vm in server_vms)) external_ip_results = RunNetperfAggregate(client_vm, server_ips) for external_ip_result in external_ip_results: external_ip_result.metadata['ip_type'] = 'external' results.extend(external_ip_results) # check if all server vms internal ips are reachable run_internal = True for tmp_vm in server_vms: if not vm_util.ShouldRunOnInternalIpAddress(client_vm, tmp_vm): run_internal = False break if run_internal: server_ips = list((vm.internal_ip for vm in server_vms)) internal_ip_results = RunNetperfAggregate(client_vm, server_ips) for internal_ip_result in internal_ip_results: internal_ip_result.metadata['ip_type'] = 'internal' results.extend(internal_ip_results) return results
def Run(benchmark_spec): """Run netperf TCP_RR on the target vm. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. Returns: A list of sample.Sample objects. """ vms = benchmark_spec.vms vm = vms[0] server_vm = vms[1] logging.info('netperf running on %s', vm) results = [] metadata = { 'ip_type': 'external', 'server_machine_type': server_vm.machine_type, 'server_zone': server_vm.zone, 'receiving_zone': server_vm.zone, 'client_machine_type': vm.machine_type, 'client_zone': vm.zone, 'sending_zone': vm.zone } for netperf_benchmark in NETPERF_BENCHMARKS: if vm_util.ShouldRunOnExternalIpAddress(): external_ip_results = RunNetperf(vm, netperf_benchmark, server_vm.ip_address) for external_ip_result in external_ip_results: external_ip_result.metadata.update(metadata) results.extend(external_ip_results) if vm_util.ShouldRunOnInternalIpAddress(vm, server_vm): internal_ip_results = RunNetperf(vm, netperf_benchmark, server_vm.internal_ip) for internal_ip_result in internal_ip_results: internal_ip_result.metadata.update(metadata) internal_ip_result.metadata['ip_type'] = 'internal' results.extend(internal_ip_results) return results
def Run(benchmark_spec): """Measure TCP stream throughput between two VMs. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. Returns: A list of sample.Sample objects with the benchmark results. """ vm_sets = [(benchmark_spec.vms[0], benchmark_spec.vms[1]), (benchmark_spec.vms[1], benchmark_spec.vms[0])] parsed_configs = ntttcp.ParseConfigList() # Keep accounting of failed configs. failed_confs = [] # Send traffic in both directions for ((sender, receiver), conf) in itertools.product(vm_sets, parsed_configs): # Send using external IP addresses if vm_util.ShouldRunOnExternalIpAddress(conf.ip_type): if not _RunTest(benchmark_spec, sender, receiver, receiver.ip_address, 'external', conf, True): failed_confs.append(('external', conf)) # Send using internal IP addresses if vm_util.ShouldRunOnInternalIpAddress(sender, receiver, conf.ip_type): if not _RunTest(benchmark_spec, sender, receiver, receiver.internal_ip, 'internal', conf, len(parsed_configs) > 1): failed_confs.append(('internal', conf)) if failed_confs: logging.info('Failed to run test and/or gather results for %s', str(failed_confs)) return []
def Run(benchmark_spec): """Run iperf on the target vm. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. Returns: A list of sample.Sample objects. """ vms = benchmark_spec.vms results = [] logging.info('Iperf Results:') for protocol in FLAGS.iperf_benchmarks: for thread_count in FLAGS.iperf_sending_thread_count: # Send traffic in both directions for sending_vm, receiving_vm in vms, reversed(vms): # Send using external IP addresses if vm_util.ShouldRunOnExternalIpAddress(): results.append( _RunIperf(sending_vm, receiving_vm, receiving_vm.ip_address, thread_count, vm_util.IpAddressMetadata.EXTERNAL, protocol)) # Send using internal IP addresses if vm_util.ShouldRunOnInternalIpAddress( sending_vm, receiving_vm): results.append( _RunIperf(sending_vm, receiving_vm, receiving_vm.internal_ip, thread_count, vm_util.IpAddressMetadata.INTERNAL, protocol)) return results