Title: [255269] trunk/Tools
Revision
255269
Author
[email protected]
Date
2020-01-28 12:44:37 -0800 (Tue, 28 Jan 2020)

Log Message

EWS django app should send cq+ patches to commit-queue
https://bugs.webkit.org/show_bug.cgi?id=206534

Reviewed by Jonathan Bedard.

* BuildSlaveSupport/ews-app/ews/common/buildbot.py:
(Buildbot.send_patch_to_buildbot): Added support to send to commit queue.
* BuildSlaveSupport/ews-app/ews/config.py: Added COMMIT_QUEUE_PORT.
* BuildSlaveSupport/ews-app/ews/fetcher.py: Added support for sending patches to commit queue.
* BuildSlaveSupport/ews-app/ews/migrations/0003_patch_sent_to_commit_queue.py: Added.
* BuildSlaveSupport/ews-app/ews/models/patch.py:
(Patch): Added sent_to_commit_queue field in patch table.
(Patch.is_patch_sent_to_commit_queue): Method to check if patch is sent to commit queue.
(Patch.set_sent_to_commit_queue): Set sent_to_commit_queue field.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/ews-app/ews/common/buildbot.py (255268 => 255269)


--- trunk/Tools/BuildSlaveSupport/ews-app/ews/common/buildbot.py	2020-01-28 20:28:36 UTC (rev 255268)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/common/buildbot.py	2020-01-28 20:44:37 UTC (rev 255269)
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2019 Apple Inc. All rights reserved.
+# Copyright (C) 2018-2020 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -41,10 +41,12 @@
     icons_for_queues_mapping = {}
 
     @classmethod
