def test_run_commit_queue_for_cl_closed_cl(self): host = MockHost() host.filesystem.write_text_file( '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations', '') importer = TestImporter(host) importer.git_cl = MockGitCL( host, results=CLStatus( status='closed', try_job_results={ Build('cq-builder-a', 120): TryJobStatus('COMPLETED', 'SUCCESS'), Build('cq-builder-b', 200): TryJobStatus('COMPLETED', 'SUCCESS'), }, )) success = importer.run_commit_queue_for_cl() self.assertFalse(success) self.assertLog([ 'INFO: Triggering CQ try jobs.\n', 'ERROR: The CL was closed; aborting.\n', ]) self.assertEqual(importer.git_cl.calls, [ ['git', 'cl', 'try'], ])
def test_wait_for_try_jobs_done(self): host = MockHost() host.executive = MockExecutive(output='lgtm') git_cl = GitCL(host) git_cl.fetch_raw_try_job_results = lambda: [ { 'builder_name': 'some-builder', 'status': 'COMPLETED', 'result': 'FAILURE', 'url': 'http://build.chromium.org/p/master/builders/some-builder/builds/100', }, ] self.assertEqual( git_cl.wait_for_try_jobs(), CLStatus(status='lgtm', try_job_results={ Build('some-builder', 100): TryJobStatus('COMPLETED', 'FAILURE'), })) self.assertEqual(host.stdout.getvalue(), 'Waiting for try jobs, timeout: 7200 seconds.\n')
def test_run_commit_queue_for_cl_fails(self): host = MockHost() host.filesystem.write_text_file( '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations', '') importer = TestImporter(host) importer.git_cl = MockGitCL( host, results=CLStatus( status='lgtm', try_job_results={ Build('cq-builder-a', 120): TryJobStatus('COMPLETED', 'SUCCESS'), Build('cq-builder-a', 123): TryJobStatus('COMPLETED', 'FAILURE'), Build('cq-builder-b', 200): TryJobStatus('COMPLETED', 'SUCCESS'), }, )) importer.fetch_new_expectations_and_baselines = lambda: None success = importer.run_commit_queue_for_cl() self.assertFalse(success) self.assertLog([ 'INFO: Triggering CQ try jobs.\n', 'INFO: All jobs finished.\n', 'ERROR: CQ appears to have failed; aborting.\n', ]) self.assertEqual(importer.git_cl.calls, [ ['git', 'cl', 'try'], ['git', 'cl', 'set-close'], ])
def test_run_commit_queue_for_cl_pass(self): host = MockHost() host.filesystem.write_text_file( '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations', '') importer = TestImporter(host) # Only the latest job for each builder is counted. importer.git_cl = MockGitCL( host, results=CLStatus( status='lgtm', try_job_results={ Build('cq-builder-a', 120): TryJobStatus('COMPLETED', 'FAILURE'), Build('cq-builder-a', 123): TryJobStatus('COMPLETED', 'SUCCESS'), }, )) success = importer.run_commit_queue_for_cl() self.assertTrue(success) self.assertLog([ 'INFO: Triggering CQ try jobs.\n', 'INFO: All jobs finished.\n', 'INFO: CQ appears to have passed; trying to commit.\n', 'INFO: Update completed.\n', ]) self.assertEqual(importer.git_cl.calls, [ ['git', 'cl', 'try'], ['git', 'cl', 'upload', '-f', '--send-mail'], ['git', 'cl', 'set-commit'], ])
def test_run_commit_queue_for_cl_only_checks_non_blink_bots(self): host = MockHost() host.filesystem.write_text_file( '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations', '') host.builders = BuilderList({ 'fakeos_blink_rel': { 'port_name': 'test-fakeos', 'specifiers': ['FakeOS', 'Release'], 'is_try_builder': True, } }) importer = TestImporter(host) importer.git_cl = MockGitCL(host, results=CLStatus( status='lgtm', try_job_results={ Build('fakeos_blink_rel', 123): TryJobStatus('COMPLETED', 'FAILURE'), Build('cq-builder-b', 200): TryJobStatus('COMPLETED', 'SUCCESS'), }, )) importer.fetch_new_expectations_and_baselines = lambda: None success = importer.run_commit_queue_for_cl() self.assertTrue(success) self.assertLog([ 'INFO: Triggering CQ try jobs.\n', 'INFO: All jobs finished.\n', 'INFO: CQ appears to have passed; trying to commit.\n', 'INFO: Update completed.\n', ]) self.assertEqual(importer.git_cl.calls, [ ['git', 'cl', 'try'], ['git', 'cl', 'upload', '-f', '--send-mail'], ['git', 'cl', 'set-commit'], ])
def test_update_expectations_for_cl_all_jobs_pass(self): host = MockHost() host.filesystem.write_text_file( '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations', '') importer = TestImporter(host) importer.git_cl = MockGitCL(host, results=CLStatus( status='lgtm', try_job_results={ Build('builder-a', 123): TryJobStatus('COMPLETED', 'SUCCESS'), }, )) success = importer.update_expectations_for_cl() self.assertLog([ 'INFO: Triggering try jobs for updating expectations.\n', 'INFO: All jobs finished.\n', ]) self.assertTrue(success)
def test_update_expectations_for_cl_fail_but_no_changes(self): host = MockHost() host.filesystem.write_text_file( '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations', '') importer = TestImporter(host) importer.git_cl = MockGitCL(host, results=CLStatus( status='lgtm', try_job_results={ Build('builder-a', 123): TryJobStatus('COMPLETED', 'FAILURE'), }, )) importer.fetch_new_expectations_and_baselines = lambda: None success = importer.update_expectations_for_cl() self.assertTrue(success) self.assertLog([ 'INFO: Triggering try jobs for updating expectations.\n', 'INFO: All jobs finished.\n', ])
def test_wait_for_try_jobs_cl_closed(self): host = MockHost() host.executive = MockExecutive(output='closed') git_cl = GitCL(host) git_cl.fetch_raw_try_job_results = lambda **_: [ { 'builder_name': 'some-builder', 'status': 'STARTED', 'result': None, 'url': None, }, ] self.assertEqual( git_cl.wait_for_try_jobs(), CLStatus( status='closed', try_job_results={ Build('some-builder', None): TryJobStatus('STARTED', None), }, )) self.assertEqual(host.stdout.getvalue(), 'Waiting for try jobs, timeout: 7200 seconds.\n')
def wait_for_try_jobs(self, **_): if self._time_out: return None return CLStatus(self._status, self.filter_latest(self._try_job_results))