Пример #1
0
 def test_run_commit_queue_for_cl_fail_to_land(self):
     host = self.mock_host()
     host.filesystem.write_text_file(
         MOCK_WEB_TESTS + 'W3CImportExpectations', '')
     importer = self._get_test_importer(host)
     # Only the latest job for each builder is counted.
     importer.git_cl = MockGitCL(host,
                                 status='lgtm',
                                 try_job_results={
                                     Build('cq-builder-a', 120):
                                     TryJobStatus('COMPLETED', 'FAILURE'),
                                     Build('cq-builder-a', 123):
                                     TryJobStatus('COMPLETED', 'SUCCESS'),
                                 })
     importer.git_cl.wait_for_closed_status = lambda: False
     success = importer.run_commit_queue_for_cl()
     self.assertFalse(success)
     self.assertLog([
         'INFO: Triggering CQ try jobs.\n',
         'INFO: All jobs finished.\n',
         'INFO: CQ appears to have passed; trying to commit.\n',
         'ERROR: Cannot submit CL; aborting.\n',
     ])
     self.assertEqual(importer.git_cl.calls, [
         ['git', 'cl', 'try'],
         ['git', 'cl', 'upload', '-f', '--send-mail'],
         ['git', 'cl', 'set-commit'],
         ['git', 'cl', 'set-close'],
     ])
Пример #2
0
 def test_run_commit_queue_for_cl_pass(self):
     host = MockHost()
     host.filesystem.write_text_file(
         MOCK_WEB_TESTS + 'W3CImportExpectations', '')
     importer = TestImporter(host)
     # Only the latest job for each builder is counted.
     importer.git_cl = MockGitCL(host,
                                 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'],
     ])
Пример #3
0
 def test_latest_try_jobs(self):
     git_cl = GitCL(MockHost())
     git_cl.fetch_raw_try_job_results = lambda **_: [
         {
             'builder_name': 'builder-b',
             'status': 'COMPLETED',
             'result': 'SUCCESS',
             'url': 'http://build.chromium.org/p/master/builders/builder-b/builds/100',
         },
         {
             'builder_name': 'builder-b',
             'status': 'COMPLETED',
             'result': 'SUCCESS',
             'url': 'http://build.chromium.org/p/master/builders/builder-b/builds/90',
         },
         {
             'builder_name': 'builder-a',
             'status': 'SCHEDULED',
             'result': None,
             'url': None,
         },
         {
             'builder_name': 'builder-c',
             'status': 'COMPLETED',
             'result': 'SUCCESS',
             'url': 'http://ci.chromium.org/master/builder-c/123',
         },
     ]
     self.assertEqual(
         git_cl.latest_try_jobs(['builder-a', 'builder-b']),
         {
             Build('builder-a'): TryJobStatus('SCHEDULED'),
             Build('builder-b', 100): TryJobStatus('COMPLETED', 'SUCCESS'),
         })
Пример #4
0
 def test_latest_try_jobs_failures(self):
     git_cl = GitCL(MockHost())
     git_cl.fetch_raw_try_job_results = lambda **_: [
         {
             'builder_name': 'builder-a',
             'status': 'COMPLETED',
             'result': 'FAILURE',
             'failure_reason': 'BUILD_FAILURE',
             'tags': [
                 'build_address:luci.chromium.try/chromium_presubmit/100',
             ],
             'url': 'http://ci.chromium.org/b/123123123123123123',
         },
         {
             'builder_name': 'builder-b',
             'status': 'COMPLETED',
             'result': 'FAILURE',
             'failure_reason': 'INFRA_FAILURE',
             'tags': [
                 'build_address:luci.chromium.try/chromium_presubmit/200',
             ],
             'url': 'http://ci.chromium.org/b/1293871928371923719',
         },
     ]
     self.assertEqual(
         git_cl.latest_try_jobs(['builder-a', 'builder-b']), {
             Build('builder-a', 100): TryJobStatus('COMPLETED', 'FAILURE'),
             Build('builder-b', 200): TryJobStatus('COMPLETED', 'FAILURE'),
         })