-    def send_patch_to_buildbot(cls, patch_path, properties=[]):
+    def send_patch_to_buildbot(cls, patch_path, send_to_commit_queue=False, properties=None):
+        properties = properties or []
+        buildbot_port = config.COMMIT_QUEUE_PORT if send_to_commit_queue else config.BUILDBOT_SERVER_PORT
         command = ['buildbot', 'try',
                    '--connect=pb',
-                   '--master={}:{}'.format(config.BUILDBOT_SERVER_HOST, config.BUILDBOT_SERVER_PORT),
+                   '--master={}:{}'.format(config.BUILDBOT_SERVER_HOST, buildbot_port),
                    '--username={}'.format(config.BUILDBOT_TRY_USERNAME),
                    '--passwd={}'.format(config.BUILDBOT_TRY_PASSWORD),
                    '--diff={}'.format(patch_path),
@@ -53,10 +55,9 @@
         for property in properties:
             command.append('--property={}'.format(property))
 
-        _log.debug('Executing command: {}'.format(command))
         return_code = subprocess.call(command)
         if return_code:
-            _log.warn('Error executing: {}, return code={}'.format(command, return_code))
+            _log.warn('Error executing buildbot try command for {}, return code={}'.format(patch_path, return_code))
 
         return return_code
 

Modified: trunk/Tools/BuildSlaveSupport/ews-app/ews/config.py (255268 => 255269)


--- trunk/Tools/BuildSlaveSupport/ews-app/ews/config.py	2020-01-28 20:28:36 UTC (rev 255268)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/config.py	2020-01-28 20:44:37 UTC (rev 255269)
@@ -1,4 +1,4 @@
-# Copyright (C) 2018 Apple Inc. All rights reserved.
+# Copyright (C) 2018-2020 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -33,6 +33,7 @@
 else:
     BUILDBOT_SERVER_HOST = 'ews-build.webkit.org'
 BUILDBOT_SERVER_PORT = '5555'
+COMMIT_QUEUE_PORT = '5557'
 BUILDBOT_TRY_USERNAME = os.getenv('BUILDBOT_TRY_USERNAME', 'sampleuser')
 BUILDBOT_TRY_PASSWORD = os.getenv('BUILDBOT_TRY_PASSWORD', 'samplepass')
 

Modified: trunk/Tools/BuildSlaveSupport/ews-app/ews/fetcher.py (255268 => 255269)


--- trunk/Tools/BuildSlaveSupport/ews-app/ews/fetcher.py	2020-01-28 20:28:36 UTC (rev 255268)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/fetcher.py	2020-01-28 20:44:37 UTC (rev 255269)
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2019 Apple Inc. All rights reserved.
+# Copyright (C) 2018-2020 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -43,6 +43,7 @@
             Buildbot.update_icons_for_queues_mapping()
             try:
                 BugzillaPatchFetcher().fetch()
+                BugzillaPatchFetcher().fetch_commit_queue_patches()
             except Exception as e:
                 _log.error('Exception in BugzillaPatchFetcher: {}'.format(e))
             time.sleep(self.interval)
@@ -61,7 +62,20 @@
         Patch.save_patches(patch_ids)
         patches_to_send = self.patches_to_send_to_buildbot(patch_ids)
         _log.info('{} r? patches, {} patches need to be sent to Buildbot: {}'.format(len(patch_ids), len(patches_to_send), patches_to_send))
+        self.send_patches_to_buildbot(patches_to_send)
 
+    def fetch_commit_queue_patches(self):
+        patch_ids_commit_queue = Bugzilla.get_list_of_patches_for_commit_queue()
+        patch_ids_commit_queue = BugzillaPatchFetcher.filter_valid_patches(patch_ids_commit_queue)
+        _log.debug('cq+ patches: {}'.format(patch_ids_commit_queue))
+        Patch.save_patches(patch_ids_commit_queue)
+        patches_to_send = self.patches_to_send_to_buildbot(patch_ids_commit_queue, commit_queue=True)
+        _log.info('{} cq+ patches, {} patches need to be sent to commit queue: {}'.format(len(patch_ids_commit_queue), len(patches_to_send), patches_to_send))
+        self.send_patches_to_buildbot(patches_to_send, send_to_commit_queue=True)
+
+    def send_patches_to_buildbot(self, patches_to_send, send_to_commit_queue=False):
+        if not patches_to_send:
+            return
         for patch_id in patches_to_send:
             bz_patch = Bugzilla.retrieve_attachment(patch_id)
             if not bz_patch or bz_patch['id'] != patch_id:
@@ -71,22 +85,22 @@
                 _log.warn('Patch is obsolete, skipping')
                 Patch.set_obsolete(patch_id)
                 continue
-            if Patch.is_patch_sent_to_buildbot(patch_id):
-                _log.error('Patch {} is already sent to buildbot.'.format(patch_id))
+            if Patch.is_patch_sent_to_buildbot(patch_id, commit_queue=send_to_commit_queue):
+                _log.error('Patch {} is already sent to buildbot/commit-queue.'.format(patch_id))
                 continue
-            Patch.set_sent_to_buildbot(patch_id, True)
+            Patch.set_sent_to_buildbot(patch_id, True, commit_queue=send_to_commit_queue)
             rc = Buildbot.send_patch_to_buildbot(bz_patch['path'],
+                     send_to_commit_queue=send_to_commit_queue,
                      properties=['patch_id={}'.format(patch_id), 'bug_id={}'.format(bz_patch['bug_id']), 'owner={}'.format(bz_patch.get('creator', ''))])
             if rc == 0:
                 Patch.set_bug_id(patch_id, bz_patch['bug_id'])
             else:
                 _log.error('Failed to send patch to buildbot.')
-                Patch.set_sent_to_buildbot(patch_id, False)
+                Patch.set_sent_to_buildbot(patch_id, False, commit_queue=send_to_commit_queue)
                 #FIXME: send an email for this failure
-        return patch_ids
 
-    def patches_to_send_to_buildbot(self, patch_ids):
-        return [patch_id for patch_id in patch_ids if not Patch.is_patch_sent_to_buildbot(patch_id)]
+    def patches_to_send_to_buildbot(self, patch_ids, commit_queue=False):
+        return [patch_id for patch_id in patch_ids if not Patch.is_patch_sent_to_buildbot(patch_id, commit_queue)]
 
     @classmethod
     def filter_valid_patches(cls, patch_ids):

Added: trunk/Tools/BuildSlaveSupport/ews-app/ews/migrations/0003_patch_sent_to_commit_queue.py (0 => 255269)


--- trunk/Tools/BuildSlaveSupport/ews-app/ews/migrations/0003_patch_sent_to_commit_queue.py	                        (rev 0)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/migrations/0003_patch_sent_to_commit_queue.py	2020-01-28 20:44:37 UTC (rev 255269)
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.16 on 2020-01-28 02:56
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('ews', '0002_build_retried'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='patch',
+            name='sent_to_commit_queue',
+            field=models.BooleanField(default=False),
+        ),
+    ]

