예제 #1
0
  def go(self):
    """
    Run the performance tests.
    """
    self._select_nodes()

    test_cases = self.test_params.generate(self.attributes)
    if len(test_cases) == 0:
      _log.warning('No test cases')
      return 0

    try:
      self._ensure_out_dir(test_cases[0].run_id)
      self._reset_client()
      self._create_test_services()

      last_deploy_yaml = None
      last_config_yaml = None
      for test_case in test_cases:
        try:
          inputs = Inputs(self.deployment_yaml, self.configmap_yaml,
                          ['/dnsperf', '-s', self.args.dns_ip])
          test_case.configure(inputs)
          # pin server to a specific node
          inputs.deployment_yaml['spec']['template']['spec']['nodeName'] = \
              self.server_node

          if not self.use_existing and (
              yaml.dump(inputs.deployment_yaml) !=
              yaml.dump(last_deploy_yaml) or
              yaml.dump(inputs.configmap_yaml) !=
              yaml.dump(last_config_yaml)):
            _log.info('Creating server with new parameters')
            self._teardown()
            self._create(inputs.deployment_yaml)
            self._create(self.service_yaml)
            if self.configmap_yaml is not None:
              self._create(self.configmap_yaml)
            self._wait_for_status(True)

          self._run_perf(test_case, inputs)
          last_deploy_yaml = inputs.deployment_yaml
          last_config_yaml = inputs.configmap_yaml

        except Exception:
          _log.info('Exception caught during run, cleaning up. %s',
                    traceback.format_exc())
          self._teardown()
          self._teardown_client()
          raise

    finally:
      self._teardown()
      self._teardown_client()

      if self.db is not None:
        self.db.commit()

    return 0
예제 #2
0
  def test_params(self):
    values = {
        'dnsmasq_cpu': 100,
        'dnsmasq_cache': 200,
        'kubedns_cpu': 300,
        'max_qps': 400,
        'query_file': 'abc',
        'run_length_seconds': 120,
    }

    inputs = Inputs(make_mock_yaml(), None, [])
    for param in PARAMETERS:
      if param.name not in values:
        continue
      param.set(inputs, values[param.name])

    self.assertEquals(
        '100m',
        inputs.deployment_yaml['spec']['template']['spec']['containers']\
            [1]['resources']['limits']['cpu'])
    self.assertTrue(
        '--cache-size=200' in
        inputs.deployment_yaml['spec']['template']['spec']['containers']\
            [1]['args'])
    self.assertEquals(
        '300m',
        inputs.deployment_yaml['spec']['template']['spec']['containers']\
            [0]['resources']['limits']['cpu'])
    self.assertEquals(
        '-l,120,-Q,400,-d,/queries/abc',
        ','.join(inputs.dnsperf_cmdline))
예제 #3
0
  def test_null_params(self):
    # These should result in no limits.
    values = {
        'dnsmasq_cpu': None,
        'dnsmasq_cache': 100,
        'kubedns_cpu': None,
        'max_qps': None,
        'query_file': 'abc',
        'run_length_seconds': 120,
    }

    inputs = Inputs(make_mock_yaml(), None, [])
    for param in PARAMETERS:
      if param.name not in values:
        continue
      param.set(inputs, values[param.name])

    self.assertTrue(
        'cpu' not in inputs.deployment_yaml\
        ['spec']['template']['spec']['containers'][0]['resources']['limits'])
    self.assertTrue(
        'cpu' not in inputs.deployment_yaml\
        ['spec']['template']['spec']['containers'][1]['resources']['limits'])
    self.assertEquals(
        '-l,120,-d,/queries/abc',
        ','.join(inputs.dnsperf_cmdline))
예제 #4
0
    def test_coredns_params(self):
        values = {
            'coredns_cpu': 100,
            'coredns_cache': 200,
        }

        inputs = Inputs(make_mock_coredns_deployment_yaml(),
                        make_mock_coredns_configmap_yaml(), [])

        for param in PARAMETERS:
            if param.name not in values:
                continue
            param.set(inputs, values[param.name])

        self.assertTrue(
            "success 200" in inputs.configmap_yaml['data']['Corefile'])
        self.assertTrue(
            "denial 200" in inputs.configmap_yaml['data']['Corefile'])
        self.assertEqual(
            '100m', inputs.deployment_yaml['spec']['template']['spec']
            ['containers'][0]['resources']['limits']['cpu'])
예제 #5
0
  def go(self):
    """
    Run the performance tests.
    """
    self._select_nodes()

    test_cases = self.test_params.generate(self.attributes)
    if len(test_cases) == 0:
      _log.warning('No test cases')
      return 0

    try:
      self._ensure_out_dir(test_cases[0].run_id)
      client_pods=self._reset_client()
      _log.info('Starting creation of test services')
      self._create_test_services()

      last_deploy_yaml = None
      last_config_yaml = None
      for test_case in test_cases:
        try:
          inputs = Inputs(self.deployment_yaml, self.configmap_yaml,
                          ['/dnsperf', '-s', self.args.dns_ip])
          test_case.configure(inputs)
          # pin server to a specific node
          inputs.deployment_yaml['spec']['template']['spec']['nodeName'] = \
              self.server_node

          if not self.use_existing and (
              yaml.dump(inputs.deployment_yaml) !=
              yaml.dump(last_deploy_yaml) or
              yaml.dump(inputs.configmap_yaml) !=
              yaml.dump(last_config_yaml)):
            _log.info('Creating server with new parameters')
            self._teardown()
            self._create(inputs.deployment_yaml)
            self._create(self.service_yaml)
            if self.configmap_yaml is not None:
              self._create(self.configmap_yaml)
            self._wait_for_status(True)
          test_threads=[]
          #Spawn off a thread to run the test case in each client pod simultaneously.
          for podname in client_pods:
            _log.debug('Running test in pod %s', podname)
            tc = copy.copy(test_case)
            tc.pod_name = podname
            dt = threading.Thread(target=self._run_perf,args=[tc,inputs, podname])
            test_threads.append(dt)
            dt.start()
          for thread in test_threads:
            thread.join()
          last_deploy_yaml = inputs.deployment_yaml
          last_config_yaml = inputs.configmap_yaml

        except Exception:
          _log.info('Exception caught during run, cleaning up. %s',
                    traceback.format_exc())
          self._teardown()
          self._teardown_client()
          raise

    finally:
      self._teardown()
      self._teardown_client()

      if self.db is not None:
        self.db.commit()

    return 0