Пример #5
0
 def test_try_job_results_url_format_fallback(self):
     git_cl = GitCL(MockHost())
     git_cl.fetch_raw_try_job_results = lambda **_: [
         {
             'builder_name': 'builder-a',
             'status': 'COMPLETED',
             'result': 'FAILURE',
             'tags': [
                 'build_address:luci.chromium.try/chromium_presubmit/100',
             ],
             'url': 'http://ci.chromium.org/p/master/builders/builder-b/builds/10',
         },
         {
             'builder_name': 'builder-b',
             'status': 'COMPLETED',
             'result': 'FAILURE',
             'url': 'http://ci.chromium.org/p/master/builders/builder-b/builds/20',
         },
         {
             'builder_name': 'builder-c',
             'status': 'COMPLETED',
             'result': 'FAILURE',
             'url': 'https://ci.chromium.org/swarming/task/36a767f405d9ee10',
         },
     ]
     self.assertEqual(
         git_cl.try_job_results(),
         {
             Build('builder-a', 100): TryJobStatus('COMPLETED', 'FAILURE'),
             Build('builder-b', 20): TryJobStatus('COMPLETED', 'FAILURE'),
             Build('builder-c', '36a767f405d9ee10'): TryJobStatus('COMPLETED', 'FAILURE'),
         })
Пример #6
0
 def test_latest_try_jobs_failures(self):
     git_cl = GitCL(MockHost())
     git_cl._host.web = MockWeb(responses=[{
         'status_code':
         200,
         'body':
         SEARCHBUILDS_RESPONSE_PREFIX + b"""{
                 "builds": [
                     {
                         "status": "FAILURE",
                         "builder": {
                             "builder": "builder-a"
                         },
                         "number": 100
                     },
                     {
                         "status": "INFRA_FAILURE",
                         "builder": {
                             "builder": "builder-b"
                         },
                         "number": 200
                     }
                 ]
             }"""
     }])
     self.assertEqual(
         git_cl.latest_try_jobs(builder_names=['builder-a', 'builder-b']), {
             Build('builder-a', 100): TryJobStatus('COMPLETED', 'FAILURE'),
             Build('builder-b', 200): TryJobStatus('COMPLETED', 'FAILURE'),
         })
Пример #7
0
 def test_try_job_results_with_task_id_in_url(self):
     git_cl = GitCL(MockHost())
     git_cl.fetch_raw_try_job_results = lambda **_: [
         {
             'builder_name':
             'builder-a',
             'status':
             'COMPLETED',
             'result':
             'FAILURE',
             'failure_reason':
             'BUILD_FAILURE',
             'url': ('https://ci.chromium.org/swarming/task/'
                     '36a767f405d9ee10'),
         },
         {
             'builder_name':
             'builder-b',
             'status':
             'COMPLETED',
             'result':
             'SUCCESS',
             'url': ('https://ci.chromium.org/swarming/task/'
                     '38740befcd9c0010?server=chromium-swarm.appspot.com'),
         },
     ]
     self.assertEqual(
         git_cl.try_job_results(), {
             Build('builder-a', '36a767f405d9ee10'):
             TryJobStatus('COMPLETED', 'FAILURE'),
             Build('builder-b', '38740befcd9c0010'):
             TryJobStatus('COMPLETED', 'SUCCESS'),
         })