Modified: trunk/Tools/BuildSlaveSupport/ews-app/ews/models/patch.py (255268 => 255269)


--- trunk/Tools/BuildSlaveSupport/ews-app/ews/models/patch.py	2020-01-28 20:28:36 UTC (rev 255268)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/models/patch.py	2020-01-28 20:44:37 UTC (rev 255269)
@@ -1,4 +1,4 @@
-# Copyright (C) 2018 Apple Inc. All rights reserved.
+# Copyright (C) 2018-2020 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
     bug_id = models.IntegerField()
     obsolete = models.BooleanField(default=False)
     sent_to_buildbot = models.BooleanField(default=False)
+    sent_to_commit_queue = models.BooleanField(default=False)
     created = models.DateTimeField(auto_now_add=True)
     modified = models.DateTimeField(auto_now=True)
 
@@ -43,7 +44,7 @@
         return str(self.patch_id)
 
     @classmethod
-    def save_patch(cls, patch_id, bug_id=-1, obsolete=False, sent_to_buildbot=False):
+    def save_patch(cls, patch_id, bug_id=-1, obsolete=False, sent_to_buildbot=False, sent_to_commit_queue=False):
         if not Patch.is_valid_patch_id(patch_id):
             _log.warn('Patch id {} in invalid. Skipped saving.'.format(patch_id))
             return ERR_INVALID_PATCH_ID
@@ -51,7 +52,7 @@
         if Patch.is_existing_patch_id(patch_id):
             _log.debug('Patch id {} already exists in database. Skipped saving.'.format(patch_id))
             return ERR_EXISTING_PATCH
-        Patch(patch_id, bug_id, obsolete, sent_to_buildbot).save()
+        Patch(patch_id, bug_id, obsolete, sent_to_buildbot, sent_to_commit_queue).save()
         _log.info('Saved patch in database, id: {}'.format(patch_id))
         return SUCCESS
 
@@ -62,9 +63,12 @@
 
     @classmethod
     def is_valid_patch_id(cls, patch_id):
-        if not patch_id or type(patch_id) != int or patch_id < 1:
+        if not patch_id or patch_id < 1:
             _log.warn('Invalid patch id: {}'.format(patch_id))
             return False
+        if type(patch_id) != int:
+            _log.warn('Data type mismatch for patch_id, expected: int, found: {}, id: {}'.format(type(patch_id), patch_id))
+            return False
         return True
 
     @classmethod
@@ -72,10 +76,20 @@
         return bool(Patch.objects.filter(patch_id=patch_id))
 
     @classmethod
-    def is_patch_sent_to_buildbot(cls, patch_id):
+    def is_patch_sent_to_buildbot(cls, patch_id, commit_queue=False):
+        if commit_queue:
+            return Patch._is_patch_sent_to_commit_queue(patch_id)
+        return Patch._is_patch_sent_to_buildbot(patch_id)
+
+    @classmethod
+    def _is_patch_sent_to_buildbot(cls, patch_id):
         return Patch.is_existing_patch_id(patch_id) and Patch.objects.get(pk=patch_id).sent_to_buildbot
 
     @classmethod
