Commit df25cf6b authored by Robert Ma's avatar Robert Ma Committed by Commit Bot

[blinkpy] Deflake two wptserve unit tests

Stub out _check_that_all_ports_are_available to always return True so
that the tests won't fail if some process is already listening on a
port used by the server.

Note that there might be a deeper issue that something else is listening
on these ports. These unit tests themselves use MockHost and would never
start the real server.

Reduce the numbers of expected log entries by 1 as we no longer have
the "DEBUG: all ports are available" message from the real
_check_that_all_ports_are_available.

Bug: 1114320
Change-Id: I5dfa98cabb5c0bb85a6f304b069240836af60f94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2428740
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Auto-Submit: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810866}
parent 682e7be7
......@@ -7,7 +7,7 @@ import logging
from blinkpy.common.host_mock import MockHost
from blinkpy.common.system.log_testing import LoggingTestCase
from blinkpy.web_tests.port import test
from blinkpy.web_tests.port.test import TestPort
from blinkpy.web_tests.servers.wptserve import WPTServe
......@@ -15,7 +15,7 @@ class TestWPTServe(LoggingTestCase):
def setUp(self):
super(TestWPTServe, self).setUp()
self.host = MockHost()
self.port = test.TestPort(self.host)
self.port = TestPort(self.host)
self.host.filesystem.write_text_file(
'/mock-checkout/third_party/blink/tools/blinkpy/third_party/wpt/wpt.config.json',
'{"ports": {}, "aliases": []}')
......@@ -84,6 +84,7 @@ class TestWPTServe(LoggingTestCase):
server = WPTServe(self.port, '/log_file_dir')
server._pid_file = '/tmp/pidfile'
server._check_that_all_ports_are_available = lambda: True
server._is_server_running_on_all_ports = lambda: True
server.start()
......@@ -94,7 +95,7 @@ class TestWPTServe(LoggingTestCase):
json.loads(self.port._filesystem.read_text_file(server._config_file))
logs = self.logMessages()
self.assertEqual(len(logs), 5)
self.assertEqual(len(logs), 4)
self.assertEqual(logs[:2], [
'DEBUG: stale wptserve pid file, pid 7\n',
'DEBUG: pid 7 is not running\n',
......@@ -113,6 +114,7 @@ class TestWPTServe(LoggingTestCase):
server = WPTServe(self.port, '/log_file_dir')
server._pid_file = '/tmp/pidfile'
server._check_that_all_ports_are_available = lambda: True
server._is_server_running_on_all_ports = lambda: True
# Simulate a process that never gets killed.
......@@ -125,7 +127,7 @@ class TestWPTServe(LoggingTestCase):
# In this case, we'll try to kill the process repeatedly,
# then give up and just try to start a new process anyway.
logs = self.logMessages()
self.assertEqual(len(logs), 44)
self.assertEqual(len(logs), 43)
self.assertEqual(logs[:2], [
'DEBUG: stale wptserve pid file, pid 7\n',
'DEBUG: pid 7 is running, killing it\n'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment