Changeset 203386 in webkit


Ignore:
Timestamp:
Jul 18, 2016, 5:24:50 PM (9 years ago)
Author:
aakash_jain@apple.com
Message:

EWS console logs doesn't go to log file
https://bugs.webkit.org/show_bug.cgi?id=159539
<rdar://problem/24464570>

Reviewed by David Kilzer.

  • Scripts/webkitpy/common/system/logutils.py:

(configure_logger_to_log_to_file): Added method to configure the logger to log to file.
(FileSystemHandler): Added class which uses logging.FileHandler as base class and supports writing
to filesystem. It also supports passing MockFilesystem.
(FileSystemHandler.init): Initialize the class and calls base class init.
(FileSystemHandler._open): Overrides the base class _open method to use filesystem object.

  • Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:

(AbstractEarlyWarningSystemTest.test_failing_tests_message): Added MockHost() parameter.
(_test_ews): Same.

  • Scripts/webkitpy/tool/commands/queues.py:

(AbstractQueue.begin_work_queue): Configure the logger to log to file.
(AbstractQueue._log_directory): Using filesystem object instead of os.
(AbstractQueue.queue_log_path): Same.
(AbstractQueue.init): Passed host parameter.
(PatchProcessingQueue.init): Same.
(CommitQueue.init): Same.
(AbstractReviewQueue.init): Same.
(StyleQueue.init): Same.

  • Scripts/webkitpy/tool/commands/queues_unittest.py:

