Esempio n. 1
0
def refdata(request):
    """returns a patched RefDataManager for testing purpose"""

    import os
    from treeherder.model.derived import RefDataManager
    from tests.conftest import add_test_procs_file

    refdata = RefDataManager()

    proc_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                             'refdata_test.json')

    add_test_procs_file(refdata.dhub, 'reference', proc_path)

    def fin():
        refdata.disconnect()

    request.addfinalizer(fin)

    return refdata
Esempio n. 2
0
    def _handle(self, *args, **options):
        if len(args) != 2:
            raise CommandError("Need to specify (only) branch and changeset")

        (project, changeset) = args

        # get reference to repo
        rdm = RefDataManager()
        repos = filter(lambda x: x['name'] == project,
                       rdm.get_all_repository_info())
        if not repos:
            raise CommandError("No project found named '%s'" % project)
        repo = repos[0]

        # make sure all tasks are run synchronously / immediately
        settings.CELERY_ALWAYS_EAGER = True

        # get hg pushlog
        pushlog_url = '%s/json-pushes/?full=1' % repo['url']

        # ingest this particular revision for this project
        process = HgPushlogProcess()
        # Use the actual push SHA, in case the changeset specified was a tag
        # or branch name (eg tip). HgPushlogProcess returns the full SHA, but
        # job ingestion expects the short version, so we truncate it.
        push_sha = process.run(pushlog_url, project, changeset=changeset)[0:12]

        self._process_all_objects_for_project(project)

        Builds4hJobsProcess().run(filter_to_project=project,
                                  filter_to_revision=push_sha,
                                  filter_to_job_group=options['filter_job_group'])
        PendingJobsProcess().run(filter_to_project=project,
                                 filter_to_revision=push_sha,
                                 filter_to_job_group=options['filter_job_group'])
        RunningJobsProcess().run(filter_to_project=project,
                                 filter_to_revision=push_sha,
                                 filter_to_job_group=options['filter_job_group'])

        self._process_all_objects_for_project(project)