def test_basic_run_job(self, db_conn, req_mock): req_mock.get(BUGZILLA_BASE_URL, json=SAMPLE_BUGZILLA_RESULTS) config_manager = self._setup_config_manager(3) with config_manager.context() as config: tab = CronTabberApp(config) tab.run_one('bugzilla-associations') information = load_structure(db_conn) assert information['bugzilla-associations'] assert not information['bugzilla-associations']['last_error'] assert information['bugzilla-associations']['last_success'] associations = self.fetch_data(db_conn) # Verify we have the expected number of associations assert len(associations) == 8 bug_ids = set([x['bug_id'] for x in associations]) # Verify bugs with no crash signatures are missing assert 6 not in bug_ids bug_8_signatures = [ item['signature'] for item in associations if item['bug_id'] == '8' ] # New signatures have correctly been inserted assert len(bug_8_signatures) == 2 assert 'another::legitimate(sig)' in bug_8_signatures assert 'legitimate(sig)' in bug_8_signatures
def test_run(self, connection_context, db_conn): config_manager = self._setup_config_manager() with config_manager.context() as config: tab = CronTabberApp(config) tab.run_one('elasticsearch-cleanup') information = load_structure(db_conn) assert information['elasticsearch-cleanup'] assert not information['elasticsearch-cleanup']['last_error'] assert information['elasticsearch-cleanup']['last_success']
def test_run(self, connection_context, db_conn): config_manager = self._setup_config_manager() with config_manager.context() as config: tab = CronTabberApp(config) tab.run_one('elasticsearch-cleanup') information = load_structure(db_conn) assert information['elasticsearch-cleanup'] assert not information['elasticsearch-cleanup']['last_error'] assert information['elasticsearch-cleanup']['last_success']
def run_job_and_assert_success(self, db_conn): # Run crontabber config_manager = self._setup_config_manager() with config_manager.context() as config: crontabberapp = CronTabberApp(config) crontabberapp.run_one('update-signatures') # Assert the job ran correctly crontabber_info = load_structure(db_conn) assert crontabber_info['update-signatures']['last_error'] == {} assert crontabber_info['update-signatures']['last_success']
def run_job_and_assert_success(self): # Run crontabber config_manager = self._setup_config_manager() with config_manager.context() as config: crontabberapp = CronTabberApp(config) crontabberapp.run_one('update-signatures') # Assert the job ran correctly crontabber_info = self._load_structure() assert crontabber_info['update-signatures']['last_error'] == {} assert crontabber_info['update-signatures']['last_success']
def test_with_bugzilla_failure(self, db_conn, req_mock): req_mock.get(BUGZILLA_BASE_URL, text='error loading content', status_code=500) config_manager = self._setup_config_manager(3) with config_manager.context() as config: tab = CronTabberApp(config) tab.run_one('bugzilla-associations') information = load_structure(db_conn) assert information['bugzilla-associations'] # Verify there has been an error last_error = information['bugzilla-associations']['last_error'] assert last_error assert 'HTTPError' in last_error['type'] assert not information['bugzilla-associations']['last_success']
def test_run_job_with_reports_with_existing_bugs_different(self, db_conn, req_mock): """Verify that an association to a signature that no longer is part of the crash signatures list gets removed. """ req_mock.get(BUGZILLA_BASE_URL, json=SAMPLE_BUGZILLA_RESULTS) self.insert_data(db_conn, bug_id='8', signature='@different') config_manager = self._setup_config_manager(3) with config_manager.context() as config: tab = CronTabberApp(config) tab.run_one('bugzilla-associations') information = load_structure(db_conn) assert information['bugzilla-associations'] assert not information['bugzilla-associations']['last_error'] assert information['bugzilla-associations']['last_success'] # The previous association, to signature '@different' that is not in # crash signatures, is now missing associations = self.fetch_data(db_conn) assert '@different' not in [item['signature'] for item in associations]
def test_run_job_with_reports_with_existing_bugs_same(self, db_conn, req_mock): req_mock.get(BUGZILLA_BASE_URL, json=SAMPLE_BUGZILLA_RESULTS) self.insert_data(db_conn, bug_id='8', signature='legitimate(sig)') config_manager = self._setup_config_manager(3) with config_manager.context() as config: tab = CronTabberApp(config) tab.run_one('bugzilla-associations') information = load_structure(db_conn) assert information['bugzilla-associations'] assert not information['bugzilla-associations']['last_error'] assert information['bugzilla-associations']['last_success'] associations = self.fetch_data(db_conn) associations = [item['signature'] for item in associations if item['bug_id'] == '8'] # New signatures have correctly been inserted assert len(associations) == 2 assert associations == [ 'another::legitimate(sig)', 'legitimate(sig)' ]