コード例 #1
0
    def run(self, args, shell=False, clean_return=True):
        argument_string = " ".join(args)
        self.logger.log("Mocked Command executed",
                        argument_string,
                        level=LogLevel.Info)

        stdout = ""
        for m in self.mappings:
            if argument_string.startswith(m):
                stdout = self.mappings[m]
                break
        return Struct(**{'stdout': Struct(**{'decode': lambda: stdout})})
コード例 #2
0
def DEFAULT_EXPECTED_VALUES(new_library_version_func):
    return Struct(
        **{
            'new_version_id': new_library_version_func,
            'filed_bug_id': 50,
            'ff_version': 87
        })
コード例 #3
0
ファイル: database.py プロジェクト: bhearsum/updatebot
    def testJobs(self):
        library = Struct(**{
            'name': 'test_library',
            'yaml_path': 'path/to/moz.yaml',
        })
        version = "test_new_version"
        bugid = 50
        phab_revision = 30
        try_link = "test_try_link"

        try:
            self.assertEqual(None, self.db.get_job(library, version))

            self.db.create_job(JOBTYPE.VENDORING, library, version,
                               JOBSTATUS.AWAITING_INITIAL_PLATFORM_TRY_RESULTS,
                               JOBOUTCOME.PENDING, bugid, phab_revision,
                               try_link, 'db test')

            newJob = self.db.get_job(library, version)
            self.assertNotEqual(None, newJob)
            self.assertEqual(newJob.type, JOBTYPE.VENDORING)
            self.assertEqual(newJob.ff_version, 88)
            self.assertEqual(newJob.library_shortname, library.name)
            self.assertEqual(newJob.version, version)
            self.assertEqual(newJob.status,
                             JOBSTATUS.AWAITING_INITIAL_PLATFORM_TRY_RESULTS)
            self.assertEqual(newJob.outcome, JOBOUTCOME.PENDING)
            self.assertEqual(newJob.bugzilla_id, bugid)
            self.assertEqual(newJob.phab_revision, phab_revision)
            self.assertEqual(len(newJob.try_runs), 1)
            self.assertEqual(newJob.try_runs[0].revision, try_link)
            self.assertEqual(newJob.try_runs[0].job_id, newJob.id)
            self.assertEqual(newJob.try_runs[0].purpose, 'db test')
        finally:
            self.db.delete_job(job_id=newJob.id)
コード例 #4
0
 def testFile(self):
     library = Struct(**{
         'shortname': 'dav1d',
         'bugzilla_product': 'Core',
         'bugzilla_component': 'ImageLib',
     })
     t = Thread(target=self.server.handle_request)
     t.start()
     self.bugzillaProvider.file_bug(library, 'V1')
     t.join()
コード例 #5
0
def DEFAULT_EXPECTED_VALUES(revision):
    # This is a bit confusing; but we use the same SHA hash for the (fake) library revision
    # we are updating to as the try revision we are return from fake-taskcluster
    return Struct(
        **{
            'library_version_id': revision,
            'filed_bug_id': 50,
            'try_revision_id': revision,
            'phab_revision': 83119
        })
コード例 #6
0
    def run(self, args, shell=False, clean_return=True):
        argument_string = " ".join(args)
        self.logger.log("Mocked Command executed", argument_string, level=LogLevel.Info)

        stdout = None
        for m in self.mappings:
            if argument_string.startswith(m):
                if self.mappings[m] == DO_EXECUTE:
                    if not self.real_runner:
                        raise Exception("TestCommandProvider was asked to really execute something; but doesn't have a means to do so")
                    return self.real_runner.run(args, shell=shell, clean_return=clean_return)
                else:
                    stdout = self.mappings[m]
                    self.logger.log("We found a mapped response, providing it.", level=LogLevel.Info)
                    self.logger.log("---\n%s\n---" % stdout, level=LogLevel.Debug2)
                break

        if stdout is None:
            self.logger.log("We did not find a mapped response for the command `%s`." % argument_string, level=LogLevel.Warning)
        return Struct(**{'stdout':
                         Struct(**{'decode': lambda: stdout})})
コード例 #7
0
ファイル: bugzilla.py プロジェクト: bhearsum/updatebot
 def testFile(self):
     library = Struct(
         **{
             'name': 'dav1d',
             'bugzilla_product': 'Core',
             'bugzilla_component': 'ImageLib',
         })
     self.bugzillaProvider.file_bug(
         library,
         CommentTemplates.UPDATE_SUMMARY(
             library, 'V1',
             string_date_to_uniform_string_date(
                 '2020-08-21T15:13:49.000+02:00')),
         "", ['*****@*****.**'], ['*****@*****.**'],
         210,
         110,
         moco_confidential=True)
