Commit a28dfe62 authored by George Steel's avatar George Steel Committed by Commit Bot

Add condition to -maxclients Xvfb option in run_web_tests

This is now only invoked where necessary (60+ cores).
Makes the test runner compatible with both modern machines and
linux-trusty-rel (which uses a very old Xvfb).

Bug: 1122100
Change-Id: Ib68f356efaa8fa361d0c377845bba165635d5362
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2385923
Commit-Queue: George Steel <gtsteel@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803900}
parent 2cf5267f
......@@ -189,10 +189,7 @@ class LinuxPort(base.Port):
self._xvfb_stdout = tempfile.NamedTemporaryFile(delete=False)
self._xvfb_stderr = tempfile.NamedTemporaryFile(delete=False)
self._xvfb_process = self.host.executive.popen(
[
'Xvfb', display, '-screen', '0', '1280x800x24', '-ac', '-dpi',
'96', '-maxclients', '512'
],
['Xvfb', display] + self.xvfb_flags(),
stdout=self._xvfb_stdout,
stderr=self._xvfb_stderr,
env=env)
......@@ -230,6 +227,16 @@ class LinuxPort(base.Port):
display, retcode)
return False
def xvfb_flags(self):
flags = ['-screen', '0', '1280x800x24', '-ac', '-dpi', '96']
# Raise the Xvfb connection limit if the default limit (256 connections)
# is in danger of being exceeded by 4 connections per test.
# This is conditional since the linux-trusty-rel build bot uses a very
# old version of Xvfb which does not recognise the flag.
if self.default_child_processes() > 60:
flags += ['-maxclients', '512']
return flags
def _find_display(self):
"""Tries to find a free X display, looping if necessary."""
# The "xvfb-run" command uses :99 by default.
......
......@@ -137,6 +137,17 @@ class LinuxPortTest(port_testcase.PortTestCase, LoggingTestCase):
self.assertEqual(port.host.environ['HOME'], '/home/user')
self.assertFalse(port.host.filesystem.exists(temp_home_dir))
def test_xvfb_flags(self):
port = self.make_port()
port.default_child_processes = lambda: 60
self.assertEqual(port.xvfb_flags(),
['-screen', '0', '1280x800x24', '-ac', '-dpi', '96'])
port.default_child_processes = lambda: 61
self.assertEqual(port.xvfb_flags(), [
'-screen', '0', '1280x800x24', '-ac', '-dpi', '96', '-maxclients',
'512'
])
def test_setup_test_run_starts_xvfb(self):
def run_command_fake(args):
if args[0:2] == ['xdpyinfo', '-display']:
......@@ -149,10 +160,7 @@ class LinuxPortTest(port_testcase.PortTestCase, LoggingTestCase):
self.assertIsNone(port.setup_test_run())
self.assertEqual(port.host.executive.calls, [
['xdpyinfo', '-display', ':99'],
[
'Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi',
'96', '-maxclients', '512'
],
['Xvfb', ':99'] + port.xvfb_flags(),
['xdpyinfo'],
])
env = port.setup_environ_for_server()
......@@ -171,10 +179,7 @@ class LinuxPortTest(port_testcase.PortTestCase, LoggingTestCase):
self.assertIsNone(port.setup_test_run())
self.assertEqual(port.host.executive.calls, [
['xdpyinfo', '-display', ':99'],
[
'Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi',
'96', '-maxclients', '512'
],
['Xvfb', ':99'] + port.xvfb_flags(),
['xdpyinfo'],
])
self.assertEqual(
......@@ -201,10 +206,7 @@ class LinuxPortTest(port_testcase.PortTestCase, LoggingTestCase):
['xdpyinfo', '-display', ':100'],
['xdpyinfo', '-display', ':101'],
['xdpyinfo', '-display', ':102'],
[
'Xvfb', ':102', '-screen', '0', '1280x800x24', '-ac',
'-dpi', '96', '-maxclients', '512'
],
['Xvfb', ':102'] + port.xvfb_flags(),
['xdpyinfo'],
])
env = port.setup_environ_for_server()
......@@ -229,10 +231,7 @@ class LinuxPortTest(port_testcase.PortTestCase, LoggingTestCase):
self.assertIsNone(port.setup_test_run())
self.assertEqual(port.host.executive.calls, [
['xdpyinfo', '-display', ':99'],
[
'Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi',
'96', '-maxclients', '512'
],
['Xvfb', ':99'] + port.xvfb_flags(),
['xdpyinfo'],
['xdpyinfo'],
['xdpyinfo'],
......@@ -255,10 +254,7 @@ class LinuxPortTest(port_testcase.PortTestCase, LoggingTestCase):
self.assertEqual(port.setup_test_run(), SYS_DEPS_EXIT_STATUS)
self.assertEqual(port.host.executive.calls, [
['xdpyinfo', '-display', ':99'],
[
'Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi',
'96', '-maxclients', '512'
],
['Xvfb', ':99'] + port.xvfb_flags(),
] + [['xdpyinfo']] * 51)
env = port.setup_environ_for_server()
self.assertEqual(env['DISPLAY'], ':99')
......@@ -288,10 +284,7 @@ class LinuxPortTest(port_testcase.PortTestCase, LoggingTestCase):
self.assertEqual(port.setup_test_run(), SYS_DEPS_EXIT_STATUS)
self.assertEqual(port.host.executive.calls,
[['xdpyinfo', '-display', ':99'],
[
'Xvfb', ':99', '-screen', '0', '1280x800x24',
'-ac', '-dpi', '96', '-maxclients', '512'
]])
['Xvfb', ':99'] + port.xvfb_flags()])
self.assertLog([
'DEBUG: Starting Xvfb with display ":99".\n',
'CRITICAL: Failed to start Xvfb on display ":99" (xvfb retcode: 3).\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