Reviewers: jarin,

Message:
PTAL

Description:
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.

The api query will be improved in a follow up CL as soon as there are indexes
for all query parameters.

BUG=

Please review this at https://codereview.chromium.org/315133003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+66, -2 lines):
  M tools/push-to-trunk/auto_roll.py
  M tools/push-to-trunk/chromium_roll.py
  M tools/push-to-trunk/common_includes.py
  M tools/push-to-trunk/git_recipes.py
  M tools/push-to-trunk/test_scripts.py


Index: tools/push-to-trunk/auto_roll.py
diff --git a/tools/push-to-trunk/auto_roll.py b/tools/push-to-trunk/auto_roll.py index 607ca0897abf7db55951f117279f90a1ef03dcc1..ad02af7b194ffcc5819f74af3420aa9c73f3345e 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,29 @@ 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",
+ # TODO(machenbach): Use these parameters as soon as they have an index.
+        # open="True", bug_information="",
+        revision_greater_or_equal=self["last_push"])
+ # TODO(machenbach): Remove these filters as soon as the query parameters
+    # above work.
+    result = filter(lambda r: r["open"], result)
+    result = filter(lambda r: not r["bug_information"], result)
+    if result:
+      print "Stop due to pending ClusterFuzz issues."
+      return True
+
+
 class RollChromium(Step):
   MESSAGE = "Roll V8 into Chromium."

@@ -75,6 +101,7 @@ class RollChromium(Step):
         "--reviewer", self._options.reviewer,
         "--chromium", self._options.chromium,
         "--force",
+        "--use-commit-queue",
       ]
       if self._options.sheriff:
         args.extend([
@@ -108,6 +135,7 @@ class AutoRoll(ScriptsBase):
       CheckActiveRoll,
       DetectLastPush,
       DetectLastRoll,
+      CheckClusterFuzz,
       RollChromium,
     ]

Index: tools/push-to-trunk/chromium_roll.py
diff --git a/tools/push-to-trunk/chromium_roll.py b/tools/push-to-trunk/chromium_roll.py index 35ab24b05d6ad492a6aed7399c3ff009e7f128ee..0138ff8e72f8bb898ffafd0ab46bb4e1b3d360c2 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:
Index: tools/push-to-trunk/common_includes.py
diff --git a/tools/push-to-trunk/common_includes.py b/tools/push-to-trunk/common_includes.py index 482509f7d1974e9fbf946c6995be33caae920e76..86d33ca0c0508c8711612a73d5499f2987b0f439 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)

Index: tools/push-to-trunk/git_recipes.py
diff --git a/tools/push-to-trunk/git_recipes.py b/tools/push-to-trunk/git_recipes.py index 8c1e314d7d8c7e493750918295dd044fba4c9b0a..1b5bd2bf18394b1c11ed926db2abf428fff1e8f9 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)
Index: tools/push-to-trunk/test_scripts.py
diff --git a/tools/push-to-trunk/test_scripts.py b/tools/push-to-trunk/test_scripts.py index bc79cfd5d7b4cca480253ad4e9a7240ac7bdd772..e6a6c2531d9e603aa320e374e8ec879364caa96f 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,12 @@ 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 [{"open": False, "bug_information": None},
+            {"open": True, "bug_information": 12345}]
+
   def Sleep(self, seconds):
     pass

@@ -996,6 +1004,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",


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to