コード例 #8
0
    def _transform_job_list(property_names, job_list):
        decision_task = None
        new_job_list = []
        # We will need to reference the decision task, so we find populate that here also.
        for j in job_list:
            d = {}
            for i in range(len(property_names)):
                d[property_names[i]] = j[i]

            job_obj = Struct(**d, decision_task=None)
            new_job_list.append(job_obj)

            if "Gecko Decision Task" == job_obj.job_type_name:
                decision_task = job_obj

        for j in new_job_list:
            j.decision_task = decision_task

        return new_job_list
コード例 #9
0
ファイル: db.py プロジェクト: bhearsum/updatebot
 def get_all_outcomes(self):
     query = "SELECT * FROM outcome_types ORDER BY id ASC"
     results = self._query_get_rows(query)
     return [Struct(**r) for r in results]
コード例 #10
0
ファイル: db.py プロジェクト: bhearsum/updatebot
 def get_configuration(self):
     query = "SELECT * FROM config"
     results = self._query_get_rows(query)
     return [Struct(**r) for r in results]
コード例 #11
0
ファイル: db.py プロジェクト: bhearsum/updatebot
# To support the --delete-database option, the key to this dictionary must be table_name|constraint_name
ALTER_QUERIES = {
    'jobs|fk_job_outcome':
        "ALTER TABLE jobs ADD CONSTRAINT fk_job_outcome FOREIGN KEY (outcome) REFERENCES outcome_types(id)",
    'jobs|fk_job_status':
        "ALTER TABLE jobs ADD CONSTRAINT fk_job_status FOREIGN KEY (status) REFERENCES status_types(id)",
    'jobs|fk_job_type':
        "ALTER TABLE jobs ADD CONSTRAINT fk_job_type FOREIGN KEY (job_type) REFERENCES job_types(id)",
    'try_runs|fk_tryrun_job':
        "ALTER TABLE try_runs ADD CONSTRAINT fk_tryrun_job FOREIGN KEY (job_id) REFERENCES jobs(id)",
}

INSERTION_QUERIES = [
    Struct(**{
        'query': "INSERT INTO `config` (`k`, `v`) VALUES ('enabled', %s)",
        'args': (1)
    }),
    Struct(**{
        'query': "INSERT INTO `config` (`k`, `v`) VALUES ('database_version', %s)",
        'args': (CURRENT_DATABASE_CONFIG_VERSION)
    })
]

for p in dir(JOBSTATUS):
    if p[0] != '_':
        INSERTION_QUERIES.append(
            Struct(**{
                'query': "INSERT INTO `status_types` (`id`, `name`) VALUES (%s, %s)",
                'args': (getattr(JOBSTATUS, p), p)
            }))
コード例 #12
0
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from components.utilities import Struct
from components.logging import logEntryExit
from components.providerbase import BaseProvider, INeedsLoggingProvider
from components.logging import LogLevel
from components.dbmodels import Job, Library, JOBSTATUS

import pymysql

LIBRARIES = [
    Struct(
        **{
            'shortname': 'dav1d',
            'yaml_path': 'media/libdav1d/moz.yaml',
            'bugzilla_product': 'Core',
            'bugzilla_component': 'ImageLib',
            'fuzzy_query': "'build-linux64/debug"
            # 'fuzzy_query' : "'test 'gtest | 'media !'asan"
        })
]

# ==================================================================================


class HardcodedDatabase:
    def __init__(self, database_config):
        self.libraries = LIBRARIES

    def check_database(self):
        return 1
コード例 #13
0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os
from sentry_sdk import init as sentry_init, add_breadcrumb, capture_exception, configure_scope

from components.utilities import Struct
from components.providerbase import BaseProvider
from components.commandrunner import _run

LogLevel = Struct(**{
    'Fatal': 'fatal',
    'Error': 'error',
    'Warning': 'warning',
    'Info': 'info',
    'Debug': 'debug'
})


def logEntryExit(func):
    def func_wrapper(*args, **kwargs):
        obj = args[0]
        assert 'logger' in dir(obj), "If @logEntryExit is applied to a class method, it must inherit INeedsLoggingProvider"
        obj.logger.log("================================================", level=LogLevel.Debug)
        obj.logger.log("Beginning %s" % func.__qualname__, level=LogLevel.Info)
        obj.logger.log(" Arguments: %s" % str(args), level=LogLevel.Info)
        ret = func(*args, **kwargs)
        obj.logger.log("Ending %s" % func.__qualname__, level=LogLevel.Info)
        return ret
    return func_wrapper
コード例 #14
0
#!/usr/bin/env python3

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from components.utilities import Struct

JOBSTATUS = Struct(**{
    'COULD_NOT_VENDOR': 1,
    'VENDORED': 2,
    'AWAITING_TRY_RESULTS': 3
})


class Job:
    def __init__(self, row=None):
        if row:
            self.id = row['id']
            self.library_shortname = row['library']
            self.version = row['version']
            self.status = row['status']
            self.bugzilla_id = row['bugzilla_id']
            self.try_revision = row['try_revision']


class Library:
    def __init__(self, row=None):
        if row:
            self.id = row['id']
            self.shortname = row['shortname']