Logo Search packages:      
Sourcecode: namebench version File versions  Download package

def libnamebench::benchmark::Benchmark::CreateTests (   self,
  input_data,
  select_mode = 'weighted' 
)

Load test input data input, and create tests from it.

Args:
  input_data: a list of hostnames to benchmark against.
  select_mode: how to randomly select which hostnames to use. Valid modes:
           weighted, random, chunk

Returns:
  A list of tuples containing record_type (str) and hostname (str)

Raises:
  ValueError: If select_mode is incorrect.

Definition at line 81 of file benchmark.py.

00081                                                            :
    """Load test input data input, and create tests from it.

    Args:
      input_data: a list of hostnames to benchmark against.
      select_mode: how to randomly select which hostnames to use. Valid modes:
                   weighted, random, chunk

    Returns:
      A list of tuples containing record_type (str) and hostname (str)

    Raises:
      ValueError: If select_mode is incorrect.
    """
    if select_mode == 'weighted' and len(input_data) != len(set(input_data)):
      print '* input contains duplicates, switching select_mode to random'
      select_mode = 'random'
    if select_mode == 'weighted':
      selected = selectors.WeightedDistribution(input_data, self.test_count)
    elif select_mode == 'chunk':
      selected = selectors.ChunkSelect(input_data, self.test_count)
    elif select_mode == 'random':
      selected = selectors.RandomSelect(input_data, self.test_count)
    else:
      raise ValueError('Invalid select_mode: %s' % select_mode)

    self.test_data = []
    for line in selected:
      selection = line.rstrip()
      if len(selection) < 2:
        continue

      if ' ' in selection:
        self.test_data.append(selection.split(' ')[0:2])
      else:
        self.test_data.append(('A', self.GenerateFqdn(selection)))

    assert self.test_data
    return self.test_data

  def GenerateFqdn(self, domain):


Generated by  Doxygen 1.6.0   Back to index