Exemplo n.º 1
0
def setTestParameters(hostname, transactions, multithreaded, workspace, rundir, apps, scenarioTypes, recordPMC):
  """
  A method run at the beginning of tests to create and enter a REMOTE environment
  and at the end of tests to exit the REMOTE environment

 @param hostname: An option added to the pytest parser to accept a REMOTE host
                   Defaults to 127.0.0.1
  @type hostname: C{str}
  """
  from xpedite.util              import makeLogPath
  from xpedite.transport.net     import isIpLocal
  from xpedite.transport.remote  import Remote
  from xpedite.util.probeFactory import ProbeIndexFactory
  remote = None
  global CONTEXT, CAN_RECORD_PMC # pylint: disable=global-statement
  ProbeIndexFactory.reset()
  if not isIpLocal(hostname):
    remote = Remote(hostname, makeLogPath('remote'))
    remote.__enter__()
  CAN_RECORD_PMC = recordPMC
  CONTEXT = Context(transactions, multithreaded, workspace)
  SCENARIO_LOADER.loadScenarios(rundir, apps, scenarioTypes, remote)
  yield
  if remote:
    remote.__exit__(None, None, None)
Exemplo n.º 2
0
  def gatherCounters(self, app, loader):
    """
    Gathers time and pmu counters from sample files for the current profile session

    :param app: Handle to the instance of the xpedite app
    :type app: xpedite.profiler.environment.XpediteApp
    :param loader: Loader to build transactions out of the counters

    """
    pattern = app.sampleFilePattern()
    LOGGER.info('scanning for samples files matching - %s', pattern)
    filePaths = app.gatherFiles(pattern)

    samplePath = makeLogPath('{}/{}'.format(app.name, app.runId))
    dataSource = DataSource(app.appInfoPath, samplePath)
    loader.beginCollection(dataSource)

    for filePath in filePaths:
      (threadId, tlsAddr) = self.extractThreadInfo(filePath)
      if not threadId or not tlsAddr:
        raise Exception('failed to extract thread info for file {}'.format(filePath))
      LOGGER.info('loading counters for thread %s from file %s -> ', threadId, filePath)

      iterBegin = begin = time.time()
      loader.beginLoad(threadId, tlsAddr)
      inflateFd = self.openInflateFile(samplePath, threadId, tlsAddr)
      extractor = subprocess.Popen([self.samplesLoader, filePath],
        bufsize=2*1024*1024, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
      recordCount = 0
      while True:
        record = extractor.stdout.readline()
        if record.strip() == '':
          if extractor.poll() is not None:
            errmsg = extractor.stderr.read()
            if errmsg:
              raise Exception('failed to load {} - {}'.format(filePath, errmsg))
          break
        if inflateFd:
          inflateFd.write(record)
        if recordCount > 0:
          self.loadCounter(threadId, loader, app.probes, record)
          elapsed = time.time() - iterBegin
          if elapsed >= 5:
            LOGGER.completed('\n\tprocessed %d counters | ', recordCount-1)
            iterBegin = time.time()
        recordCount += 1
      loader.endLoad()
      if inflateFd:
        inflateFd.close()
      elapsed = time.time() - begin
      self.logCounterFilterReport()
      if self.orphanedRecords:
        LOGGER.warn('detected mismatch in binary vs app info - %d counters ignored', len(self.orphanedRecords))
      LOGGER.completed('%d records | %d txns loaded in %0.2f sec.', recordCount-1, loader.getCount(), elapsed)
    if loader.isCompromised() or loader.getTxnCount() <= 0:
      LOGGER.warn(loader.report())
    elif loader.isNotAccounted():
      LOGGER.debug(loader.report())
    loader.endCollection()
Exemplo n.º 3
0
    def __init__(self, ip, appInfoPath, dryRun):
        """
    Constructs an instance of Remote environment

    :param ip: Name or ip address of the host where target application is running
    :type ip: str
    :param appInfoPath: Path to appInfo file of the target process
    :type appInfoPath: str
    :param dryRun: Flag to enable simlulation of target application
    :type dryRun: bool

    """
        Environment.__init__(self, ip, appInfoPath, dryRun)
        LOGGER.debug('Registered rpyc channel to %s ', ip)
        from xpedite.util import makeLogPath
        self.remote = Remote(ip, makeLogPath('remote'), chdir=False)
Exemplo n.º 4
0
def set_hostname(hostname):
    """
  A method run at the beginning of tests to create and enter a remote environment
  and at the end of tests to exit the remote environment

  @param hostname: An option added to the pytest parser to accept a remote host
                   Defaults to 127.0.0.1
  @type hostname: C{str}
  """
    from xpedite.util import makeLogPath
    from xpedite.transport.net import isIpLocal
    from xpedite.transport.remote import Remote
    global remote
    if not isIpLocal(hostname):
        remote = Remote(hostname, makeLogPath('remote'))
        remote.__enter__()
    yield
    if remote:
        remote.__exit__(None, None, None)
Exemplo n.º 5
0
def setTestParameters(hostname, transactions, multithreaded, workspace,
                      tempdir):
    """
  A method run at the beginning of tests to create and enter a REMOTE environment
  and at the end of tests to exit the REMOTE environment

 @param hostname: An option added to the pytest parser to accept a REMOTE host
                   Defaults to 127.0.0.1
  @type hostname: C{str}
  """
    from xpedite.util import makeLogPath
    from xpedite.transport.net import isIpLocal
    from xpedite.transport.remote import Remote
    global DATA_DIR, REMOTE, TXN_COUNT, THREAD_COUNT, WORKSPACE  # pylint: disable=global-statement
    if not isIpLocal(hostname):
        REMOTE = Remote(hostname, makeLogPath('remote'))
        REMOTE.__enter__()
    TXN_COUNT = transactions
    THREAD_COUNT = multithreaded
    WORKSPACE = workspace
    DATA_DIR = os.path.join(tempdir, 'slowFixDecoder')
    yield
    if REMOTE:
        REMOTE.__exit__(None, None, None)
Exemplo n.º 6
0
 def __init__(self, mode):
     from xpedite.util import makeLogPath
     path = '{}/xpedite.log'.format(makeLogPath())
     logging.FileHandler.__init__(self, path, mode)