def Prepare(benchmark_spec):
  """Install ntttcp and open any ports we need."""
  vms = benchmark_spec.vms

  for vm in vms:
    vm.Install('ntttcp')
    vm.AllowPort(ntttcp.CONTROL_PORT)
    # get the number of ports needed based on the flags
    num_ports = max([c.threads for c in ntttcp.ParseConfigList()])
    vm.AllowPort(ntttcp.BASE_DATA_PORT, ntttcp.BASE_DATA_PORT + num_ports)
 def testEmptyConfig(self):
     ntttcp.FLAGS.ntttcp_config_list = []
     expected_list = [
         NtttcpConf(udp=FLAGS.ntttcp_udp,
                    threads=FLAGS.ntttcp_threads,
                    time_s=FLAGS.ntttcp_time,
                    ip_type=FLAGS.ip_addresses,
                    packet_size=FLAGS.ntttcp_packet_size)
     ]
     conf_list = ntttcp.ParseConfigList()
     self.assertListEqual(conf_list, expected_list)
 def testSingleConfigParse(self):
     ntttcp.FLAGS.ntttcp_config_list = ['True:7:800:INTERNAL:1']
     expected_list = [
         NtttcpConf(udp=True,
                    threads=7,
                    time_s=800,
                    ip_type='INTERNAL',
                    packet_size=1)
     ]
     conf_list = ntttcp.ParseConfigList()
     self.assertListEqual(conf_list, expected_list)
Exemple #4
0
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 testMultiConfigParse(self):
     ntttcp.FLAGS.ntttcp_config_list = [
         'True:7:800:INTERNAL:1', 'False:1:2:EXTERNAL:2',
         'True:44:1001:INTERNAL:3'
     ]
     expected_list = [
         NtttcpConf(udp=True,
                    threads=7,
                    time_s=800,
                    ip_type='INTERNAL',
                    packet_size=1),
         NtttcpConf(udp=False,
                    threads=1,
                    time_s=2,
                    ip_type='EXTERNAL',
                    packet_size=2),
         NtttcpConf(udp=True,
                    threads=44,
                    time_s=1001,
                    ip_type='INTERNAL',
                    packet_size=3),
     ]
     conf_list = ntttcp.ParseConfigList()
     self.assertListEqual(conf_list, expected_list)