Esempio n. 1
0
    def analyze(self, datadir, resultdir, noreanalyze):
        if not os.path.isdir(datadir):
            logging.debug('"%s" does not exist. Skipping', datadir)
            return {}

        etce_stores = []
        for dirname, _, filenames in os.walk(datadir):
            if 'etce.store' in filenames:
                etce_stores.append(os.path.join(dirname, 'etce.store'))

        ws = WrapperStore(os.path.join(sorted(etce_stores)[0]))

        store_values = list(ws.read().values())

        starttimestr = store_values[0]['etce']['starttime']

        dt = etce.timeutils.strtimetodatetime(starttimestr)

        starttime = time.mktime(dt.timetuple())

        mgr = AnalyzerManager(self._analyzerconfig)

        # process individual data files
        trialfilesmap = defaultdict(lambda: [])

        for hostname in sorted(os.listdir(datadir)):
            hostdir = os.path.join(datadir, hostname)

            if not os.path.isdir(hostdir):
                continue

            for datafile in sorted(os.listdir(hostdir)):
                # return a map where the key is the name of any analyzer that
                # operates on datafile, and values are the node output files generated
                # by that analyzer
                resultfilesmap = mgr.analyzefile(
                    PathInfo(datadir, hostname, datafile), resultdir,
                    noreanalyze)

                for analyzer, resultfiles in resultfilesmap.items():
                    trialfilesmap[analyzer].extend(resultfiles)

        # then combine the results
        combinedfiles = defaultdict(lambda: None)

        for analyzer, trialfiles in trialfilesmap.items():

            if len(trialfiles) == 0:
                continue

            combinedfiles[analyzer] = mgr.combinetrialresults(
                trialfiles, resultdir, analyzer, starttime)

        return combinedfiles
    def __init__(self, wrappername, wrapperinstance, trialargs, testargs,
                 config, testdir):
        self._trialargs = trialargs
        self._testargs = testargs
        self._config = config
        self._testdir = testdir
        self._platform = Platform()
        self._wrappername = wrappername
        self._sudo = False
        self._default_pidfilename = \
            '%s/etce.%s.%s.pid' \
            % (os.path.join(self._config.get('etce', 'WORK_DIRECTORY'), 'lock'),
               self.platform.hostname(),
               self._wrappername)

        self._description = wrapperinstance.__doc__

        # start with reserved args set here ...
        self._args = {
            'default_pidfilename': self._default_pidfilename,
            'nodename': self._testdir.nodename(),
            'nodeid': self._testdir.nodeid(),
            'testname': self._testdir.name(),
            'wrappername': self._wrappername,
            'infile': None,
            'outfile': None
        }

        # ... and the ones passed in
        self._args.update(trialargs)

        # these are the reserved args that cannot be overwritten
        self._reserved_args = set(self._args)

        # fill in the arguments registered by the wrapper
        wrapperinstance.register(self)

        storefile = os.path.join(self._trialargs['logdirectory'], 'etce.store')

        self._wrapperstore = WrapperStore(storefile)

        self._wrapperstore.update(
            {'etce': {
                'starttime': self._trialargs['starttime']
            }}, self._args['nodename'])