Пример #8
0
    def _fetch_results(self, jobs):
        """Fetches results for all of the given builds.

        There should be a one-to-one correspondence between Builds, supported
        platforms, and try bots. If not all of the builds can be fetched, then
        continuing with rebaselining may yield incorrect results, when the new
        baselines are deduped, an old baseline may be kept for the platform
        that's missing results.

        Args:
            jobs: A dict mapping Build objects to TryJobStatus objects.

        Returns:
            A dict mapping Build to WebTestResults for all completed jobs.
        """
        results_fetcher = self._tool.results_fetcher
        results = {}
        for build, status in jobs.iteritems():
            if status == TryJobStatus('COMPLETED', 'SUCCESS'):
                # Builds with passing try jobs are mapped to None, to indicate
                # that there are no baselines to download.
                results[build] = None
                continue
            if status != TryJobStatus('COMPLETED', 'FAILURE'):
                # Only completed failed builds will contain actual failed
                # web tests to download baselines for.
                continue
            results_url = results_fetcher.results_url(build.builder_name, build.build_number)
            web_test_results = results_fetcher.fetch_results(build)
            if web_test_results is None:
                _log.info('Failed to fetch results for "%s".', build.builder_name)
                _log.info('Results URL: %s/results.html', results_url)
                continue
            results[build] = web_test_results
        return results
Пример #9
0
 def test_run_commit_queue_for_cl_pass(self):
     host = self.mock_host()
     host.filesystem.write_text_file(
         MOCK_WEB_TESTS + 'W3CImportExpectations', '')
     importer = self._get_test_importer(host)
     # Only the latest job for each builder is counted.
     importer.git_cl = MockGitCL(host,
                                 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; sending to the rubber-stamper '
         'bot for CR+1 and commit.\n',
         'INFO: If the rubber-stamper bot rejects the CL, you either need '
         'to modify the benign file patterns, or manually CR+1 and land the '
         'import yourself if it touches code files. See https://chromium.'
         'googlesource.com/infra/infra/+/refs/heads/master/go/src/infra/'
         'appengine/rubber-stamper/README.md\n',
         'INFO: Update completed.\n',
     ])
     self.assertEqual(importer.git_cl.calls, [
         ['git', 'cl', 'try'],
         [
             'git', 'cl', 'upload', '-f', '--send-mail',
             '--enable-auto-submit', '--reviewers', RUBBER_STAMPER_BOT
         ],
     ])
Пример #10
0
 def test_run_commit_queue_for_cl_fail_cq(self):
     host = MockHost()
     host.filesystem.write_text_file(
         MOCK_WEB_TESTS + 'W3CImportExpectations', '')
     importer = TestImporter(host)
     importer.git_cl = MockGitCL(host,
                                 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'],
     ])
Пример #11
0
 def test_has_failing_try_results_only_success_and_started(self):
     self.assertFalse(
         GitCL.some_failed({
             Build('some-builder', 90):
             TryJobStatus('COMPLETED', 'SUCCESS'),
             Build('some-builder', 100):
             TryJobStatus('STARTED'),
         }))
Пример #12
0
 def test_all_success_with_started_build(self):
     self.assertFalse(
         GitCL.all_success({
             Build('some-builder', 1):
             TryJobStatus('COMPLETED', 'SUCCESS'),
             Build('some-builder', 2):
             TryJobStatus('STARTED'),
         }))
Пример #13
0
 def __init__(self, *args, **kwargs):
     self.linux_build = Build('linux-rel', 100)
     self.mac_build = Build('mac-rel', 101)
     self.win_build = Build('win7-rel', 102)
     self.mock_try_results = {
         self.linux_build: TryJobStatus('COMPLETED', 'SUCCESS'),
         self.win_build: TryJobStatus('COMPLETED', 'SUCCESS'),
         self.mac_build: TryJobStatus('COMPLETED', 'SUCCESS')
     }
     super(TryFlagTest, self).__init__(*args, **kwargs)
Пример #14
0
 def test_filter_latest(self):
     try_job_results = {
         Build('builder-a', 100): TryJobStatus('COMPLETED', 'FAILURE'),
         Build('builder-a', 200): TryJobStatus('COMPLETED', 'SUCCESS'),
         Build('builder-b', 50): TryJobStatus('SCHEDULED'),
     }
     self.assertEqual(
         GitCL.filter_latest(try_job_results), {
             Build('builder-a', 200): TryJobStatus('COMPLETED', 'SUCCESS'),
             Build('builder-b', 50): TryJobStatus('SCHEDULED'),
         })
