예제 #1
0
    def test_regression_can_get_regression_base_target_pair(self):

        results = {}
        resultutils.append_resultsdata(results, ResultToolTests.base_results_data)
        resultutils.append_resultsdata(results, ResultToolTests.target_results_data)
        self.assertTrue('target_result1' in results['runtime/mydistro/qemux86/image'], msg="Pair not correct:%s" % results)
        self.assertTrue('target_result3' in results['runtime/mydistro/qemux86-64/image'], msg="Pair not correct:%s" % results)
    def test_regression_can_get_regression_base_target_pair(self):

        results = {}
        resultutils.append_resultsdata(results, ResultToolTests.base_results_data)
        resultutils.append_resultsdata(results, ResultToolTests.target_results_data)
        self.assertTrue('target_result1' in results['runtime/mydistro/qemux86/image'], msg="Pair not correct:%s" % results)
        self.assertTrue('target_result3' in results['runtime/mydistro/qemux86-64/image'], msg="Pair not correct:%s" % results)
예제 #3
0
def store(args, logger):
    tempdir = tempfile.mkdtemp(prefix='testresults.')
    try:
        results = {}
        logger.info('Reading files from %s' % args.source)
        if resultutils.is_url(args.source) or os.path.isfile(args.source):
            resultutils.append_resultsdata(results, args.source)
        else:
            for root, dirs,  files in os.walk(args.source):
                for name in files:
                    f = os.path.join(root, name)
                    if name == "testresults.json":
                        resultutils.append_resultsdata(results, f)
                    elif args.all:
                        dst = f.replace(args.source, tempdir + "/")
                        os.makedirs(os.path.dirname(dst), exist_ok=True)
                        shutil.copyfile(f, dst)

        revisions = {}

        if not results and not args.all:
            if args.allow_empty:
                logger.info("No results found to store")
                return 0
            logger.error("No results found to store")
            return 1

        # Find the branch/commit/commit_count and ensure they all match
        for suite in results:
            for result in results[suite]:
                config = results[suite][result]['configuration']['LAYERS']['meta']
                revision = (config['commit'], config['branch'], str(config['commit_count']))
                if revision not in revisions:
                    revisions[revision] = {}
                if suite not in revisions[revision]:
                    revisions[revision][suite] = {}
                revisions[revision][suite][result] = results[suite][result]

        logger.info("Found %d revisions to store" % len(revisions))

        for r in revisions:
            results = revisions[r]
            keywords = {'commit': r[0], 'branch': r[1], "commit_count": r[2]}
            subprocess.check_call(["find", tempdir, "!", "-path", "./.git/*", "-delete"])
            resultutils.save_resultsdata(results, tempdir, ptestlogs=True)

            logger.info('Storing test result into git repository %s' % args.git_dir)

            gitarchive.gitarchive(tempdir, args.git_dir, False, False,
                                  "Results of {branch}:{commit}", "branch: {branch}\ncommit: {commit}", "{branch}",
                                  False, "{branch}/{commit_count}-g{commit}/{tag_number}",
                                  'Test run #{tag_number} of {branch}:{commit}', '',
                                  [], [], False, keywords, logger)

    finally:
        subprocess.check_call(["rm", "-rf",  tempdir])

    return 0
예제 #4
0
def store(args, logger):
    tempdir = tempfile.mkdtemp(prefix='testresults.')
    try:
        results = {}
        logger.info('Reading files from %s' % args.source)
        if os.path.isfile(args.source):
            resultutils.append_resultsdata(results, args.source)
        else:
            for root, dirs,  files in os.walk(args.source):
                for name in files:
                    f = os.path.join(root, name)
                    if name == "testresults.json":
                        resultutils.append_resultsdata(results, f)
                    elif args.all:
                        dst = f.replace(args.source, tempdir + "/")
                        os.makedirs(os.path.dirname(dst), exist_ok=True)
                        shutil.copyfile(f, dst)

        revisions = {}

        if not results and not args.all:
            if args.allow_empty:
                logger.info("No results found to store")
                return 0
            logger.error("No results found to store")
            return 1

        # Find the branch/commit/commit_count and ensure they all match
        for suite in results:
            for result in results[suite]:
                config = results[suite][result]['configuration']['LAYERS']['meta']
                revision = (config['commit'], config['branch'], str(config['commit_count']))
                if revision not in revisions:
                    revisions[revision] = {}
                if suite not in revisions[revision]:
                    revisions[revision][suite] = {}
                revisions[revision][suite][result] = results[suite][result]

        logger.info("Found %d revisions to store" % len(revisions))

        for r in revisions:
            results = revisions[r]
            keywords = {'commit': r[0], 'branch': r[1], "commit_count": r[2]}
            subprocess.check_call(["find", tempdir, "!", "-path", "./.git/*", "-delete"])
            resultutils.save_resultsdata(results, tempdir, ptestlogs=True)

            logger.info('Storing test result into git repository %s' % args.git_dir)

            gitarchive.gitarchive(tempdir, args.git_dir, False, False,
                                  "Results of {branch}:{commit}", "branch: {branch}\ncommit: {commit}", "{branch}",
                                  False, "{branch}/{commit_count}-g{commit}/{tag_number}",
                                  'Test run #{tag_number} of {branch}:{commit}', '',
                                  [], [], False, keywords, logger)

    finally:
        subprocess.check_call(["rm", "-rf",  tempdir])

    return 0
