OSX testsuite fixes (#35948)

* OSX is a bit more restrictive on getting the process information

* OSX says the sockets aren't connected, which is weird, but...

* Close the sockets on OSX
This commit is contained in:
Pedro Algarvio 2016-08-31 15:09:51 -04:00 committed by Nicole Thomas
parent 9bdb161eac
commit f842ddd525
2 changed files with 39 additions and 5 deletions

View file

@ -118,7 +118,11 @@ except ImportError:
log.info('No process with the PID %s was found running', pid)
if process and only_children is False:
cmdline = process.cmdline()
try:
cmdline = process.cmdline()
except psutil.AccessDenied:
# OSX denies us access to the above information
cmdline = None
if not cmdline:
try:
cmdline = process.as_dict()
@ -260,8 +264,16 @@ def get_unused_localhost_port():
usock.close()
return port
if sys.platform.startswith('darwin') and port in _RUNTESTS_PORTS:
port = get_unused_localhost_port()
usock.close()
return port
_RUNTESTS_PORTS[port] = usock
if sys.platform.startswith('darwin'):
usock.close()
return port
@ -573,8 +585,18 @@ class SaltDaemonScriptBase(SaltScriptBase, ShellTestCase):
if conn == 0:
log.debug('Port %s is connectable!', port)
check_ports.remove(port)
sock.shutdown(socket.SHUT_RDWR)
sock.close()
try:
sock.shutdown(socket.SHUT_RDWR)
sock.close()
except socket.error as exc:
if not sys.platform.startswith('darwin'):
raise
try:
if exc.errno != errno.ENOTCONN:
raise
except AttributeError:
# This is not OSX !?
pass
del sock
elif isinstance(port, str):
joined = self.run_run('manage.joined', config_dir=self.config_dir)

View file

@ -14,6 +14,8 @@
# Import python libs
from __future__ import absolute_import
import sys
import errno
import socket
import logging
@ -72,8 +74,18 @@ class PyTestEngine(object):
def handle_connection(self, connection, address):
log.warning('Accepted connection from %s. Role: %s', address, self.opts['__role'])
# We just need to know that the daemon running the engine is alive...
connection.shutdown(socket.SHUT_RDWR) # pylint: disable=no-member
connection.close()
try:
connection.shutdown(socket.SHUT_RDWR) # pylint: disable=no-member
connection.close()
except socket.error as exc:
if not sys.platform.startswith('darwin'):
raise
try:
if exc.errno != errno.ENOTCONN:
raise
except AttributeError:
# This is not OSX !?
pass
@gen.coroutine
def listen_to_minion_connected_event(self):