(TestCommitQueue): Passed MockHost() as host.
(TestCommitQueue.init): Same.
(TestQueue.init): Same.
(TestReviewQueue.init): Same.
(TestFeederQueue.init): Same.
(AbstractPatchQueueTest.test_next_patch): Same.
(PatchProcessingQueueTest.test_upload_results_archive_for_patch): Same.
(test_commit_queue_failure): Same.
(MockCommitQueueTask.results_from_patch_test_run): Same.
(test_rollout_lands): Same.
(test_non_valid_patch): Same.
(test_auto_retry): Same.
(test_style_queue_with_watch_list_exception): Same.

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r203350 r203386  
     12016-07-18  Aakash Jain  <aakash_jain@apple.com>
     2
     3        EWS console logs doesn't go to log file
     4        https://bugs.webkit.org/show_bug.cgi?id=159539
     5        <rdar://problem/24464570>
     6
     7        Reviewed by David Kilzer.
     8
     9        * Scripts/webkitpy/common/system/logutils.py:
     10        (configure_logger_to_log_to_file): Added method to configure the logger to log to file.
     11        (FileSystemHandler): Added class which uses logging.FileHandler as base class and supports writing
     12        to filesystem. It also supports passing MockFilesystem.
     13        (FileSystemHandler.__init__): Initialize the class and calls base class __init__.
     14        (FileSystemHandler._open): Overrides the base class _open method to use filesystem object.
     15        * Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:
     16        (AbstractEarlyWarningSystemTest.test_failing_tests_message): Added MockHost() parameter.
     17        (_test_ews): Same.
     18        * Scripts/webkitpy/tool/commands/queues.py:
     19        (AbstractQueue.begin_work_queue): Configure the logger to log to file.
     20        (AbstractQueue._log_directory): Using filesystem object instead of os.
     21        (AbstractQueue.queue_log_path): Same.
     22        (AbstractQueue.__init__): Passed host parameter.
     23        (PatchProcessingQueue.__init__): Same.
     24        (CommitQueue.__init__): Same.
     25        (AbstractReviewQueue.__init__): Same.
     26        (StyleQueue.__init__): Same.
     27        * Scripts/webkitpy/tool/commands/queues_unittest.py:
     28        (TestCommitQueue): Passed MockHost() as host.
     29        (TestCommitQueue.__init__): Same.
     30        (TestQueue.__init__): Same.
     31        (TestReviewQueue.__init__): Same.
     32        (TestFeederQueue.__init__): Same.
     33        (AbstractPatchQueueTest.test_next_patch): Same.
     34        (PatchProcessingQueueTest.test_upload_results_archive_for_patch): Same.
     35        (test_commit_queue_failure): Same.
     36        (MockCommitQueueTask.results_from_patch_test_run): Same.
     37        (test_rollout_lands): Same.
     38        (test_non_valid_patch): Same.
     39        (test_auto_retry): Same.
     40        (test_style_queue_with_watch_list_exception): Same.
     41
    1422016-07-02  Filip Pizlo  <fpizlo@apple.com>
    243
  • trunk/Tools/Scripts/webkitpy/common/system/logutils.py

    r132840 r203386  
    3131
    3232import webkitpy
     33
     34from logging import FileHandler
    3335
    3436
     
    210212
    211213    return handlers
     214
     215
     216def configure_logger_to_log_to_file(logger, log_path, filesystem):
     217    log_directory = filesystem.dirname(log_path)
     218    if log_directory and not filesystem.exists(log_directory):
     219        filesystem.maybe_make_directory(log_directory)
     220
     221    handler = FileSystemHandler(log_path, filesystem)
     222    formatter = logging.Formatter('%(asctime)s - %(message)s')
     223    handler.setFormatter(formatter)
     224
     225    logger.addHandler(handler)
     226
     227
     228class FileSystemHandler(FileHandler):
     229    def __init__(self, filename, filesystem):
     230        self.filename = filename
     231        self.filesystem = filesystem
     232        FileHandler.__init__(self, filename)
     233
     234    def _open(self):
     235        return self.filesystem.open_text_file_for_writing(self.filename)
  • trunk/Tools/Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py

    r191345 r203386  
    2929from webkitpy.thirdparty.mock import Mock
    3030from webkitpy.common.host import Host
     31from webkitpy.common.host_mock import MockHost
    3132from webkitpy.common.net.layouttestresults import LayoutTestResults
    3233from webkitpy.common.system.outputcapture import OutputCapture
     
    5051        ews = TestEWS()
    5152        ews.bind_to_tool(MockTool())
     53        ews.host = MockHost()
    5254        ews._options = MockOptions(port=None, confirm=False)
    5355        OutputCapture().assert_outputs(self, ews.begin_work_queue, expected_logs=self._default_begin_work_queue_logs(ews.name))
     
    9092    def _test_ews(self, ews):
    9193        ews.bind_to_tool(MockTool())
     94        ews.host = MockHost()
    9295        options = Mock()
    9396        options.port = None
  • trunk/Tools/Scripts/webkitpy/tool/commands/queues.py

    r202319 r203386  
    4242from webkitpy.common.config.committervalidator import CommitterValidator
    4343from webkitpy.common.config.ports import DeprecatedPort
     44from webkitpy.common.host import Host
    4445from webkitpy.common.net.bugzilla import Attachment
    4546from webkitpy.common.net.statusserver import StatusServer
     47from webkitpy.common.system import logutils
    4648from webkitpy.common.system.executive import ScriptError
    4749from webkitpy.tool.bot.botinfo import BotInfo
     
    6769    _error_status = "Error"
    6870
    69     def __init__(self, options=None):  # Default values should never be collections (like []) as default values are shared between invocations
     71    def __init__(self, options=None, host=Host()):  # Default values should never be collections (like []) as default values are shared between invocations
    7072        options_list = (options or []) + [
    7173            make_option("--no-confirm", action="store_false", dest="confirm", default=True, help="Do not ask the user for confirmation before running the queue.  Dangerous!"),
     
    7779        if not hasattr(self, 'architecture'):
    7880            self.architecture = None
     81        self.host = host
    7982
    8083    def _cc_watchers(self, bug_id):
     
    110113
    111114    def _log_directory(self):
    112         return os.path.join("..", "%s-logs" % self.name)
     115        return self.host.filesystem.join("..", "%s-logs" % self.name)
    113116
    114117    # QueueEngineDelegate methods
    115118
    116119    def queue_log_path(self):
    117         return os.path.join(self._log_directory(), "%s.log" % self.name)
     120        return self.host.filesystem.join(self._log_directory(), "%s.log" % self.name)
    118121
    119122    def work_item_log_path(self, work_item):
     
    121124
    122125    def begin_work_queue(self):
     126        logutils.configure_logger_to_log_to_file(_log, self.queue_log_path(), self.host.filesystem)
    123127        _log.info("CAUTION: %s will discard all local changes in \"%s\"" % (self.name, self._tool.scm().checkout_root))
    124128        if self._options.confirm:
     
    260264    port_name = None
    261265
    262     def __init__(self, options=None):
     266    def __init__(self, options=None, host=Host()):
    263267        self._port = None  # We can't instantiate port here because tool isn't avaialble.
    264         AbstractPatchQueue.__init__(self, options)
     268        self.host = host
     269        AbstractPatchQueue.__init__(self, options, host=host)
    265270
    266271    # FIXME: This is a hack to map between the old port names and the new port names.
     
    314319
    315320class CommitQueue(PatchProcessingQueue, StepSequenceErrorHandler, CommitQueueTaskDelegate):
    316     def __init__(self, commit_queue_task_class=CommitQueueTask):
     321    def __init__(self, commit_queue_task_class=CommitQueueTask, host=Host()):
     322        self.host = host
    317323        self._commit_queue_task_class = commit_queue_task_class
    318         PatchProcessingQueue.__init__(self)
     324        PatchProcessingQueue.__init__(self, host=host)
    319325
    320326    name = "commit-queue"
     
    431437class AbstractReviewQueue(PatchProcessingQueue, StepSequenceErrorHandler):
    432438    """This is the base-class for the EWS queues and the style-queue."""
    433     def __init__(self, options=None):
    434         PatchProcessingQueue.__init__(self, options)
     439    def __init__(self, options=None, host=Host()):
     440        self.host = host
     441        PatchProcessingQueue.__init__(self, options, host=host)
    435442
    436443    def review_patch(self, patch):
     
    464471    name = "style-queue"
    465472
    466     def __init__(self):
    467         AbstractReviewQueue.__init__(self)
     473    def __init__(self, host=Host()):
     474        self.host = host
     475        AbstractReviewQueue.__init__(self, host=host)
    468476
    469477    def review_patch(self, patch):
  • trunk/Tools/Scripts/webkitpy/tool/commands/queues_unittest.py

    r202319 r203386  
    3232from webkitpy.common.checkout.scm import CheckoutNeedsUpdate
    3333from webkitpy.common.checkout.scm.scm_mock import MockSCM
     34from webkitpy.common.host_mock import MockHost
    3435from webkitpy.common.net.layouttestresults import LayoutTestResults
    3536from webkitpy.common.net.bugzilla import Attachment
     
    4849class TestCommitQueue(CommitQueue):
    4950    def __init__(self, tool=None):
    50         CommitQueue.__init__(self)
     51        CommitQueue.__init__(self, host=MockHost())
    5152        if tool:
    5253            self.bind_to_tool(tool)
     
    6364    name = "test-queue"
    6465
     66    def __init__(self):
     67        AbstractPatchQueue.__init__(self, host=MockHost())
     68
    6569
    6670class TestReviewQueue(AbstractReviewQueue):
    6771    name = "test-review-queue"
    6872
     73    def __init__(self):
     74        AbstractReviewQueue.__init__(self, host=MockHost())
     75
    6976
    7077class TestFeederQueue(FeederQueue):
    7178    _sleep_duration = 0
     79
     80    def __init__(self):
     81        FeederQueue.__init__(self, host=MockHost())
    7282
    7383
     
    154164class AbstractPatchQueueTest(CommandsTest):
    155165    def test_next_patch(self):
    156         queue = AbstractPatchQueue()
     166        queue = AbstractPatchQueue(host=MockHost())
    157167        tool = MockTool()
    158168        queue.bind_to_tool(tool)
     
    172182class PatchProcessingQueueTest(CommandsTest):
    173183    def test_upload_results_archive_for_patch(self):
    174         queue = PatchProcessingQueue()
     184        queue = PatchProcessingQueue(host=MockHost())
    175185        queue.name = "mock-queue"
    176186        tool = MockTool()
     
    261271            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
    262272        }
    263         self.assert_queue_outputs(CommitQueue(), tool=tool, expected_logs=expected_logs)
     273        self.assert_queue_outputs(CommitQueue(host=MockHost()), tool=tool, expected_logs=expected_logs)
    264274
    265275    def test_commit_queue_failure(self):
     
    277287            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
    278288        }
    279         queue = CommitQueue()
     289        queue = CommitQueue(host=MockHost())
    280290
    281291        def mock_run_webkit_patch(command):
     
    309319                return LayoutTestResults([test_results.TestResult("mock_test_name.html", failures=[test_failures.FailureTextMismatch()])], did_exceed_test_failure_limit=False)
    310320
    311         queue = CommitQueue(MockCommitQueueTask)
     321        queue = CommitQueue(MockCommitQueueTask, host=MockHost())
    312322
    313323        def mock_run_webkit_patch(command):
     
    348358            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
    349359        }
    350         self.assert_queue_outputs(CommitQueue(), tool=tool, expected_logs=expected_logs)
     360        self.assert_queue_outputs(CommitQueue(host=MockHost()), tool=tool, expected_logs=expected_logs)
    351361
    352362    def test_rollout_lands(self):
     
    373383            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10005' with comment 'Rejecting attachment 10005 from commit-queue.\n\nMock error message'\n",
    374384        }
    375         self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=rollout_patch, expected_logs=expected_logs)
     385        self.assert_queue_outputs(CommitQueue(host=MockHost()), tool=tool, work_item=rollout_patch, expected_logs=expected_logs)
    376386
    377387    def test_non_valid_patch(self):
     
    384394""",
    385395        }
    386         self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=patch, expected_logs=expected_logs)
     396        self.assert_queue_outputs(CommitQueue(host=MockHost()), tool=tool, work_item=patch, expected_logs=expected_logs)
    387397
    388398    def test_auto_retry(self):
    389         queue = CommitQueue()
     399        queue = CommitQueue(host=MockHost())
    390400        options = Mock()
    391401        options.parent_command = "commit-queue"
     
    499509        }
    500510        tool = MockTool(executive_throws_when_run=set(['check-style']))
    501         self.assert_queue_outputs(StyleQueue(), expected_logs=expected_logs, tool=tool)
     511        self.assert_queue_outputs(StyleQueue(host=MockHost()), expected_logs=expected_logs, tool=tool)
    502512
    503513    def test_style_queue_with_watch_list_exception(self):
     
    524534        }
    525535        tool = MockTool(executive_throws_when_run=set(['apply-watchlist-local']))
    526         self.assert_queue_outputs(StyleQueue(), expected_logs=expected_logs, tool=tool)
     536        self.assert_queue_outputs(StyleQueue(host=MockHost()), expected_logs=expected_logs, tool=tool)
Note: See TracChangeset for help on using the changeset viewer.