+    def _is_patch_sent_to_commit_queue(cls, patch_id):
+        return Patch.is_existing_patch_id(patch_id) and Patch.objects.get(pk=patch_id).sent_to_commit_queue
+
+    @classmethod
     def get_patch(cls, patch_id):
         try:
             return Patch.objects.get(patch_id=patch_id)
@@ -83,7 +97,13 @@
             return None
 
     @classmethod
-    def set_sent_to_buildbot(cls, patch_id, sent_to_buildbot=True):
+    def set_sent_to_buildbot(cls, patch_id, value, commit_queue=False):
+        if commit_queue:
+            return Patch._set_sent_to_commit_queue(patch_id, sent_to_commit_queue=value)
+        return Patch._set_sent_to_buildbot(patch_id, sent_to_buildbot=value)
+
+    @classmethod
+    def _set_sent_to_buildbot(cls, patch_id, sent_to_buildbot=True):
         if not Patch.is_existing_patch_id(patch_id):
             Patch.save_patch(patch_id=patch_id, sent_to_buildbot=sent_to_buildbot)
             _log.info('Patch {} saved to database with sent_to_buildbot={}'.format(patch_id, sent_to_buildbot))
@@ -100,6 +120,23 @@
         return SUCCESS
 
     @classmethod
+    def _set_sent_to_commit_queue(cls, patch_id, sent_to_commit_queue=True):
+        if not Patch.is_existing_patch_id(patch_id):
+            Patch.save_patch(patch_id=patch_id, sent_to_commit_queue=sent_to_commit_queue)
+            _log.info('Patch {} saved to database with sent_to_commit_queue={}'.format(patch_id, sent_to_commit_queue))
+            return SUCCESS
+
+        patch = Patch.objects.get(pk=patch_id)
+        if patch.sent_to_commit_queue == sent_to_commit_queue:
+            _log.warn('Patch {} already has sent_to_commit_queue={}'.format(patch_id, sent_to_commit_queue))
+            return SUCCESS
+
+        patch.sent_to_commit_queue = sent_to_commit_queue
+        patch.save()
+        _log.info('Updated patch {} with sent_to_commit_queue={}'.format(patch_id, sent_to_commit_queue))
+        return SUCCESS
+
+    @classmethod
     def set_bug_id(cls, patch_id, bug_id):
         if not Patch.is_existing_patch_id(patch_id):
             return ERR_NON_EXISTING_PATCH

Modified: trunk/Tools/ChangeLog (255268 => 255269)


--- trunk/Tools/ChangeLog	2020-01-28 20:28:36 UTC (rev 255268)
+++ trunk/Tools/ChangeLog	2020-01-28 20:44:37 UTC (rev 255269)
@@ -1,3 +1,20 @@
+2020-01-28  Aakash Jain  <[email protected]>
+
+        EWS django app should send cq+ patches to commit-queue
+        https://bugs.webkit.org/show_bug.cgi?id=206534
+
+        Reviewed by Jonathan Bedard.
+
+        * BuildSlaveSupport/ews-app/ews/common/buildbot.py:
+        (Buildbot.send_patch_to_buildbot): Added support to send to commit queue.
+        * BuildSlaveSupport/ews-app/ews/config.py: Added COMMIT_QUEUE_PORT.
+        * BuildSlaveSupport/ews-app/ews/fetcher.py: Added support for sending patches to commit queue.
+        * BuildSlaveSupport/ews-app/ews/migrations/0003_patch_sent_to_commit_queue.py: Added.
+        * BuildSlaveSupport/ews-app/ews/models/patch.py:
+        (Patch): Added sent_to_commit_queue field in patch table.
+        (Patch.is_patch_sent_to_commit_queue): Method to check if patch is sent to commit queue.
+        (Patch.set_sent_to_commit_queue): Set sent_to_commit_queue field.
+
 2020-01-28  Stephan Szabo  <[email protected]>
 
         Python 3: Update windows scripts and uses of is constant
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to