Пример #15
0
 def test_submit_cl_timeout_and_already_merged(self):
     # Here we simulate a case where we timeout waiting for the CQ to submit a
     # CL because we miss the notification that it was merged. We then get an
     # error when trying to close the CL because it's already been merged.
     host = self.mock_host()
     host.filesystem.write_text_file(
         MOCK_WEB_TESTS + 'W3CImportExpectations', '')
     importer = self._get_test_importer(host)
     # Define some error text that looks like a typical ScriptError.
     git_error_text = (
         'This is a git Script Error\n'
         '...there is usually a stack trace here with some calls\n'
         '...and maybe other calls\n'
         'And finally, there is the exception:\n'
         'GerritError: Conflict: change is merged\n')
     importer.git_cl = MockGitCL(
         host,
         status='lgtm',
         git_error_output={'set-close': git_error_text},
         # Only the latest job for each builder is counted.
         try_job_results={
             Build('cq-builder-a', 120):
             TryJobStatus('COMPLETED', 'FAILURE'),
             Build('cq-builder-a', 123):
             TryJobStatus('COMPLETED', 'SUCCESS')
         })
     importer._need_sheriff_attention = lambda: False
     importer.git_cl.wait_for_closed_status = lambda timeout_seconds: False
     success = importer.run_commit_queue_for_cl()
     # Since the CL is already merged, we absorb the error and treat it as success.
     self.assertTrue(success)
     self.assertLog([
         'INFO: Triggering CQ try jobs.\n',
         'INFO: All jobs finished.\n',
         'INFO: CQ appears to have passed; sending to the rubber-stamper '
         'bot for CR+1 and commit.\n',
         'INFO: If the rubber-stamper bot rejects the CL, you either need '
         'to modify the benign file patterns, or manually CR+1 and land the '
         'import yourself if it touches code files. See https://chromium.'
         'googlesource.com/infra/infra/+/refs/heads/main/go/src/infra/'
         'appengine/rubber-stamper/README.md\n',
         'ERROR: Cannot submit CL; aborting.\n',
         'ERROR: CL is already merged; treating as success.\n',
     ])
     self.assertEqual(importer.git_cl.calls, [
         ['git', 'cl', 'try'],
         [
             'git', 'cl', 'upload', '-f', '--send-mail',
             '--enable-auto-submit', '--reviewers', RUBBER_STAMPER_BOT
         ],
         ['git', 'cl', 'set-close'],
     ])
Пример #16
0
 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',
             'tags': [
                 'build_address:luci.chromium.try/chromium_presubmit/100',
             ],
             'url': 'http://ci.chromium.org/b/8931586523737389552',
         },
     ]
     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')