예제 #5
0
def store(args, logger):
    tempdir = tempfile.mkdtemp(prefix='testresults.')
    try:
        results = {}
        logger.info('Reading files from %s' % args.source)
        for root, dirs, files in os.walk(args.source):
            for name in files:
                f = os.path.join(root, name)
                if name == "testresults.json":
                    resultutils.append_resultsdata(results, f)
                elif args.all:
                    dst = f.replace(args.source, tempdir + "/")
                    os.makedirs(os.path.dirname(dst), exist_ok=True)
                    shutil.copyfile(f, dst)
        resultutils.save_resultsdata(results, tempdir)

        if not results and not args.all:
            if args.allow_empty:
                logger.info("No results found to store")
                return 0
            logger.error("No results found to store")
            return 1

        keywords = {'branch': None, 'commit': None, 'commit_count': None}

        # Find the branch/commit/commit_count and ensure they all match
        for suite in results:
            for result in results[suite]:
                config = results[suite][result]['configuration']['LAYERS'][
                    'meta']
                for k in keywords:
                    if keywords[k] is None:
                        keywords[k] = config.get(k)
                    if config.get(k) != keywords[k]:
                        logger.error(
                            "Mismatched source commit/branch/count: %s vs %s" %
                            (config.get(k), keywords[k]))
                        return 1

        logger.info('Storing test result into git repository %s' %
                    args.git_dir)

        gitarchive.gitarchive(
            tempdir, args.git_dir, False, False,
            "Results of {branch}:{commit}",
            "branch: {branch}\ncommit: {commit}", "{branch}", False,
            "{branch}/{commit_count}-g{commit}/{tag_number}",
            'Test run #{tag_number} of {branch}:{commit}', '', [], [], False,
            keywords, logger)

    finally:
        subprocess.check_call(["rm", "-rf", tempdir])

    return 0
예제 #6
0
 def test_merge_can_merged_results(self):
     results = {}
     resultutils.append_resultsdata(results,
                                    ResultToolTests.base_results_data,
                                    configmap=resultutils.flatten_map)
     resultutils.append_resultsdata(results,
                                    ResultToolTests.target_results_data,
                                    configmap=resultutils.flatten_map)
     self.assertEqual(len(results[''].keys()),
                      5,
                      msg="Flattened results not correct %s" % str(results))
예제 #7
0
def merge(args, logger):
    if resultutils.is_url(args.target_results) or os.path.isdir(args.target_results):
        results = resultutils.load_resultsdata(args.target_results, configmap=resultutils.store_map)
        resultutils.append_resultsdata(results, args.base_results, configmap=resultutils.store_map)
        resultutils.save_resultsdata(results, args.target_results)
    else:
        results = resultutils.load_resultsdata(args.base_results, configmap=resultutils.flatten_map)
        if os.path.exists(args.target_results):
            resultutils.append_resultsdata(results, args.target_results, configmap=resultutils.flatten_map)
        resultutils.save_resultsdata(results, os.path.dirname(args.target_results), fn=os.path.basename(args.target_results))

    return 0
예제 #8
0
def merge(args, logger):
    configvars = {}
    if not args.not_add_testseries:
        configvars = resultutils.extra_configvars.copy()
    if args.executed_by:
        configvars['EXECUTED_BY'] = args.executed_by
    if resultutils.is_url(args.target_results) or os.path.isdir(args.target_results):
        results = resultutils.load_resultsdata(args.target_results, configmap=resultutils.store_map, configvars=configvars)
        resultutils.append_resultsdata(results, args.base_results, configmap=resultutils.store_map, configvars=configvars)
        resultutils.save_resultsdata(results, args.target_results)
    else:
        results = resultutils.load_resultsdata(args.base_results, configmap=resultutils.flatten_map, configvars=configvars)
        if os.path.exists(args.target_results):
            resultutils.append_resultsdata(results, args.target_results, configmap=resultutils.flatten_map, configvars=configvars)
        resultutils.save_resultsdata(results, os.path.dirname(args.target_results), fn=os.path.basename(args.target_results))

    logger.info('Merged results to %s' % os.path.dirname(args.target_results))

    return 0
예제 #9
0
def merge(args, logger):
    if os.path.isdir(args.target_results):
        results = resultutils.load_resultsdata(args.target_results,
                                               configmap=resultutils.store_map)
        resultutils.append_resultsdata(results,
                                       args.base_results,
                                       configmap=resultutils.store_map)
        resultutils.save_resultsdata(results, args.target_results)
    else:
        results = resultutils.load_resultsdata(
            args.base_results, configmap=resultutils.flatten_map)
        if os.path.exists(args.target_results):
            resultutils.append_resultsdata(results,
                                           args.target_results,
                                           configmap=resultutils.flatten_map)
        resultutils.save_resultsdata(results,
                                     os.path.dirname(args.target_results),
                                     fn=os.path.basename(args.target_results))

    return 0
 def test_merge_can_merged_results(self):
     results = {}
     resultutils.append_resultsdata(results, ResultToolTests.base_results_data, configmap=resultutils.flatten_map)
     resultutils.append_resultsdata(results, ResultToolTests.target_results_data, configmap=resultutils.flatten_map)
     self.assertEqual(len(results[''].keys()), 5, msg="Flattened results not correct %s" % str(results))