def testConfigurationPassing(self): configs = { 'General': {'env': 'dev', 'gecko-path': 'nowhere'}, 'Database': {'specialkey': 'database!'}, 'Vendor': {'specialkey': 'vendor!'}, 'Bugzilla': {'specialkey': 'bugzilla!'}, 'Mercurial': {'specialkey': 'mercurial!'}, 'Taskcluster': {'specialkey': 'taskcluster!'}, 'Phabricator': {'specialkey': 'phab!'}, 'Command': {'specialkey': 'command!'}, 'Logging': {'specialkey': 'logging!'}, } providers = { 'Database': TestConfigDatabaseProvider, 'Vendor': TestConfigVendorProvider, 'Bugzilla': TestConfigBugzillaProvider, 'Mercurial': TestConfigMercurialProvider, 'Taskcluster': TestConfigTaskclusterProvider, 'Phabricator': TestConfigPhabricatorProvider, 'Logging': TestConfigLoggingProvider, 'Command': TestConfigCommandProvider, } u = Updatebot(configs, providers) def assert_extra_key(x): self.assertTrue("!" in x.also_expected, "Extra key was not populated") u.runOnProviders(assert_extra_key)
def testFunctionalityWithRealDatabase(self): configs = { 'General': { 'env': 'dev' }, 'Command': { 'test_mappings': COMMAND_MAPPINGS }, 'Logging': localconfig['Logging'], 'Database': localconfig['Database'], 'Vendor': {}, 'Bugzilla': {}, 'Mercurial': {}, 'Taskcluster': {}, 'Phabricator': {}, } providers = { # Not Mocked At All 'Logging': LoggingProvider, # Fully Mocked 'Command': TestCommandProvider, # Not Mocked At All 'Database': DatabaseProvider, # Not Mocked At All 'Vendor': VendorProvider, # Fully Mocked 'Bugzilla': TestConfigBugzillaProvider, # Not Mocked At All 'Mercurial': MercurialProvider, # Not Mocked At All 'Taskcluster': TaskclusterProvider, # Not Mocked At All 'Phabricator': PhabricatorProvider, } u = Updatebot(configs, providers) u.run() # Check For Success for l in u.dbProvider.get_libraries(): j = u.dbProvider.get_job(l, TestConfigVendorProvider.version_id) self.assertNotEqual(j, None) self.assertEqual(l.shortname, j.library_shortname) self.assertEqual(TestConfigVendorProvider.version_id, j.version) self.assertEqual(JOBSTATUS.AWAITING_TRY_RESULTS, j.status) self.assertEqual(TestConfigBugzillaProvider.bug_id, j.bugzilla_id) self.assertEqual(TestConfigTaskclusterProvider.revision_id, j.try_revision) # Cleanup for l in u.dbProvider.get_libraries(): u.dbProvider.delete_job(l, TestConfigVendorProvider.version_id)
def testAlertAcrossFFVersions(self): library_filter = "aom" (u, expected_values) = TestFunctionality._setup( lambda: "0886ba657dedc54fad06018618cc07689198abea", lambda: "11c85fb14571c822e5f7f8b92a7e87749430b696", lambda: 1, lambda: 0, library_filter, keep_tmp_db=True) u.run(library_filter=library_filter) all_jobs = u.dbProvider.get_all_jobs() self.assertEqual( len([j for j in all_jobs if j.library_shortname != "dav1d"]), 1, "I should have created a single job.") self._check_job(all_jobs[0], expected_values) config_dictionary = copy.deepcopy(u.config_dictionary) config_dictionary['Database']['keep_tmp_db'] = False config_dictionary['General']['ff-version'] -= 1 expected_values.ff_version -= 1 config_dictionary['General'][ 'repo'] = "https://hg.mozilla.org/mozilla-beta" u = Updatebot(config_dictionary, PROVIDERS) u.run(library_filter=library_filter) expected_comment = CommentTemplates.COMMENT_ALSO_AFFECTS( config_dictionary['General']['ff-version'], config_dictionary['General']['repo']) self.assertEqual( config_dictionary['Bugzilla']['comment_filed'], expected_comment, "Did not file a comment matching the expected value.") all_jobs = u.dbProvider.get_all_jobs() self.assertEqual( len([j for j in all_jobs if j.library_shortname != "dav1d"]), 2, "I should have two jobs.") self._check_job(all_jobs[1], expected_values, outcome=JOBOUTCOME.CROSS_VERSION_STUB) TestFunctionality._cleanup(u, library_filter)
def _setup(try_revision, library_filter): db_config = transform_db_config_to_tmp_db(localconfig['Database']) configs = { 'General': { 'env': 'dev', 'gecko-path': '.', 'ff-version': '87', 'repo': 'https://hg.mozilla.org/mozilla-central' }, 'Command': { 'test_mappings': None }, 'Logging': localconfig['Logging'], 'Database': db_config, 'Vendor': {}, 'Bugzilla': { 'filed_bug_id': None }, 'Mercurial': {}, 'Taskcluster': { 'url_treeherder': 'http://localhost:27490/', 'url_taskcluster': 'http://localhost:27490/', }, 'Phabricator': {}, 'Library': { 'vendoring_revision_override': try_revision, } } providers = { # Not Mocked At All 'Logging': LoggingProvider, # Fully Mocked 'Command': TestCommandProvider, # Not Mocked At All 'Database': DatabaseProvider, # Not Mocked At All 'Vendor': VendorProvider, # Fully Mocked 'Library': MockLibraryProvider, # Fully Mocked, avoids needing to make a fake # bugzilla server which provides no additional logic coverage 'Bugzilla': MockedBugzillaProvider, # Not Mocked At All 'Mercurial': MercurialProvider, # Not Mocked At All, but does point to a fake server 'Taskcluster': TaskclusterProvider, # Not Mocked At All 'Phabricator': PhabricatorProvider, 'SCM': SCMProvider, } expected_values = DEFAULT_EXPECTED_VALUES(try_revision) configs['Bugzilla']['filed_bug_id'] = expected_values.filed_bug_id configs['Command']['test_mappings'] = COMMAND_MAPPINGS(expected_values) u = Updatebot(configs, providers) _check_jobs = functools.partial(TestFunctionality._check_jobs, u, library_filter, expected_values) # Ensure we don't have a dirty database with existing jobs tc = unittest.TestCase() for lib in u.libraryProvider.get_libraries( u.config_dictionary['General']['gecko-path']): for task in lib.tasks: if task.type != 'vendoring': continue j = u.dbProvider.get_job(lib, expected_values.library_version_id) tc.assertEqual( j, None, "When running %s, we found an existing job, indicating the database is dirty and should be cleaned." % inspect.stack()[1].function) return (u, expected_values, _check_jobs)
def _setup(current_library_version_func, new_library_version_func, expected_commits_seen, expected_bugs_filed_func, library_filter, branch="master", repo_func=None, keep_tmp_db=False): real_command_runner = CommandProvider({}) real_command_runner.update_config( {'LoggingProvider': SimpleLogger(localconfig['Logging'])}) db_config = transform_db_config_to_tmp_db(localconfig['Database']) db_config['keep_tmp_db'] = keep_tmp_db configs = { 'General': { 'env': 'dev', 'gecko-path': '.', 'ff-version': None, 'repo': 'https://hg.mozilla.org/mozilla-central' }, 'Command': { 'test_mappings': None, 'real_runner': real_command_runner }, 'Logging': localconfig['Logging'], 'Database': db_config, 'Vendor': {}, 'Bugzilla': { 'filed_bug_id': None, 'expected_commits_seen': expected_commits_seen, 'expected_bugs_filed_func': expected_bugs_filed_func }, 'Mercurial': {}, 'Taskcluster': {}, 'Phabricator': {}, 'Library': { 'commitalert_revision_override': current_library_version_func, 'commitalert_repo_override': repo_func, 'commitalert_branch_override': branch } } expected_values = DEFAULT_EXPECTED_VALUES(new_library_version_func) configs['General']['ff-version'] = expected_values.ff_version configs['Bugzilla']['filed_bug_id'] = expected_values.filed_bug_id configs['Command']['test_mappings'] = COMMAND_MAPPINGS(expected_values) u = Updatebot(configs, PROVIDERS) # Ensure we don't have a dirty database with existing jobs tc = unittest.TestCase() for lib in u.libraryProvider.get_libraries( u.config_dictionary['General']['gecko-path']): j = u.dbProvider.get_job(lib, expected_values.new_version_id()) tc.assertEqual( j, None, "When running %s, we found an existing job, indicating the database is dirty and should be cleaned." % inspect.stack()[1].function) return (u, expected_values)