From: machenbach@chromium.org Date: Wed, 25 Jun 2014 08:17:45 +0000 (+0000) Subject: Add clusterfuzz check to v8 auto-roll script and use CQ. X-Git-Tag: upstream/4.7.83~8556 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7833a1321cb6489378de53c9f323896d1c9dbe90;p=platform%2Fupstream%2Fv8.git Add clusterfuzz check to v8 auto-roll script and use CQ. This adds a check step that makes sure there are no new issues when rolling into chromium. It also checks the cq bit on roll upload. BUG= R=jarin@chromium.org Review URL: https://codereview.chromium.org/315133003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21996 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/tools/push-to-trunk/auto_roll.py b/tools/push-to-trunk/auto_roll.py index 607ca08..e6cbed5 100755 --- a/tools/push-to-trunk/auto_roll.py +++ b/tools/push-to-trunk/auto_roll.py @@ -12,8 +12,11 @@ import urllib from common_includes import * import chromium_roll +CLUSTERFUZZ_API_KEY_FILE = "CLUSTERFUZZ_API_KEY_FILE" + CONFIG = { PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", + CLUSTERFUZZ_API_KEY_FILE: ".cf_api_key", } CR_DEPS_URL = 'http://src.chromium.org/svn/trunk/src/DEPS' @@ -65,6 +68,24 @@ class DetectLastRoll(Step): return True +class CheckClusterFuzz(Step): + MESSAGE = "Check ClusterFuzz api for new problems." + + def RunStep(self): + if not os.path.exists(self.Config(CLUSTERFUZZ_API_KEY_FILE)): + print "Skipping ClusterFuzz check. No api key file found." + return False + api_key = FileToText(self.Config(CLUSTERFUZZ_API_KEY_FILE)) + # Check for open, reproducible issues that have no associated bug. + result = self._side_effect_handler.ReadClusterFuzzAPI( + api_key, job_type="linux_asan_d8_dbg", reproducible="True", + open="True", bug_information="", + revision_greater_or_equal=self["last_push"]) + if result: + print "Stop due to pending ClusterFuzz issues." + return True + + class RollChromium(Step): MESSAGE = "Roll V8 into Chromium." @@ -75,6 +96,7 @@ class RollChromium(Step): "--reviewer", self._options.reviewer, "--chromium", self._options.chromium, "--force", + "--use-commit-queue", ] if self._options.sheriff: args.extend([ @@ -108,6 +130,7 @@ class AutoRoll(ScriptsBase): CheckActiveRoll, DetectLastPush, DetectLastRoll, + CheckClusterFuzz, RollChromium, ] diff --git a/tools/push-to-trunk/chromium_roll.py b/tools/push-to-trunk/chromium_roll.py index 35ab24b..0138ff8 100755 --- a/tools/push-to-trunk/chromium_roll.py +++ b/tools/push-to-trunk/chromium_roll.py @@ -105,7 +105,8 @@ class UploadCL(Step): % self["sheriff"]) self.GitCommit("%s%s\n\nTBR=%s" % (commit_title, sheriff, rev)) self.GitUpload(author=self._options.author, - force=self._options.force_upload) + force=self._options.force_upload, + cq=self._options.use_commit_queue) print "CL uploaded." @@ -143,6 +144,9 @@ class ChromiumRoll(ScriptsBase): "directory to automate the V8 roll.")) parser.add_argument("-l", "--last-push", help="The git commit ID of the last push to trunk.") + parser.add_argument("--use-commit-queue", + help="Check the CQ bit on upload.", + default=False, action="store_true") def _ProcessOptions(self, options): # pragma: no cover if not options.manual and not options.reviewer: diff --git a/tools/push-to-trunk/common_includes.py b/tools/push-to-trunk/common_includes.py index 482509f..86d33ca 100644 --- a/tools/push-to-trunk/common_includes.py +++ b/tools/push-to-trunk/common_includes.py @@ -28,6 +28,7 @@ import argparse import datetime +import httplib import imp import json import os @@ -207,6 +208,25 @@ class SideEffectHandler(object): # pragma: no cover finally: url_fh.close() + def ReadClusterFuzzAPI(self, api_key, **params): + params["api_key"] = api_key + params = urllib.urlencode(params) + + headers = {"Content-type": "application/x-www-form-urlencoded"} + + conn = httplib.HTTPSConnection("backend-dot-cluster-fuzz.appspot.com") + conn.request("POST", "/_api/", params, headers) + + response = conn.getresponse() + data = response.read() + + try: + return json.loads(data) + except: + print data + print "ERROR: Could not read response. Is your key valid?" + raise + def Sleep(self, seconds): time.sleep(seconds) diff --git a/tools/push-to-trunk/git_recipes.py b/tools/push-to-trunk/git_recipes.py index 8c1e314..1b5bd2b 100644 --- a/tools/push-to-trunk/git_recipes.py +++ b/tools/push-to-trunk/git_recipes.py @@ -144,7 +144,7 @@ class GitRecipesMixin(object): args.append(Quoted(patch_file)) self.Git(MakeArgs(args)) - def GitUpload(self, reviewer="", author="", force=False): + def GitUpload(self, reviewer="", author="", force=False, cq=False): args = ["cl upload --send-mail"] if author: args += ["--email", Quoted(author)] @@ -152,6 +152,8 @@ class GitRecipesMixin(object): args += ["-r", Quoted(reviewer)] if force: args.append("-f") + if cq: + args.append("--use-commit-queue") # TODO(machenbach): Check output in forced mode. Verify that all required # base files were uploaded, if not retry. self.Git(MakeArgs(args), pipe=False) diff --git a/tools/push-to-trunk/test_scripts.py b/tools/push-to-trunk/test_scripts.py index bc79cfd..0c71bba 100644 --- a/tools/push-to-trunk/test_scripts.py +++ b/tools/push-to-trunk/test_scripts.py @@ -35,6 +35,7 @@ import auto_push from auto_push import CheckLastPush from auto_push import SETTINGS_LOCATION import auto_roll +from auto_roll import CLUSTERFUZZ_API_KEY_FILE import common_includes from common_includes import * import merge_to_branch @@ -66,6 +67,7 @@ TEST_CONFIG = { "/tmp/test-merge-to-branch-tempfile-already-merging", COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", + CLUSTERFUZZ_API_KEY_FILE: "/tmp/test-fake-cf-api-key", } @@ -384,6 +386,11 @@ class ScriptTest(unittest.TestCase): else: return self._url_mock.Call("readurl", url) + def ReadClusterFuzzAPI(self, api_key, **params): + # TODO(machenbach): Use a mock for this and add a test that stops rolling + # due to clustefuzz results. + return [] + def Sleep(self, seconds): pass @@ -996,6 +1003,8 @@ deps = { self.assertEquals(1, result) def testAutoRoll(self): + TEST_CONFIG[CLUSTERFUZZ_API_KEY_FILE] = self.MakeEmptyTempFile() + TextToFile("fake key", TEST_CONFIG[CLUSTERFUZZ_API_KEY_FILE]) self.ExpectReadURL([ URL("https://codereview.chromium.org/search", "owner=author%40chromium.org&limit=30&closed=3&format=json",