mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ansible-test: set ulimit to enforce consistent test environment (#46652)
* ansible-test: set ulimit to enforce consistent test environment * fixed santiy issue
This commit is contained in:
parent
a1f80a07dc
commit
7b774117ab
2 changed files with 24 additions and 0 deletions
|
@ -31,6 +31,7 @@ import sys
|
||||||
import pipes
|
import pipes
|
||||||
import logging
|
import logging
|
||||||
import getpass
|
import getpass
|
||||||
|
import resource
|
||||||
|
|
||||||
logger = logging.getLogger('injector') # pylint: disable=locally-disabled, invalid-name
|
logger = logging.getLogger('injector') # pylint: disable=locally-disabled, invalid-name
|
||||||
# pylint: disable=locally-disabled, invalid-name
|
# pylint: disable=locally-disabled, invalid-name
|
||||||
|
@ -89,6 +90,17 @@ def main():
|
||||||
try:
|
try:
|
||||||
logger.debug('Self: %s', __file__)
|
logger.debug('Self: %s', __file__)
|
||||||
|
|
||||||
|
# to achieve a consistent nofile ulimit, set to 16k here, this can affect performance in subprocess.Popen when
|
||||||
|
# being called with close_fds=True on Python (8x the time on some environments)
|
||||||
|
nofile_limit = 16 * 1024
|
||||||
|
current_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||||
|
new_limit = (nofile_limit, nofile_limit)
|
||||||
|
if current_limit > new_limit:
|
||||||
|
logger.debug('RLIMIT_NOFILE: %s -> %s', current_limit, new_limit)
|
||||||
|
resource.setrlimit(resource.RLIMIT_NOFILE, (nofile_limit, nofile_limit))
|
||||||
|
else:
|
||||||
|
logger.debug('RLIMIT_NOFILE: %s', current_limit)
|
||||||
|
|
||||||
config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'injector.json')
|
config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'injector.json')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import absolute_import, print_function
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
|
import resource
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from lib.util import (
|
from lib.util import (
|
||||||
|
@ -84,6 +85,17 @@ def main():
|
||||||
display.info_stderr = (isinstance(config, SanityConfig) and config.lint) or (isinstance(config, IntegrationConfig) and config.list_targets)
|
display.info_stderr = (isinstance(config, SanityConfig) and config.lint) or (isinstance(config, IntegrationConfig) and config.list_targets)
|
||||||
check_startup()
|
check_startup()
|
||||||
|
|
||||||
|
# to achieve a consistent nofile ulimit, set to 16k here, this can affect performance in subprocess.Popen when
|
||||||
|
# being called with close_fds=True on Python (8x the time on some environments)
|
||||||
|
nofile_limit = 16 * 1024
|
||||||
|
current_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||||
|
new_limit = (nofile_limit, nofile_limit)
|
||||||
|
if current_limit > new_limit:
|
||||||
|
display.info('RLIMIT_NOFILE: %s -> %s' % (current_limit, new_limit), verbosity=2)
|
||||||
|
resource.setrlimit(resource.RLIMIT_NOFILE, (nofile_limit, nofile_limit))
|
||||||
|
else:
|
||||||
|
display.info('RLIMIT_NOFILE: %s' % (current_limit, ), verbosity=2)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
args.func(config)
|
args.func(config)
|
||||||
except Delegate as ex:
|
except Delegate as ex:
|
||||||
|
|
Loading…
Reference in a new issue