Пример #17
0
 def test_wait_for_try_jobs_done(self):
     host = MockHost()
     host.executive = MockExecutive(output='lgtm')
     git_cl = GitCL(host)
     git_cl._host.web = MockWeb(responses=[{
         'status_code':
         200,
         'body':
         SEARCHBUILDS_RESPONSE_PREFIX + b"""{
                 "builds": [
                     {
                         "status": "FAILURE",
                         "builder": {
                             "builder": "some-builder"
                         },
                         "number": 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')
Пример #18
0
 def test_wait_for_try_jobs_cl_closed(self):
     host = MockHost()
     host.executive = MockExecutive(output='closed')
     git_cl = GitCL(host)
     git_cl._host.web = MockWeb(responses=[{
         'status_code':
         200,
         'body':
         SEARCHBUILDS_RESPONSE_PREFIX + b"""{
                 "builds": [
                     {
                         "status": "STARTED",
                         "builder": {
                             "builder": "some-builder"
                         }
                     }
                 ]
             }"""
     }])
     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')
Пример #19
0
 def test_latest_try_jobs_ignores_swarming_task(self):
     git_cl = GitCL(MockHost())
     git_cl.fetch_raw_try_job_results = lambda **_: [
         {
             'builder_name': 'builder-b',
             'status': 'COMPLETED',
             'result': 'SUCCESS',
             'tags': [
                 'build_address:luci.chromium.try/chromium_presubmit/10',
             ],
             'url': 'https://ci.chromium.org/b/123918239182739',
         }, {
             'builder_name':
             'builder-b',
             'status':
             'COMPLETED',
             'result':
             'SUCCESS',
             'url': ('https://ci.chromium.org/swarming/task/'
                     '1234abcd1234abcd?server=chromium-swarm.appspot.com'),
         }
     ]
     self.assertEqual(
         git_cl.latest_try_jobs(['builder-b']), {
             Build('builder-b', 10): TryJobStatus('COMPLETED', 'SUCCESS'),
         })
Пример #20
0
 def test_execute_with_canceled_job(self):
     builds = {
         Build('MOCK Try Win', 5000): TryJobStatus('COMPLETED', 'FAILURE'),
         Build('MOCK Try Mac', 4000): TryJobStatus('COMPLETED', 'FAILURE'),
         Build('MOCK Try Linux', 6000): TryJobStatus('COMPLETED', 'CANCELED'),
     }
     self.command.git_cl = MockGitCL(self.tool, builds)
     exit_code = self.command.execute(self.command_options(), [], self.tool)
     self.assertEqual(exit_code, 1)
     self.assertLog([
         'INFO: Finished try jobs found for all try bots.\n',
         'INFO: There are some builders with no results:\n',
         'INFO:   MOCK Try Linux\n',
         'INFO: Would you like to continue?\n',
         'INFO: Aborting.\n',
     ])
Пример #21
0
 def test_try_job_results(self):
     git_cl = GitCL(MockHost())
     git_cl._host.web = MockWeb(responses=[{
         'status_code':
         200,
         'body':
         SEARCHBUILDS_RESPONSE_PREFIX + b"""{
                 "builds": [
                     {
                         "status": "SUCCESS",
                         "builder": {
                             "builder": "builder-a"
                         },
                         "number": 111,
                         "tags": [
                             {"key": "user_agent", "value": "cq"}
                         ]
                     },
                     {
                         "status": "SCHEDULED",
                         "builder": {
                             "builder": "builder-b"
                         },
                         "number": 222
                     },
                     {
                         "status": "INFRA_FAILURE",
                         "builder": {
                             "builder": "builder-c"
                         },
                         "number": 333
                     }
                 ]
             }"""
     }])
     self.assertEqual(
         git_cl.try_job_results(issue_number=None),
         {
             Build('builder-a', 111):
             TryJobStatus('COMPLETED', 'SUCCESS'),
             Build('builder-b', 222):
             TryJobStatus('SCHEDULED', None),
             # INFRA_FAILURE is mapped to FAILURE for this build.
             Build('builder-c', 333):
             TryJobStatus('COMPLETED', 'FAILURE'),
         })
Пример #22
0
 def test_run_commit_queue_for_cl_closed_cl(self):
     host = MockHost()
     host.filesystem.write_text_file(MOCK_WEB_TESTS + 'W3CImportExpectations', '')
     importer = TestImporter(host)
     importer.git_cl = MockGitCL(host, 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'],
     ])
Пример #23
0
 def test_execute_one_missing_build(self):
     builds = {
         Build('MOCK Try Win', 5000): TryJobStatus('COMPLETED', 'FAILURE'),
         Build('MOCK Try Mac', 4000): TryJobStatus('COMPLETED', 'FAILURE'),
     }
     self.command.git_cl = MockGitCL(self.tool, builds)
     exit_code = self.command.execute(self.command_options(), [], self.tool)
     self.assertEqual(exit_code, 1)
     self.assertLog([
         'INFO: Finished try jobs:\n',
         'INFO:   MOCK Try Mac\n',
         'INFO:   MOCK Try Win\n',
         'INFO: Triggering try jobs:\n',
         'INFO:   MOCK Try Linux\n',
         'INFO: Once all pending try jobs have finished, please re-run\n'
         'blink_tool.py rebaseline-cl to fetch new baselines.\n',
     ])
Пример #24
0
 def test_execute_with_passing_jobs(self):
     builds = {
         Build('MOCK Try Win', 5000): TryJobStatus('COMPLETED', 'FAILURE'),
         Build('MOCK Try Mac', 4000): TryJobStatus('COMPLETED', 'SUCCESS'),
         Build('MOCK Try Linux', 6000): TryJobStatus('COMPLETED', 'SUCCESS'),
     }
     self.command.git_cl = MockGitCL(self.tool, builds)
     exit_code = self.command.execute(self.command_options(), [], self.tool)
     self.assertEqual(exit_code, 0)
     self.assertLog([
         'INFO: Finished try jobs found for all try bots.\n',
         'INFO: Rebaselining one/flaky-fail.html\n',
         'INFO: Rebaselining one/missing.html\n',
         'INFO: Rebaselining one/slow-fail.html\n',
         'INFO: Rebaselining one/text-fail.html\n',
         'INFO: Rebaselining two/image-fail.html\n'
     ])
Пример #25
0
 def test_latest_try_jobs(self):
     # Here we have multiple builds with the same name, but we only take the
     # latest one (based on build number).
     git_cl = GitCL(MockHost())
     git_cl._host.web = MockWeb(responses=[{
         'status_code':
         200,
         'body':
         SEARCHBUILDS_RESPONSE_PREFIX + b"""{
                 "builds": [
                     {
                         "status": "SUCCESS",
                         "builder": {
                             "builder": "builder-b"
                         },
                         "number": 100
                     },
                     {
                         "status": "SUCCESS",
                         "builder": {
                             "builder": "builder-b"
                         },
                         "number": 90
                     },
                     {
                         "status": "SCHEDULED",
                         "builder": {
                             "builder": "builder-a"
                         }
                     },
                     {
                         "status": "SUCCESS",
                         "builder": {
                             "builder": "builder-c"
                         },
                         "number": 123
                     }
                 ]
             }"""
     }])
     self.assertEqual(
         git_cl.latest_try_jobs(builder_names=['builder-a', 'builder-b']), {
             Build('builder-a'): TryJobStatus('SCHEDULED'),
             Build('builder-b', 100): TryJobStatus('COMPLETED', 'SUCCESS'),
         })
Пример #26
0
 def test_execute_with_no_trigger_jobs_option(self):
     builds = {
         Build('MOCK Try Win', 5000): TryJobStatus('COMPLETED', 'FAILURE'),
         Build('MOCK Try Mac', 4000): TryJobStatus('COMPLETED', 'FAILURE'),
     }
     self.command.git_cl = MockGitCL(self.tool, builds)
     exit_code = self.command.execute(
         self.command_options(trigger_jobs=False), [], self.tool)
     self.assertEqual(exit_code, 1)
     self.assertLog([
         'INFO: Finished try jobs:\n',
         'INFO:   MOCK Try Mac\n',
         'INFO:   MOCK Try Win\n',
         'INFO: There are some builders with no results:\n',
         'INFO:   MOCK Try Linux\n',
         'INFO: Would you like to continue?\n',
         'INFO: Aborting.\n',
     ])
Пример #27
0
 def test_execute_with_test_that_fails_on_retry(self):
     # In this example, one test failed both with and without the patch
     # in the try job, so it is not rebaselined.
     builds = {
         Build('MOCK Try Win', 5000): TryJobStatus('COMPLETED', 'FAILURE'),
         Build('MOCK Try Mac', 4000): TryJobStatus('COMPLETED', 'FAILURE'),
         Build('MOCK Try Linux', 6000): TryJobStatus('COMPLETED', 'FAILURE'),
     }
     for build in builds:
         self.tool.buildbot.set_retry_sumary_json(build, json.dumps({
             'failures': ['one/text-fail.html'],
             'ignored': ['two/image-fail.html'],
         }))
     exit_code = self.command.execute(self.command_options(), [], self.tool)
     self.assertEqual(exit_code, 0)
     self.assertLog([
         'INFO: Finished try jobs found for all try bots.\n',
         'INFO: Rebaselining one/text-fail.html\n',
     ])
Пример #28
0
 def test_submit_cl_timeout_and_already_merged(self):
     # Here we simulate a case where we timeout waiting for the CQ to submit a
     # CL because we miss the notification that it was merged. We then get an
     # error when trying to close the CL because it's already been merged.
     host = MockHost()
     host.filesystem.write_text_file(
         MOCK_WEB_TESTS + 'W3CImportExpectations', '')
     importer = TestImporter(host)
     # Define some error text that looks like a typical ScriptError.
     git_error_text = (
         'This is a git Script Error\n'
         '...there is usually a stack trace here with some calls\n'
         '...and maybe other calls\n'
         'And finally, there is the exception:\n'
         'GerritError: Conflict: change is merged\n')
     importer.git_cl = MockGitCL(
         host,
         status='lgtm',
         git_error_output={'set-close': git_error_text},
         # Only the latest job for each builder is counted.
         try_job_results={
             Build('cq-builder-a', 120):
             TryJobStatus('COMPLETED', 'FAILURE'),
             Build('cq-builder-a', 123):
             TryJobStatus('COMPLETED', 'SUCCESS')
         })
     importer.git_cl.wait_for_closed_status = lambda: False
     success = importer.run_commit_queue_for_cl()
     # Since the CL is already merged, we absorb the error and treat it as success.
     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',
         'ERROR: Cannot submit CL; aborting.\n',
         'ERROR: CL is already merged; treating as success.\n',
     ])
     self.assertEqual(importer.git_cl.calls, [
         ['git', 'cl', 'try'],
         ['git', 'cl', 'upload', '-f', '--send-mail'],
         ['git', 'cl', 'set-commit'],
         ['git', 'cl', 'set-close'],
     ])
Пример #29
0
 def test_latest_try_jobs_started_build_luci_url(self):
     git_cl = GitCL(MockHost())
     git_cl.fetch_raw_try_job_results = lambda **_: [
         {
             'builder_name': 'builder-a',
             'status': 'STARTED',
             'result': None,
             'url': 'http://ci.chromium.org/p/master/some-builder/100',
         },
     ]
     self.assertEqual(git_cl.latest_try_jobs(['builder-a']),
                      {Build('builder-a', 100): TryJobStatus('STARTED')})
Пример #30
0
 def test_execute_with_unfinished_jobs(self):
     builds = {
         Build('MOCK Try Win', 5000): TryJobStatus('COMPLETED', 'FAILURE'),
         Build('MOCK Try Mac', 4000): TryJobStatus('STARTED'),
         Build('MOCK Try Linux', 6000): TryJobStatus('SCHEDULED'),
     }
     self.command.git_cl = MockGitCL(self.tool, builds)
     exit_code = self.command.execute(self.command_options(), [], self.tool)
     self.assertEqual(exit_code, 1)
     self.assertLog([
         'INFO: Finished try jobs:\n',
         'INFO:   MOCK Try Win\n',
         'INFO: Scheduled or started try jobs:\n',
         'INFO:   MOCK Try Linux\n',
         'INFO:   MOCK Try Mac\n',
         'INFO: There are some builders with no results:\n',
         'INFO:   MOCK Try Linux\n',
         'INFO:   MOCK Try Mac\n',
         'INFO: Would you like to continue?\n',
         'INFO: Aborting.\n',
     ])