HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/supervisor/tests/__pycache__/test_options.cpython-36.opt-1.pyc
3

�k�`�3�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddl
mZddl
mZmZmZddlmZddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Z Gdd�dej�Z!Gdd�dej�Z"Gdd�dej�Z#Gdd �d ej�Z$Gd!d"�d"ej�Z%Gd#d$�d$ej�Z&Gd%d&�d&ej�Z'd'd(�Z(e)d)k�r�ej*d(d*�dS)+z!Test suite for supervisor.options�N)�StringIO)�as_bytes)�Mock�sentinel�patch)�LevelsByName)�DummySupervisor)�DummyLogger)�DummyOptions)�DummyPoller)�DummyPConfig)�DummyProcess)�DummySocketConfig)�lstripc@s�eZdZdd�Zd-dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,S).�OptionTestscCsddlm}|S)Nr)�Options)�supervisor.optionsr)�selfr�r�"/usr/lib/python3.6/test_options.py�_getTargetClassszOptionTests._getTargetClassFcsf|j��ddlm}G��fdd�d��}|�}t�|_|jdddddd	�|jd
d
ddd
|d�|S)Nr)�integercs,eZdZddiZ�f�fdd�	Zdd�ZdS)z+OptionTests._makeOptions.<locals>.MyOptions�other�)cs,||_�j|�Gdd�dt�}|�|_dS)Nc@seZdZdS)zAOptionTests._makeOptions.<locals>.MyOptions.__init__.<locals>.FooN)�__name__�
__module__�__qualname__rrrr�Foo-sr)�
read_error�__init__�object�
configroot)rrr)rrrr*s
z4OptionTests._makeOptions.<locals>.MyOptions.__init__cSs4|jrt|j��|jjj|j�|jjj|j�dS)N)r�
ValueErrorr!�__dict__�updateZdefault_map�master)r�fprrr�read_config0s
z7OptionTests._makeOptions.<locals>.MyOptions.read_configN)rrrr%rr'r)rrrr�	MyOptions'sr(�anoption�oZoption�default)�name�confname�short�longr+r�OTHERzp:zother=)r,r-�envr.r/�handler)r�supervisor.datatypesrr�
configfile�add)rrrr(�optionsr)rrr�_makeOptions#s
zOptionTests._makeOptionscCs&|j�}|�}|jt|jddd�dS)NT)�flagr2)r�assertRaisesr"r5)r�cls�instrrr�'test_add_flag_not_None_handler_not_None?sz3OptionTests.test_add_flag_not_None_handler_not_NonecCs(|j�}|�}|jt|jdddd�dS)NTF)r8r/r.)rr9r"r5)rr:r;rrr�-test_add_flag_not_None_long_false_short_falseDsz9OptionTests.test_add_flag_not_None_long_false_short_falsecCs(|j�}|�}|jt|jdddd�dS)NTF�:)r8r/r.)rr9r"r5)rr:r;rrr�+test_add_flag_not_None_short_endswith_colonOsz7OptionTests.test_add_flag_not_None_short_endswith_coloncCs(|j�}|�}|jt|jdddd�dS)NT�=F)r8r/r.)rr9r"r5)rr:r;rrr�*test_add_flag_not_None_long_endswith_equalZsz6OptionTests.test_add_flag_not_None_long_endswith_equalcCs&|j�}|�}|jt|jddd�dS)Nr@�abc)r/r.)rr9r"r5)rr:r;rrr�(test_add_inconsistent_short_long_optionsesz4OptionTests.test_add_inconsistent_short_long_optionscCs&|j�}|�}|jt|jddd�dS)NFz-abc)r/r.)rr9r"r5)rr:r;rrr�%test_add_short_option_startswith_dashosz1OptionTests.test_add_short_option_startswith_dashcCs&|j�}|�}|jt|jddd�dS)NFrB)r/r.)rr9r"r5)rr:r;rrr�test_add_short_option_too_longysz*OptionTests.test_add_short_option_too_longcCs0|j�}|�}ddi|_|jt|jddd�dS)Nz-aTF�a)r/r.)r�options_mapr9r"r5)rr:r;rrr�#test_add_duplicate_short_option_key�s
z/OptionTests.test_add_duplicate_short_option_keycCs&|j�}|�}|jt|jddd�dS)Nz-abcF)r/r.)rr9r"r5)rr:r;rrr�$test_add_long_option_startswith_dash�sz0OptionTests.test_add_long_option_startswith_dashcCs0|j�}|�}ddi|_|jt|jddd�dS)Nz--abcTrBF)r/r.)rrGr9r"r5)rr:r;rrr�"test_add_duplicate_long_option_key�s
z.OptionTests.test_add_duplicate_long_option_keycCs<|j�}|jt|j�d�|j|jdd�ddddg�dS)N��zsupervisord.confzetc/supervisord.confz/etc/supervisord.confz /etc/supervisor/supervisord.conf���)r7�assertEqual�len�searchpaths)rr6rrr�test_searchpaths�szOptionTests.test_searchpathscCs�|j�}|jg�|j|jd�|j|jd�|j�}dtjd<|jg�|j|jd�|j�}|jddg�|j|jd�tjd=dS)	Nr+rZ42r0�*z-pZ43�+)r7�realizerNr)r�os�environ)rr6rrr�test_options_and_args_order�s


z'OptionTests.test_options_and_args_ordercCsD|j�}|jg�|j|jd�d|jd<|j�|j|jd�dS)NrrRr)r7rTrNrr%�process_config)rr6rrr�test_config_reload�s

zOptionTests.test_config_reloadcCs |jdd�}|jt|jd�dS)N�error)rF)r7r9r"rX)rr6rrr�!test_config_reload_do_usage_false�s
z-OptionTests.test_config_reload_do_usage_falsecsZ|jdd�}g��fdd�|_t�|_|_d|j_d|j_|jdd�|j	�dg�dS)	NrZ)rcs
�j|�S)N)�append)�x)�	exitcodesrr�<lambda>�sz>OptionTests.test_config_reload_do_usage_true.<locals>.<lambda>�T)�do_usage�)
r7�exitr�stderr�stdoutr!r)rrXrN)rr6r)r^r� test_config_reload_do_usage_true�sz,OptionTests.test_config_reload_do_usage_truecCs�ddlm}|�}|jddd�|j|jd�|j|jdd�|jddd�|j|jd�|j|jdd�|jddd�|j|jd�|j|jdd�|jddd�|j|jd�dS)Nr)r�foo�bar�bazr`Zgazonk)rrZ_setrNrgZattr_priorities)rrr6rrr�	test__set�szOptionTests.test__setcs\|j�}g|_g��fdd�|_t�|_|j�|j�dg�d}|j|jj�j	|��dS)Ncs
�j|�S)N)r\)r])r^rrr_�sz9OptionTests.test_missing_default_config.<locals>.<lambda>rbz,Error: No config file found at default paths)
r7rPrcrrd�default_configfilerN�
assertTrue�getvalue�
startswith)rr6�msgr)r^r�test_missing_default_config�sz'OptionTests.test_missing_default_configc
Cs@|j�}tj��&}|jg|_|j�}|j||j�WdQRXdS)N)r7�tempfile�NamedTemporaryFiler,rPrkrN)rr6�f�configrrr�test_default_config�s


zOptionTests.test_default_configcs`|j�}g��fdd�|_t�|_d|_d|_|jd�|j�dg�d}|j|jj�|�dS)Ncs
�j|�S)N)r\)r])r^rrr_�sz'OptionTests.test_help.<locals>.<lambda>�	test_helpzA sample docstring for %s�rz!A sample docstring for test_help
)	r7rcrreZprogname�doc�helprNrm)rr6ror)r^rrv�s
zOptionTests.test_helpN)F)rrrrr7r<r=r?rArCrDrErHrIrJrQrWrYr[rfrjrprurvrrrrrs*






rc@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�ClientOptionsTestscCsddlm}|S)Nr)�
ClientOptions)rr{)rr{rrrrsz"ClientOptionsTests._getTargetClasscCs
|j��S)N)r)rrrr�_makeOne	szClientOptionsTests._makeOnecs�|j�}g|_g��fdd�|_|jddddddgd	�|j�g�|j|jd
�|j|jd�|j|jd�|j|jd�dS)z(Making sure config file is not required.cs
�j|�S)N)r\)r])r^rrr_sz8ClientOptionsTests.test_no_config_file.<locals>.<lambda>z-szhttp://localhost:9001z-u�chrisz-p�123)�argsr`N)	r|rPrcrTrN�interactive�	serverurl�username�password)r�instancer)r^r�test_no_config_filesz&ClientOptionsTests.test_no_config_filecCs�tj�}td|�}t|�}|j�}||_|jgd�|j|jd�t	j
j|d�}|j|j|�|j
j}|j|jd�|j|jd�|j|jd�|j|jd�|j|j|�dS)	Nz�[supervisorctl]
        serverurl=http://localhost:9001
        username=chris
        password=123
        prompt=mysupervisor
        history_file=%s/sc_history
        )rT�
sc_historyZmysupervisorzhttp://localhost:9001r}r~)rq�
gettempdirrrr|r4rTrNr�rU�path�join�history_filer!�
supervisorctl�promptr�r�r�)r�tempdir�sr&r�r�r6rrr�test_optionss 
zClientOptionsTests.test_optionscCs@td�}|j�}t|�|_|jgd�|jj}|j|jd�dS)Nzx
        [supervisorctl]
        serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
        )rzhttp://127.0.0.1:9001)	rr|rr4rTr!r�rNr�)r�textr�r6rrr�3test_options_ignores_space_prefixed_inline_comments4s
zFClientOptionsTests.test_options_ignores_space_prefixed_inline_commentscCs@td�}|j�}t|�|_|jgd�|jj}|j|jd�dS)Nzw
        [supervisorctl]
        serverurl=http://127.0.0.1:9001	;use an http:// url to specify an inet socket
        )rzhttp://127.0.0.1:9001)	rr|rr4rTr!r�rNr�)rr�r�r6rrr�1test_options_ignores_tab_prefixed_inline_comments?s
zDClientOptionsTests.test_options_ignores_tab_prefixed_inline_commentscCs*td�}|j�}t|�|_|jgd�dS)Nz�
        [supervisorctl]
        serverurl=http://localhost:9001 ;duplicate

        [supervisorctl]
        serverurl=http://localhost:9001 ;duplicate
        )r)rr|rr4rT)rr�r�rrr�3test_options_parses_as_nonstrict_for_py2_py3_compatJs

zFClientOptionsTests.test_options_parses_as_nonstrict_for_py2_py3_compatcCs�td�}t|�}|j�}tj�ddddddd�|_||_|jgd	�|j|j	d
�|j
j}|j|jd�|j|j
d�|j|jd�|j|jd�|j|jd�dS)
Na
        [supervisorctl]
        serverurl=http://localhost:%(ENV_SERVER_PORT)s
        username=%(ENV_CLIENT_USER)s
        password=%(ENV_CLIENT_PASS)s
        prompt=%(ENV_CLIENT_PROMPT)s
        history_file=/path/to/histdir/.supervisorctl%(ENV_CLIENT_HIST_EXT)s
        �johndoe�9210�someuser�passwordhereZxsupervisorz.hist)�ENV_HOME�ENV_USER�ENV_SERVER_PORTZENV_CLIENT_USERZENV_CLIENT_PASSZENV_CLIENT_PROMPTZENV_CLIENT_HIST_EXT)rTzhttp://localhost:9210z$/path/to/histdir/.supervisorctl.hist)rrr|rqr��environ_expansionsr4rTrNr�r!r�r�r�r�r�r�)rr�r&r�r6rrr�(test_options_with_environment_expansionsWs(
z;ClientOptionsTests.test_options_with_environment_expansionscCs�|j�}td�}tj�}tjj|d�}t|d��}|j|�WdQRXz||_	|j
gd�Wdtj|dd�X|j
j}|j|jtjj|d��|j|jdtjj|d	��dS)
Nz}
        [supervisorctl]
        history_file=%(here)s/sc_history
        serverurl=unix://%(here)s/supervisord.sock
        zsupervisord.conf�w)rT)�
ignore_errorsr�zunix://zsupervisord.sock)r|rrq�mkdtemprUr�r��open�writer4rT�shutil�rmtreer!r�rNr�r�)rr�r��here�supervisord_confrsr6rrr�/test_options_supervisorctl_section_expands_hereus zBClientOptionsTests.test_options_supervisorctl_section_expands_herecCsrtjjtjjt�d�}|j�}y|j|�|jd�Wn6tk
rl}z|j	d|j
dk�WYdd}~XnXdS)N�nonexistentznothing raisedzcould not find config filer)rUr�r��dirname�__file__r|r'�failr"rlr)rr�r��excrrr�test_read_config_not_found�s
z-ClientOptionsTests.test_read_config_not_foundcCsj|j�}dd�}||_y|jt�|jd�Wn6tk
rd}z|jd|jdk�WYdd}~XnXdS)NcSsttjd|��dS)NzPermission denied: %s)�IOError�errno�EACCES)�fn�moderrr�
dummy_open�szBClientOptionsTests.test_read_config_unreadable.<locals>.dummy_openzexpected exceptionzcould not read config filer)r|r�r'r�r�r"rlr)rr�r�r�rrr�test_read_config_unreadable�s
z.ClientOptionsTests.test_read_config_unreadablecCs\|j�}y|jt��|jd�Wn4tk
rV}z|j|jdd�WYdd}~XnXdS)Nznothing raisedrz0.ini file does not include supervisorctl section)r|r'rr�r"rNr)rr�r�rrr�9test_read_config_no_supervisord_section_raises_valueerror�szLClientOptionsTests.test_read_config_no_supervisord_section_raises_valueerrorcCs8td�}|j�}||_|jddgd�|j|jd�dS)Nz[supervisorctl]z--serverurlzunix:///dev/null)r)rr|r4rTrNr�)rr&r�rrr�test_options_unixsocket_cli�s
z.ClientOptionsTests.test_options_unixsocket_clicCs<td�}t|�}|j�}||_|jgd�|j|jd�dS)Nz;[supervisorctl]
        serverurl=unix:///dev/null
        )rzunix:///dev/null)rrr|r4rTrNr�)rr�r&r�rrr�"test_options_unixsocket_configfile�sz5ClientOptionsTests.test_options_unixsocket_configfileN)rrrrr|r�r�r�r�r�r�r�r�r�r�r�r�rrrrrzs
		rzc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4dedf�Z5dgdh�Z6didj�Z7dkdl�Z8dmdn�Z9dodp�Z:dqdr�Z;dsdt�Z<dudv�Z=e>dwe?e@dx��dydz��ZAd{d|�ZBd}d~�ZCdd��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d„Zed�dĄZfd�dƄZgd�dȄZhd�dʄZid�d̄Zjd�d΄Zkd�dЄZld�d҄Zmd�dԄZnd�dքZod�d؄Zpd�dڄZqd�d܄Zrd�dބZsd�d�Ztd�d�Zud�d�Zvd�d�Zwd�d�Zxd�d�Zyd�d�Zzd�d�Z{d�d�Z|d�d�Z}d�d�Z~d�d��Zd�d��Z�d�d��Z�d�d��Z�d�d��Z�d��d�Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d	�d
�Z�e>�de?�d�d
�d�dg�d��e>�de?�d�d���d�d���Z�e>�de?�d�d
�d�dg�d��e>�de?�d�d���d�d���Z��d�d�Z��d
S(�ServerOptionsTestscCsddlm}|S)Nr)�
ServerOptions)rr�)rr�rrrr�sz"ServerOptionsTests._getTargetClasscCs
|j��S)N)r)rrrrr|�szServerOptionsTests._makeOnecCsFddlm}|j�}t�|_|jt|jd�|j|jj	�|d�dS)Nr)�VERSION�
)
rr�r|rrer9�
SystemExit�versionrNrm)rr�r6rrr�test_version�s
zServerOptionsTests.test_versioncCsR	tddtj�i�}ddlm}t|�}|j�}||_|jgd�|j	j
}|j|jtj��|j|j
d�|j|jd�|j|jd5�|j|jd
�|j|jd�|j|jd�|j|jd
�|j|jd
�|j|jd�|j|jtj��|jt|j�d�|j|jddtj�|j|jddd�|j|jddd�|j|jddd�|j|jddd�|j|jd
�|j|jd�|j|jd�|j|jd
�|jt|j�d
�|j|jt dd��|jd}|j|j!d�|j|j"d�|jt|j#�d�|j#d}|j|j!d�|j|j$d�|j|j"d�|j|j%d
�|j|j&|j'�|j|j(d
�|j|j)d�|j|j*d�|j|j+d �|j|j,t-j.�|j|j/d
�|j|j0d!�|j|j1d!�|j|j2|j3d"��|j|j4d�|j|j5dg�|j|jd#�|j|j
d$�|j|jt dd��|jd}|j|j!d%�|j|j"d$�|jt|j#�d�|j#d}	|j|	j!d%�|j|	j$d�|j|	j"d$�|j|	j%d
�|j|	j&d!�|j|	j*d�|j|	j+d&�|j|	j,t-j6�|j|	j0d!�|j|	j1d!�|j|	j2d	�|j|	j4d$�|j|	j5dg�|j|	jd�|jd$}
|j|
j!d'�|j|
j"d(�|jt|
j#�d�|
j#d}|j|j!d)�|j|j$d�|j|j"d(�|j|j%d
�|j|j&|j7�|j|j*d�|j|j+|j8�|j|j2|j3d"��|j|j4d�|j|j5ddd*g�|j|j,t-j6�|j|j0d
�|j|j1d
�|jd(}|j|j!d+�|j|j"d,�|jt|j#�d$�|j#d}
|j|
j!d-�|j|
j$d�|j|
j"d,�|j|
j%d
�|j|
j&|j'�|j|
j*d�|j|
j+|j8�|j|
j2|j3d"��|j|
j4d�|j|
j5dg�|j|
j,t-j6�|j|
j0d!�|j|
j1d!�|j|
jd�|j#d}|j|j!d.�|j|j$d�|j|j"d,�|j|j%d
�|j|j&|j'�|j|j*d�|j|j+|j8�|j|j2|j3d"��|j|j4d�|j|j5dg�|j|j,t-j6�|j|j0d!�|j|j1d!�|j|jd�|jd,}|j|j!d/�|j|j"d
�|jt|j#�d$�|j#d}|j|j!d0�|j|jd1�|j#d}|j|j!d2�|j|jd3�t9j:j;t9j<��}|j|j*d�|j|j=d�|j|jtj��|j|j
d�|j|jt9j:j>|d��|j|jd7�|j|jd
�|j|jd�|j|jt9j:j>|d��|j|jd
�|j|jd
�|j|j?d�|j|jd�|j|jtj��|jt|j�d�|j|jddtj�|j|jddd�|j|jddd�|j|jddd�|j|jddd�|j|jd
�|j|jd�|j|jd�dS)8Na�
        [supervisord]
        directory=%(tempdir)s
        backofflimit=10
        user=root
        umask=022
        logfile=supervisord.log
        logfile_maxbytes=1000MB
        logfile_backups=5
        loglevel=error
        pidfile=supervisord.pid
        nodaemon=true
        silent=true
        identifier=fleeb
        childlogdir=%(tempdir)s
        nocleanup=true
        minfds=2048
        minprocs=300
        environment=FAKE_ENV_VAR=/some/path

        [inet_http_server]
        port=127.0.0.1:8999
        username=chrism
        password=foo

        [program:cat1]
        command=/bin/cat
        priority=1
        autostart=true
        user=root
        stdout_logfile=/tmp/cat.log
        stopsignal=KILL
        stopwaitsecs=5
        startsecs=5
        startretries=10
        directory=/tmp
        umask=002

        [program:cat2]
        priority=2
        command=/bin/cat
        autostart=true
        autorestart=false
        stdout_logfile_maxbytes = 1024
        stdout_logfile_backups = 2
        stdout_logfile = /tmp/cat2.log

        [program:cat3]
        priority=3
        process_name = replaced
        command=/bin/cat
        autorestart=true
        exitcodes=0,1,127
        stopasgroup=true
        killasgroup=true

        [program:cat4]
        priority=4
        process_name = fleeb_%%(process_num)s
        numprocs = 2
        command = /bin/cat
        autorestart=unexpected

        [program:cat5]
        priority=5
        process_name = foo_%%(process_num)02d
        numprocs = 2
        numprocs_start = 1
        command = /bin/cat
        directory = /some/path/foo_%%(process_num)02d
        r�r)�	datatypes)r�zsupervisord.logi�i��(zsupervisord.pidTZfleebr`�family�hostz	127.0.0.1�porti'#r�Zchrismr�rgii,z
/some/path)�FAKE_ENV_VAR�cat1z/bin/cat�
z/tmp/cat.logFZ50MBz/tmprb�cat2z
/tmp/cat2.log�cat3�Zreplaced��cat4rLZfleeb_0Zfleeb_1�cat5Zfoo_01z/some/path/foo_01Zfoo_02z/some/path/foo_02i�i�>i�i�>)@rrqr��
supervisorr�rr|r4rTr!�supervisordrN�	directory�umask�logfile�logfile_maxbytes�logfile_backups�loglevel�pidfile�nodaemon�silent�
identifier�childlogdirrO�server_configs�socket�AF_INET�	nocleanup�minfds�minprocs�process_group_configs�environment�dictr,�priority�process_configs�command�	autostart�autorestart�RestartWhenExitUnexpected�	startsecs�startretries�uid�stdout_logfile�
stopsignal�signal�SIGKILL�stopwaitsecs�stopasgroup�killasgroup�stdout_logfile_maxbytes�	byte_size�stdout_logfile_backupsr^�SIGTERMZRestartUnconditionally�	AutomaticrUr��abspath�getcwd�gidr�Z
passwdfile)rr�r�r&r�r6r��proc1r�Zproc2r�Zproc3r�Zproc4_aZproc4_br�Zproc5_aZproc5_br�rrrr��sLF











zServerOptionsTests.test_optionscCsNtd�}|j�}t|�|_|jgd�|jj}|j|jd�|j|j	d�dS)Nz�
        [supervisord]
        logfile=/tmp/supervisord.log ;(main log file;default $CWD/supervisord.log)
        minfds=123 ; (min. avail startup file descriptors;default 1024)
        )rz/tmp/supervisord.log�{)
rr|rr4rTr!r�rNr�r�)rr�r�r6rrrr��s
zFServerOptionsTests.test_options_ignores_space_prefixed_inline_commentscCs@td�}|j�}t|�|_|jgd�|jj}|j|jd�dS)Nz�
        [supervisord]
        logfile=/tmp/supervisord.log	;(main log file;default $CWD/supervisord.log)
        minfds=123	; (min. avail startup file descriptors;default 1024)
        )rr�)	rr|rr4rTr!r�rNr�)rr�r�r6rrrr��s
zDServerOptionsTests.test_options_ignores_tab_prefixed_inline_commentscCs*td�}|j�}t|�|_|jgd�dS)Nz�
        [supervisord]

        [program:duplicate]
        command=/bin/cat

        [program:duplicate]
        command=/bin/cat
        )r)rr|rr4rT)rr�r�rrrr��s

zFServerOptionsTests.test_options_parses_as_nonstrict_for_py2_py3_compatcCs\td�}|j�}t|�|_|jgd�|jj}|jt|j	�d�|j	d}|jt|j
�d�|j	d}|jt|j
�d�|j|j	|j	k�td�}t|�|_|jdd�|jj}|jt|j	�d�|j	d}|jt|j
�d�|j
d}|j|j
d	�|j|jd
�|j|j	|j	k�|j	d}|jt|j
�d�|j
d}|j|j
d�|j|jd�dS)
Nz�        [supervisord]
        user=root

        [program:one]
        command = /bin/cat

        [program:two]
        command = /bin/dog

        [program:four]
        command = /bin/sheep

        [group:thegroup]
        programs = one,two
        )rrbrr`z�        [supervisord]
        user=root

        [program:one]
        command = /bin/cat

        [program:three]
        command = /bin/pig

        [group:thegroup]
        programs = three
        F)raZonez/bin/catZthreez/bin/pig)rr|rr4rTr!r�rNrOr�r�rlrXr,r�)rr�r��section�cat�procrrr�test_reload�s>









zServerOptionsTests.test_reloadcCsv|j�}d}|g|_|g|_|g|_td�}t|�|_|jgd�|j||jk�|j||jk�|j||jk�dS)Nz Message from a prior config readzb        [supervisord]
        user=root

        [program:cat]
        command = /bin/cat
        )r)	r|Zparse_criticals�parse_warnings�parse_infosrrr4rT�assertFalse)rr�Zold_msgr�rrr�!test_reload_clears_parse_messages3s
z4ServerOptionsTests.test_reload_clears_parse_messagescCsF|j�}d}|g|_td�}t|�|_|jgd�|j||jk�dS)NzInfo from a prior config readzb        [supervisord]
        user=root

        [program:cat]
        command = /bin/cat
        )r)r|Zinfosrrr4rTrr)rr�Zold_infor�rrr�test_reload_clears_parse_infosGs
z1ServerOptionsTests.test_reload_clears_parse_infoscCsrtjjtjjt�d�}|j�}y|j|�|jd�Wn6tk
rl}z|j	d|j
dk�WYdd}~XnXdS)Nr�znothing raisedzcould not find config filer)rUr�r�r�r�r|r'r�r"rlr)rr�r�r�rrrr�Ws
z-ServerOptionsTests.test_read_config_not_foundcCsj|j�}dd�}||_y|jt�|jd�Wn6tk
rd}z|jd|jdk�WYdd}~XnXdS)NcSsttjd|��dS)NzPermission denied: %s)r�r�r�)r�r�rrrr�bszBServerOptionsTests.test_read_config_unreadable.<locals>.dummy_openznothing raisedzcould not read config filer)r|r�r'r�r�r"rlr)rr�r�r�rrrr�`s
z.ServerOptionsTests.test_read_config_unreadablecCs�|j�}tjdd���}y,|jd�|j�|j|j�|jd�WnLtk
r�}z0|j	d|j
dk�|j	|j|j
dk�WYdd}~XnXWdQRXdS)Nzw+)r�z[supervisord]
junkznothing raisedzcontains parsing errors:r)r|rqrrr��flushr'r,r�r"rlr)rr�rsr�rrr�8test_read_config_malformed_config_file_raises_valueerrorls
zKServerOptionsTests.test_read_config_malformed_config_file_raises_valueerrorcCs�|j�}tjjtjjt�dd�}td|�}y|jt|��|j	d�Wn8t
k
r�}z|j|jdd|�WYdd}~XnXdS)Nr�zsupervisord.logz1        [supervisord]
        logfile=%s
        znothing raisedrz9The directory named as part of the path %s does not exist)
r|rUr�r�r�r�rr'rr�r"rNr)rr�Zlogfile_with_nonexistent_dirr�r�rrr�1test_read_config_logfile_with_nonexistent_dirpathys
zDServerOptionsTests.test_read_config_logfile_with_nonexistent_dirpathcCs\|j�}y|jt��|jd�Wn4tk
rV}z|j|jdd�WYdd}~XnXdS)Nznothing raisedrz..ini file does not include supervisord section)r|r'rr�r"rNr)rr�r�rrrr��szLServerOptionsTests.test_read_config_no_supervisord_section_raises_valueerrorcCsf|j�}td�}y|jt|��|jd�Wn4tk
r`}z|j|jdd�WYdd}~XnXdS)NzD        [supervisord]

        [include]
        ;no files=
        znothing raisedrz5.ini file has [include] section, but no files setting)r|rr'rr�r"rNr)rr�r�r�rrr�8test_read_config_include_with_no_files_raises_valueerror�szKServerOptionsTests.test_read_config_include_with_no_files_raises_valueerrorcCs2|j�}td�}|jt|��|j|jdg�dS)NzM        [supervisord]

        [include]
        files=nonexistent/*
        z-No file matches via include "./nonexistent/*")r|rr'rrNr)rr�r�rrr�<test_read_config_include_with_no_matching_files_logs_warning�szOServerOptionsTests.test_read_config_include_with_no_matching_files_logs_warningc"Cs0tj�}tjj|d�}tj|�tjj|d�}td||f�}t|d��}|j|�WdQRXtjj|d�}t|d��}|jd�WdQRXtjj|d�}t|d��}|jd�WdQRX|j	�}z|j
|�Wdtj|d	d
�X|j
j}	|jt|	j�d�d|}
|j|
|jk�d|}
|j|
|jk�dS)
Nzconf.dzsupervisord.confz`        [supervisord]

        [include]
        files=%s/conf.d/*.conf %s/conf.d/*.ini
        r�za.confz[inet_http_server]
port=8000
za.iniz"[unix_http_server]
file=/tmp/file
T)r�rbz'Included extra file "%s" during parsing)rqr�rUr�r��mkdirrr�r�r|r'r�r�r!r�rNrOr�rlr)rr��conf_dr�r�rs�	conf_fileZini_filer�r6rorrr�*test_read_config_include_reads_extra_files�s0
z=ServerOptionsTests.test_read_config_include_reads_extra_filescCs.tj�}tjj|d�}tj|�tjj|d�}td|�}t|d��}|j|�WdQRXddl	m
}|dd�}xJt|�D]>}tjj|d|�}	t|	d��}|jd	||f�WdQRXq|W|j�}
z|
j
|�Wdtj|d
d�Xg}x0t|�D]$}tjj|d|�}	|jd|	�q�W|j|
j|�dS)
Nzconf.dzsupervisord.confzP        [supervisord]

        [include]
        files=%s/conf.d/*.conf
        r�r)�letters�z%s.confz[program:%s]
command=/bin/%s
T)r�z'Included extra file "%s" during parsing)rqr�rUr�r�rrr�r��supervisor.compatr�reversedr|r'r�r��sortedr\rNr)rr�r
r�r�rsrZa_zZletter�filenamer�Z
expected_msgsrrr�4test_read_config_include_reads_files_in_sorted_order�s2

zGServerOptionsTests.test_read_config_include_reads_files_in_sorted_orderc
'Cs(tj�}tjj|d�}tj|�tjj|d�}td|�}t|d��}|j|�WdQRXtjj|d�}t|d��}|jd�WdQRX|j	�}z�y|j
|�|jd�Wndtk
�r}zF|j
d|jd	k�|j
||jd	k�d
|}	|j
|	|jk�WYdd}~XnXWdtj|dd�XdS)
Nzconf.dzsupervisord.confzP        [supervisord]

        [include]
        files=%s/conf.d/*.conf
        r�za.confz[inet_http_server]
junk
znothing raisedzcontains parsing errors:rz'Included extra file "%s" during parsingT)r�)rqr�rUr�r�rrr�r�r|r'r�r"rlrrr�r�)
rr�r
r�r�rsZmalformed_filer�r�rorrr�-test_read_config_include_extra_file_malformed�s*


&[email protected]_read_config_include_extra_file_malformedc
Cs�tj�}tjj|d�}tj|�tjj|d�}td|df�}t|d��}|j|�WdQRXtjj|dt	j
��}t|d��}|jd�WdQRX|j�}z|j|�Wdt
j|dd	�X|jj}|jt|j�d
�d|}	|j|	|jk�dS)Nzconf.dzsupervisord.confzQ        [supervisord]

        [include]
        files=%s/conf.d/%s.conf
        z%(host_node_name)sr�z%s.confz[inet_http_server]
port=8000
T)r�r`z'Included extra file "%s" during parsing)rqr�rUr�r�rrr�r��platform�noder|r'r�r�r!r�rNrOr�rlr)
rr�r
r�r�rsrr�r6rorrr�/test_read_config_include_expands_host_node_names&
zBServerOptionsTests.test_read_config_include_expands_host_node_namecCsztjjtjjtjjt��dd�}tjj|�}tjj|d�}|j�}||_|jd�|j	j
}|j|j|�|j|j
|�dS)NZfixtureszinclude.confZexampleT)rUr�r�r�r�r�r|r4Zprocess_config_filer!r�rNr�r�)rZconfZ	root_hereZinclude_here�parserr�rrr�%test_read_config_include_expands_here2s
z8ServerOptionsTests.test_read_config_include_expands_herecCs^ddlm}y|ddd�Wn4tk
rP}z|j|jdd�WYdd}~Xn
Xtd��dS)Nr)�readFilez	/nottherer�ZFAILEDzDidn't raise)rrr"rNr�AssertionError)rrr;rrr�test_readFile_failed?s$z'ServerOptionsTests.test_readFile_failedcCs |j�}|jtj�|j��dS)N)r|rNrU�getpidZget_pid)rr�rrr�test_get_pidHszServerOptionsTests.test_get_pidcCs`|j�}|jjtjd�|jjtjd�|j|j�tj�|j|j�tj�|j|j�d�dS)N)r|Zsignal_receiver�receiver�r��SIGCHLDrN�
get_signal)rr�rrr�,test_get_signal_delegates_to_signal_receiverLsz?ServerOptionsTests.test_get_signal_delegates_to_signal_receivercCs,|j�}ddlm}|j||jddd�dS)Nr)�NotFoundz
/not/there)r|rr&r9�check_execv_args)rr�r&rrr�'test_check_execv_args_cant_find_commandTs
z:ServerOptionsTests.test_check_execv_args_cant_find_commandcCs4|j�}ddlm}|j||jddgtjd��dS)Nr)�
NotExecutablez/etc/passwdz
etc/passwd)r|rr)r9r'rU�stat)rr�r)rrr�#test_check_execv_args_notexecutableZs
z6ServerOptionsTests.test_check_execv_args_notexecutablecCs4|j�}ddlm}|j||jddgtjd��dS)Nr)r)�/)r|rr)r9r'rUr*)rr�r)rrr�test_check_execv_args_isdiras
z.ServerOptionsTests.test_check_execv_args_isdircsd|j�}g��fdd�}||_td�|_ddg}|j|d�|jt��d�|j�dd	|�dS)
Ncs�j|�dS)N)r\)�message)�recorderrr�record_usagelszSServerOptionsTests.test_realize_positional_args_not_supported.<locals>.record_usagez
[supervisord]rgrh)rr`rz*positional arguments are not supported: %s)r|�usagerr4rTrNrO)rr�r0rr)r/r�*test_realize_positional_args_not_supportedhs

z=ServerOptionsTests.test_realize_positional_args_not_supportedcsZ|j�}g��fdd�}||_td�|_|jdgd�|jt��d�|j�dd�dS)	Ncs�j|�dS)N)r\)r.)r/rrr0{szBServerOptionsTests.test_realize_getopt_error.<locals>.record_usagez
[supervisord]z--bad=1)rr`rzoption --bad not recognized)r|r1rr4rTrNrO)rr�r0r)r/r�test_realize_getopt_errorws
z,ServerOptionsTests.test_realize_getopt_errorcCs�|j�}td�}ddlm}|�}|j|�t|�|_|jt|��|jgd�|j	j
}|j|jddt
j�|j|jddd�|j|jddd	�|j|jdd
d�dS)Nz�        [unix_http_server]
        file=/tmp/supvtest.sock
        username=johndoe
        password=passwordhere

        [supervisord]
        ; ...
        r)�UnhosedConfigParser)rr��filez/tmp/supvtest.sock�chmodi��chownr`���r8)r8r8)r|rrr4�read_stringrr4r'rTr!r�rNr�r��AF_UNIX)rr�r�r4rtr6rrr�test_options_afunix�s

z&ServerOptionsTests.test_options_afunixcCs�|j�}td�}ddlm}|�}|j|�t|�|_|jt|��|jgd�|j	j
}|j|jddt
j�|j|jddd�|j|jddd	�dS)
Nz�        [unix_http_server]
        file=/tmp/supvtest.sock
        username=johndoe
        password=passwordhere
        chmod=0755

        [supervisord]
        ; ...
        r)r4)rr�r5z/tmp/supvtest.sockr6i�)r|rrr4r9rr4r'rTr!r�rNr�r�r:)rr�r�r4rtr6rrr�&test_options_afunix_chxxx_values_valid�s	

z9ServerOptionsTests.test_options_afunix_chxxx_values_validcCsp|j�}td�}t|�|_y|jt|��|jd�Wn4tk
rj}z|j|jdd�WYdd}~XnXdS)Nzc        [supervisord]

        [unix_http_server]
        file=/tmp/file
        chmod=NaN
        znothing raisedrzInvalid chmod value NaN)	r|rrr4r'r�r"rNr)rr�r�r�rrr�test_options_afunix_chmod_bad�s
z0ServerOptionsTests.test_options_afunix_chmod_badcCsp|j�}td�}t|�|_y|jt|��|jd�Wn4tk
rj}z|j|jdd�WYdd}~XnXdS)Nzs        [supervisord]

        [unix_http_server]
        file=/tmp/file
        chown=thisisnotavaliduser
        znothing raisedrz+Invalid sockchown value thisisnotavaliduser)	r|rrr4r'r�r"rNr)rr�r�r�rrr�test_options_afunix_chown_bad�s
z0ServerOptionsTests.test_options_afunix_chown_badcCsp|j�}td�}t|�|_y|jt|��|jd�Wn4tk
rj}z|j|jdd�WYdd}~XnXdS)NzL        [supervisord]

        [unix_http_server]
        ;no file=
        znothing raisedrz,section [unix_http_server] has no file value)	r|rrr4r'r�r"rNr)rr�r�r�rrr�test_options_afunix_no_file�s
z.ServerOptionsTests.test_options_afunix_no_filecCsp|j�}td�}t|�|_y|jt|��|jd�Wn4tk
rj}z|j|jdd�WYdd}~XnXdS)Nz�        [supervisord]

        [unix_http_server]
        file=/tmp/supvtest.sock
        username=usernamehere
        ;no password=
        chmod=0755
        znothing raisedrz�Section [unix_http_server] contains incomplete authentication: If a username or a password is specified, both the username and password must be specified)	r|rrr4r'r�r"rNr)rr�r�r�rrr�-test_options_afunix_username_without_password�s
[email protected]_options_afunix_username_without_passwordcCsp|j�}td�}t|�|_y|jt|��|jd�Wn4tk
rj}z|j|jdd�WYdd}~XnXdS)Nz�        [supervisord]

        [unix_http_server]
        file=/tmp/supvtest.sock
        ;no username=
        password=passwordhere
        chmod=0755
        znothing raisedrz�Section [unix_http_server] contains incomplete authentication: If a username or a password is specified, both the username and password must be specified)	r|rrr4r'r�r"rNr)rr�r�r�rrr�-test_options_afunix_password_without_username�s
[email protected]_options_afunix_password_without_usernamecCs�|j�}td�}tj�}tjj|d�}t|d��}|j|�WdQRXz||_	|j
gd�Wdtj|dd�X|j
j}|jd}|j|dtj�|j|d	tjj|d
��dS)Nza        [supervisord]

        [unix_http_server]
        file=%(here)s/supervisord.sock
        zsupervisord.confr�)rT)r�rr�r5zsupervisord.sock)r|rrqr�rUr�r�r�r�r4rTr�r�r!r�r�rNr�r:)rr�r�r�r�rsr6Z
serverconfrrr�%test_options_afunix_file_expands_heres 

z8ServerOptionsTests.test_options_afunix_file_expands_herecCsp|j�}td�}t|�|_y|jt|��|jd�Wn4tk
rj}z|j|jdd�WYdd}~XnXdS)Nz�        [supervisord]

        [inet_http_server]
        file=/tmp/supvtest.sock
        username=usernamehere
        ;no password=
        chmod=0755
        znothing raisedrz�Section [inet_http_server] contains incomplete authentication: If a username or a password is specified, both the username and password must be specified)	r|rrr4r'r�r"rNr)rr�r�r�rrr�-test_options_afinet_username_without_password*s
[email protected]_options_afinet_username_without_passwordcCsp|j�}td�}t|�|_y|jt|��|jd�Wn4tk
rj}z|j|jdd�WYdd}~XnXdS)Nzn        [supervisord]

        [inet_http_server]
        password=passwordhere
        ;no username=
        znothing raisedrz�Section [inet_http_server] contains incomplete authentication: If a username or a password is specified, both the username and password must be specified)	r|rrr4r'r�r"rNr)rr�r�r�rrr�-test_options_afinet_password_without_username@s
[email protected]_options_afinet_password_without_usernamecCsp|j�}td�}t|�|_y|jt|��|jd�Wn4tk
rj}z|j|jdd�WYdd}~XnXdS)NzL        [supervisord]

        [inet_http_server]
        ;no port=
        znothing raisedrz,section [inet_http_server] has no port value)	r|rrr4r'r�r"rNr)rr�r�r�rrr�test_options_afinet_no_portTs
z.ServerOptionsTests.test_options_afinet_no_portc
Cs~tj�}t|d��}|jd�WdQRX|j�}d|_Gdd�d�}tj|d�|�fg|_d|_	|j
�|jtj
j|��dS)Nr�rgTc@seZdZdS)z=ServerOptionsTests.test_cleanup_afunix_unlink.<locals>.ServerN)rrrrrrr�ServerjsrF)r�r5rw)rq�mktempr�r�r|�unlink_socketfilesr�r:�httpserversr��cleanuprrUr��exists)rr�rsr�rFrrr�test_cleanup_afunix_unlinkds
z-ServerOptionsTests.test_cleanup_afunix_unlinkcCs�tj�}zvt|d��}|jd�WdQRX|j�}Gdd�d�}tj|d�|�fg|_d|_d|_	|j
�|jtj
j|��Wdytj|�Wntk
r�YnXXdS)Nr�rgc@seZdZdS)z?ServerOptionsTests.test_cleanup_afunix_nounlink.<locals>.ServerN)rrrrrrrrFxsrF)r�r5rwF)rqrGr�r�r|r�r:rIr�rHrJrlrUr�rK�unlink�OSError)rr�rsr�rFrrr�test_cleanup_afunix_nounlinkrs 
z/ServerOptionsTests.test_cleanup_afunix_nounlinkcCs�tjjtjjt�d�}tj�}z�t|d��}|jd�WdQRX|j	�}d|_
Gdd�d�}tj|d�|�ftj|d�|�fg|_
d|_|j�|jtjj|��Wdytj|�Wntk
r�YnXXdS)	N�notfoundr�rgTc@seZdZdS)zMServerOptionsTests.test_cleanup_afunix_ignores_oserror_enoent.<locals>.ServerN)rrrrrrrrF�srF)r�r5rw)rUr�r�r�r�rqrGr�r�r|rHr�r:rIr�rJrrKrMrN)rrPZ
socketnamersr�rFrrr�*test_cleanup_afunix_ignores_oserror_enoent�s"z=ServerOptionsTests.test_cleanup_afunix_ignores_oserror_enoentcCs�tj�}zht|d��}|jd�WdQRX|j�}||_t�|_|j�|j	|j
�|j�|jt
jj|��Wdyt
j|�Wntk
r�YnXXdS)Nr��2)rqrGr�r�r|r�r	�logger�
write_pidfilerl�unlink_pidfilerJrrUr�rKrMrN)rr�rsr�rrr�test_cleanup_removes_pidfile�sz/ServerOptionsTests.test_cleanup_removes_pidfilecCs0tjjtjjt�d�}|j�}||_|j�dS)NrP)rUr�r�r�r�r|r�rJ)rrPr�rrr�+test_cleanup_pidfile_ignores_oserror_enoent�sz>ServerOptionsTests.test_cleanup_pidfile_ignores_oserror_enoentcCs�tj�}t|d��}|jd�WdQRXz8|j�}||_|j|j�|j�|j	t
jj|��Wdyt
j
|�Wntk
r�YnXXdS)Nr�Z1234)rqrGr�r�r|r�rrUrJrlrUr�rKrMrN)rr�rsr�rrr�=test_cleanup_does_not_remove_pidfile_from_another_supervisord�szPServerOptionsTests.test_cleanup_does_not_remove_pidfile_from_another_supervisordcCs�tj�}z`t|d��}|jd�WdQRX|j�}||_ti�}||_|j|j	�|j
�|j|j	�Wdytj
|�Wntk
r�YnXXdS)Nr�rR)rqrGr�r�r|r�r�pollerr�closedrJrlrUrMrN)rr�rsr�rYrrr�test_cleanup_closes_poller�sz-ServerOptionsTests.test_cleanup_closes_pollercsR|j��d�_g��fdd�}td|��fdd��}|�|j�ddd	d
g�dS)Nr�cs|dkrt��j|�dS)N�)rNr\)�fd)rZrr�close�szWServerOptionsTests.test_cleanup_fds_closes_5_upto_minfds_ignores_oserror.<locals>.closezos.closecs�j�dS)N)Zcleanup_fdsr)r�rrrs�szSServerOptionsTests.test_cleanup_fds_closes_5_upto_minfds_ignores_oserror.<locals>.fr�rK��	)r|r�rrN)rr^rsr)rZr�r�5test_cleanup_fds_closes_5_upto_minfds_ignores_oserror�szHServerOptionsTests.test_cleanup_fds_closes_5_upto_minfds_ignores_oserrorcCsB|j�}Gdd�d�}|�}i|fg|_|j�|j|jd�dS)Nc@seZdZdZdd�ZdS)z9ServerOptionsTests.test_close_httpservers.<locals>.ServerFcSs
d|_dS)NT)rZ)rrrrr^�sz?ServerOptionsTests.test_close_httpservers.<locals>.Server.closeN)rrrrZr^rrrrrF�srFT)r|rIZclose_httpserversrNrZ)rr�rFZserverrrr�test_close_httpservers�sz)ServerOptionsTests.test_close_httpserverscCs.|j�}t�}||_|j�|j|jd�dS)NT)r|r	rSZclose_loggerrNrZ)rr�rSrrr�test_close_logger�s
z$ServerOptionsTests.test_close_loggercsT|j�}g��fdd�}||_ddddddd	�}|j|�|jt��dddg�dS)
Ncs�j|�dS)N)r\)r])rZrr�close_fdsz<ServerOptionsTests.test_close_parent_pipes.<locals>.close_fdrr`rbr�rLr�)�stdinrerd�child_stdin�child_stdout�child_stderr)r|rd�close_parent_pipesrNr)rr�rd�pipesr)rZr�test_close_parent_pipes�s
z*ServerOptionsTests.test_close_parent_pipescs@|j�}g��fdd�}||_ddi}|j|�|j�g�dS)Ncs�j|�dS)N)r\)r])rZrrrd
szOServerOptionsTests.test_close_parent_pipes_ignores_fd_of_none.<locals>.close_fdre)r|rdrirN)rr�rdrjr)rZr�*test_close_parent_pipes_ignores_fd_of_none
s
z=ServerOptionsTests.test_close_parent_pipes_ignores_fd_of_nonecsT|j�}g��fdd�}||_ddddddd	�}|j|�|jt��dddg�dS)
Ncs�j|�dS)N)r\)r])rZrrrdsz;ServerOptionsTests.test_close_child_pipes.<locals>.close_fdrr`rbr�rLr�)rererdrfrgrh)r|rdZclose_child_pipesrNr)rr�rdrjr)rZr�test_close_child_pipess
z)ServerOptionsTests.test_close_child_pipescsD|j�}g��fdd�}||_ddi}|j|�|jt��g�dS)Ncs�j|�dS)N)r\)r])rZrrrd"szNServerOptionsTests.test_close_child_pipes_ignores_fd_of_none.<locals>.close_fdrf)r|rdrirNr)rr�rdrjr)rZr�)test_close_child_pipes_ignores_fd_of_nones
z<ServerOptionsTests.test_close_child_pipes_ignores_fd_of_nonecCsP|j�}t�}t�g|_||_|j�|j|jdjd�|j|jdd�dS)NrTzsupervisord logreopen)r|r	ZhandlersrSZ
reopenlogsrNZreopened�data)rr�rSrrr�test_reopenlogs)s
z"ServerOptionsTests.test_reopenlogscCs�tj�}z�|j�}t�|_||_|j�|jtj	j
|��t|d��}t|j
�j��}WdQRX|j|tj��|jjd}|j|jd��|j|j�Wdytj|�Wntk
r�YnXXdS)N�rrzsupervisord started with pid)rqrGr|r	rSr�rTrlrUr�rKr��int�read�striprNr rornrUrMrN)rr�r�rs�pidrorrr�test_write_pidfile_ok2s"z(ServerOptionsTests.test_write_pidfile_okcCsNd}|j�}t�|_||_|j�|jjd}|j|jd��|j|j	�dS)Nz/cannot/possibly/existrzcould not write pidfile)
r|r	rSr�rTrorlrnrrU)rr�r�rorrr�test_write_pidfile_failFsz*ServerOptionsTests.test_write_pidfile_failcCsp|j�}tj�\}}tj|d�tj|td��|j|�|jttj|d�|j|�|jttj|td��dS)Nrrg)	r|rU�pipersr�rrdr9rN)rr�ZinnieZoutierrr�
test_close_fdPs

z ServerOptionsTests.test_close_fdzos.close)Zside_effectcCs|j�}|jd�dS)Nr)r|rd)rr�rrr�test_close_fd_ignores_oserrorZsz0ServerOptionsTests.test_close_fd_ignores_oserrorcCs`|j�}td�}ddlm}|�}|j|�|j|dd�}|jt|�d�|d}|j|jd�|j|j	d�|j|j
d	�|j|jd	�|j|jd
�|j|j
d
�|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|j|jtj�|j|jd	�|j|jd�|j|jd
�|j|jd
dg�|j|jd	�|j|jdddd��dS)Na~        [program:foo]
        command = /bin/cat
        priority = 1
        autostart = false
        autorestart = false
        startsecs = 100
        startretries = 100
        user = root
        stdout_logfile = NONE
        stdout_logfile_backups = 1
        stdout_logfile_maxbytes = 100MB
        stdout_events_enabled = true
        stopsignal = KILL
        stopwaitsecs = 100
        killasgroup = true
        exitcodes = 1,4
        redirect_stderr = false
        environment = KEY1=val1,KEY2=val2,KEY3=%(process_num)s
        numprocs = 2
        process_name = %(group_name)s_%(program_name)s_%(process_num)02d
        r)r4zprogram:foorhrbZ
bar_foo_00z/bin/catF�di@Tr`rLZval1Zval2�0)ZKEY1ZKEY2ZKEY3)r|rrr4r9�processes_from_sectionrNrOr,r�r�r�r�r�r�r��stdout_capture_maxbytesr��stdout_events_enabledr�r�r�r�r�r�r^�redirect_stderrr�)rr�r�r4rt�pconfigs�pconfigrrr�test_processes_from_section_s8
z.ServerOptionsTests.test_processes_from_sectioncCs\|j�}td�}ddlm}|�}|j|�|j|dd�}dtj�}|j|dj	|�dS)NzS        [program:foo]
        command = /bin/foo --host=%(host_node_name)s
        r)r4zprogram:foorhz/bin/foo --host=)
r|rrr4r9r}rrrNr�)rr�r�r4rtr��expectedrrr�4test_processes_from_section_host_node_name_expansion�s
zGServerOptionsTests.test_processes_from_section_host_node_name_expansioncCs�|j�}td�}ddlm}|�}|j|�|j|dd�}|jt|�d�x�dD]�}|j||jd|�|j||j	d	|�|j||j
d
|�|j||jd|�|j||jd|�|j||j
d
d|i�qPWdS)NaX        [program:foo]
        process_name = foo_%(process_num)d
        command = /bin/foo --num=%(process_num)d
        directory = /tmp/foo_%(process_num)d
        stderr_logfile = /tmp/foo_%(process_num)d_stderr
        stdout_logfile = /tmp/foo_%(process_num)d_stdout
        environment = NUM=%(process_num)d
        numprocs = 2
        r)r4zprogram:foorhrbr`zfoo_%dz/bin/foo --num=%dz/tmp/foo_%dz/tmp/foo_%d_stderrz/tmp/foo_%d_stdoutZNUMz%d)rr`)r|rrr4r9r}rNrOr,r�r��stderr_logfiler�r�)rr�r�r4rtr��numrrr�1test_processes_from_section_process_num_expansion�s"	



zDServerOptionsTests.test_processes_from_section_process_num_expansioncCs�|j�}td�}ddlm}|�}|j|�|j|dd�}|jt|�d�x8d
D]0}|j||jd|�|j||j	d	d�qPWdS)Nz�        [program:foo]
        process_name = foo_%(process_num)d
        command = /bin/foo --numprocs=%(numprocs)d
        numprocs = 2
        r)r4zprogram:foorhrbr`zfoo_%dz/bin/foo --numprocs=%d)rr`)
r|rrr4r9r}rNrOr,r�)rr�r�r4rtr�r�rrr�.test_processes_from_section_numprocs_expansion�s

zAServerOptionsTests.test_processes_from_section_numprocs_expansioncCsZ|j�}td�}ddlm}|�}ddi|_|j|�|j|dd�}|j|djd�dS)Nz^        [program:foo]
        command = /bin/cat
        directory = /tmp/%(ENV_FOO)s
        r)r4�ENV_FOOrhzprogram:fooz/tmp/bar)	r|rrr4�
expansionsr9r}rNr�)rr�r�r4rtr�rrr�-test_processes_from_section_expands_directory�s

[email protected]_processes_from_section_expands_directorycCs^|j�}td�}ddlm}|�}|j|�|j|dd�}dtjd}|j|dj	|�dS)NzO        [program:foo]
        command = /bin/foo --path='%(ENV_PATH)s'
        r)r4zprogram:foorhz/bin/foo --path='%s'�PATH)
r|rrr4r9r}rUrVrNr�)rr�r�r4rtr�r�rrr�;test_processes_from_section_environment_variables_expansion�s
zNServerOptionsTests.test_processes_from_section_environment_variables_expansioncCsb|j�}td�}ddlm}|�}|j|�|j|dd�}dtjd}|j|dj	d|�dS)Nzl        [program:foo]
        command = /bin/foo
        environment = PATH='/foo/bar:%(ENV_PATH)s'
        r)r4zprogram:foorhz/foo/bar:%sr�)
r|rrr4r9r}rUrVrNr�)rr�r�r4rtr�r�rrr�6test_processes_from_section_expands_env_in_environment�s
zIServerOptionsTests.test_processes_from_section_expands_env_in_environmentcCsb|j�}td�}ddlm}|�}|j|�|j|dd�}|j|jdd�|j|djd�dS)Nz~        [program:foo]
        command = /bin/foo
        redirect_stderr = true
        stderr_logfile = /tmp/logfile
        r)r4zprogram:foorhzyFor [program:foo], redirect_stderr=true but stderr_logfile has also been set to a filename, the filename has been ignored)	r|rrr4r9r}rNrr�)rr�r�r4rtr�rrr�9test_processes_from_section_redirect_stderr_with_filename�s
zLServerOptionsTests.test_processes_from_section_redirect_stderr_with_filenamecCst|j�}td�}ddlm}|�}|j|�|j|dd�}|j|jdd�|j|djd�|j|dj	d�dS)NzY        [program:foo]
        command = /bin/foo
        stdout_logfile = syslog
        r)r4zprogram:foorhz�For [program:foo], stdout_logfile=syslog but this is deprecated and will be removed.  Use stdout_syslog=true to enable syslog instead.T)
r|rrr4r9r}rNrr��
stdout_syslog)rr�r�r4rtr�rrr�=test_processes_from_section_rewrites_stdout_logfile_of_syslogs
zPServerOptionsTests.test_processes_from_section_rewrites_stdout_logfile_of_syslogcCst|j�}td�}ddlm}|�}|j|�|j|dd�}|j|jdd�|j|djd�|j|dj	d�dS)NzY        [program:foo]
        command = /bin/foo
        stderr_logfile = syslog
        r)r4zprogram:foorhz�For [program:foo], stderr_logfile=syslog but this is deprecated and will be removed.  Use stderr_syslog=true to enable syslog instead.T)
r|rrr4r9r}rNrr��
stderr_syslog)rr�r�r4rtr�rrr�=test_processes_from_section_rewrites_stderr_logfile_of_syslogs
zPServerOptionsTests.test_processes_from_section_rewrites_stderr_logfile_of_syslogcCs^|j�}td�}ddlm}|�}|j|�|j|dd�}|j|jg�|j|djd�dS)Nzv        [program:foo]
        command = /bin/foo
        redirect_stderr = true
        stderr_logfile = auto
        r)r4zprogram:foorh)	r|rrr4r9r}rNrr�)rr�r�r4rtr�rrr�5test_processes_from_section_redirect_stderr_with_auto(s
zHServerOptionsTests.test_processes_from_section_redirect_stderr_with_autoc	Cs@td�}ddlm}ddlm}|j�}tj�ddddd	d
dddd
dddddddddddddddd
ddd�|_|�}|j|_	|j
|�t|�|_|j
t|��|jgd�|j|jd|j	�|j|jd|j	�|j|jd�|j|jd �|j|jtj�|j|jd!�|j|jd!�|j|jd"�|j|jd#�|j|jd$�|j|j|j	d%�|j|jd!�|jj}|j|j dd&t!j"�|j|j dd'd(�|j|j dd)d*�|j|j dd+d�|j|j dd,d�|j#d}|j|j$d-�|j|j%d.�|jt&|j'�d/�|j'd}|j|j$d-�|j|j(d0�|j|j%d.�|j|j)d$�|j|j*|j+�|j|j,d1�|j|j-d �|j|j.d�|j|j/d�|j|j0t1j2�|j|j3d1�|j|j4d!�|j|j5d!�|j|j6|j7d��|j|j8d2�|j|j9dg�|j|j:d�|j|j;d2�|j|j<t=d3d4��dS)5Na^        [supervisord]
        logfile = %(ENV_HOME)s/supervisord.log
        logfile_maxbytes = %(ENV_SUPD_LOGFILE_MAXBYTES)s
        logfile_backups = %(ENV_SUPD_LOGFILE_BACKUPS)s
        loglevel = %(ENV_SUPD_LOGLEVEL)s
        nodaemon = %(ENV_SUPD_NODAEMON)s
        minfds = %(ENV_SUPD_MINFDS)s
        minprocs = %(ENV_SUPD_MINPROCS)s
        umask = %(ENV_SUPD_UMASK)s
        identifier = supervisor_%(ENV_USER)s
        nocleanup = %(ENV_SUPD_NOCLEANUP)s
        childlogdir = %(ENV_HOME)s
        strip_ansi = %(ENV_SUPD_STRIP_ANSI)s
        environment = FAKE_ENV_VAR=/some/path

        [inet_http_server]
        port=*:%(ENV_HTSRV_PORT)s
        username=%(ENV_HTSRV_USER)s
        password=%(ENV_HTSRV_PASS)s

        [program:cat1]
        command=%(ENV_CAT1_COMMAND)s --logdir=%(ENV_CAT1_COMMAND_LOGDIR)s
        priority=%(ENV_CAT1_PRIORITY)s
        autostart=%(ENV_CAT1_AUTOSTART)s
        user=%(ENV_CAT1_USER)s
        stdout_logfile=%(ENV_CAT1_STDOUT_LOGFILE)s
        stdout_logfile_maxbytes = %(ENV_CAT1_STDOUT_LOGFILE_MAXBYTES)s
        stdout_logfile_backups = %(ENV_CAT1_STDOUT_LOGFILE_BACKUPS)s
        stopsignal=%(ENV_CAT1_STOPSIGNAL)s
        stopwaitsecs=%(ENV_CAT1_STOPWAIT)s
        startsecs=%(ENV_CAT1_STARTWAIT)s
        startretries=%(ENV_CAT1_STARTRETRIES)s
        directory=%(ENV_CAT1_DIR)s
        umask=%(ENV_CAT1_UMASK)s
        r)r�)r4r�r�r�r�Z51MBZ10�infoZfalseZ1024Z200Z002�truez/bin/customcatz
/path/to/logs�3�rootz/tmp/cat.logZ78KBrRZKILL�5z/tmp)r�r�ZENV_HTSRV_PORTZENV_HTSRV_USERZENV_HTSRV_PASSZENV_SUPD_LOGFILE_MAXBYTESZENV_SUPD_LOGFILE_BACKUPSZENV_SUPD_LOGLEVELZENV_SUPD_NODAEMONZENV_SUPD_SILENTZENV_SUPD_MINFDSZENV_SUPD_MINPROCSZENV_SUPD_UMASKZENV_SUPD_NOCLEANUPZENV_SUPD_STRIP_ANSIZENV_CAT1_COMMANDZENV_CAT1_COMMAND_LOGDIRZENV_CAT1_PRIORITYZENV_CAT1_AUTOSTARTZ
ENV_CAT1_USERZENV_CAT1_STDOUT_LOGFILEZ ENV_CAT1_STDOUT_LOGFILE_MAXBYTESZENV_CAT1_STDOUT_LOGFILE_BACKUPSZENV_CAT1_STOPSIGNALZENV_CAT1_STOPWAITZENV_CAT1_STARTWAITZENV_CAT1_STARTRETRIESZENV_CAT1_DIRZENV_CAT1_UMASK)rz%(ENV_HOME)s/supervisord.logzsupervisor_%(ENV_USER)si0r�Fi��Tr�r�r�rwr�i�#r�r�r�r�r`z%/bin/customcat --logdir=/path/to/logsr�rbz
/some/path)r�)>rr�r�rr4r|rqr�r�r�r9rr4r'rTrNr�r�r�r�r�r�INFOr�r�r�r�r�r�Z
strip_ansir!r�r�r�r�r�r,r�rOr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r^r�r�r�r�)	rr�r�r4r�rtr6r�r�rrrr�7s�#




z;ServerOptionsTests.test_options_with_environment_expansionscCs�|j�}td�}tj�}tjj|d�}t|d��}|j|�WdQRXz||_	|j
gd�Wdtj|dd�X|j
|jtjj|��|j
|jtjj|��|j
|jtjj|d��|j
|jtjj|d��dS)	Nz�        [supervisord]
        childlogdir=%(here)s
        directory=%(here)s
        logfile=%(here)s/supervisord.log
        pidfile=%(here)s/supervisord.pid
        zsupervisord.confr�)rT)r�zsupervisord.logzsupervisord.pid)r|rrqr�rUr�r�r�r�r4rTr�r�rNr�r�r�r�)rr�r�r�r�rsrrr�-test_options_supervisord_section_expands_here�s&[email protected]_options_supervisord_section_expands_herec	Cs�|j�}td�}tj�}tjj|d�}t|d��}|j|�WdQRXz||_	|j
gd�Wdtj|dd�X|j
j}|jd}|j|jd�|jd}|j|jtjj|d	��dS)
Nz�
        [supervisord]
        environment=CMD=/bin/from/supervisord/section

        [program:cmd]
        command=%(ENV_CMD)s
        zsupervisord.confr�)rT)r�r�cmdz/bin/from/supervisord/section)r|rrqr�rUr�r�r�r�r4rTr�r�r!r�r�rNr,r�r�)	rr�r�r�r�rsr6�grouprrrr�>test_options_program_section_expands_env_from_supervisord_sect�s"

zQServerOptionsTests.test_options_program_section_expands_env_from_supervisord_sectc	Cs�|j�}td�}tj�}tjj|d�}t|d��}|j|�WdQRXz||_	|j
gd�Wdtj|dd�X|j
j}|jd}|j|jd�|jd}|j|jtjj|d	��dS)
Nz�
        [supervisord]
        environment=CMD=/bin/from/supervisord/section

        [program:cmd]
        command=%(ENV_CMD)s
        environment=CMD=/bin/from/program/section
        zsupervisord.confr�)rT)r�rr�z/bin/from/program/section)r|rrqr�rUr�r�r�r�r4rTr�r�r!r�r�rNr,r�r�)	rr�r�r�r�rsr6r�rrrr�:test_options_program_section_expands_env_from_program_sect�s"

zMServerOptionsTests.test_options_program_section_expands_env_from_program_sectc	Cs4|j�}td�}tj�}tjj|d�}t|d��}|j|�WdQRXz||_	|j
gd�Wdtj|dd�X|j
j}|jd}|j|jd�|jd}|j|jtjj|d	��|j|jtjj|d
��|j|jdtjj|d�i�|j|jd
tjj|d��|j|jtjj|d��|j|jtjj|d��dS)Na-
        [supervisord]

        [program:cat]
        command=%(here)s/bin/cat
        directory=%(here)s/thedirectory
        environment=FOO=%(here)s/foo
        serverurl=unix://%(here)s/supervisord.sock
        stdout_logfile=%(here)s/stdout.log
        stderr_logfile=%(here)s/stderr.log
        zsupervisord.confr�)rT)r�rr��thedirectoryzbin/cat�FOOrgzunix://zsupervisord.sockz
stdout.logz
stderr.log)r|rrqr�rUr�r�r�r�r4rTr�r�r!r�r�rNr,r�r�r�r�r�r�r�)	rr�r�r�r�rsr6r�rrrr�)test_options_program_section_expands_heres6


z<ServerOptionsTests.test_options_program_section_expands_herec	Cs4|j�}td�}tj�}tjj|d�}t|d��}|j|�WdQRXz||_	|j
gd�Wdtj|dd�X|j
j}|jd}|j|jd�|jd}|j|jtjj|d	��|j|jtjj|d
��|j|jdtjj|d�i�|j|jd
tjj|d��|j|jtjj|d��|j|jtjj|d��dS)NaP
        [supervisord]

        [eventlistener:memmon]
        events=TICK_60
        command=%(here)s/bin/memmon
        directory=%(here)s/thedirectory
        environment=FOO=%(here)s/foo
        serverurl=unix://%(here)s/supervisord.sock
        stdout_logfile=%(here)s/stdout.log
        stderr_logfile=%(here)s/stderr.log
        zsupervisord.confr�)rT)r�rZmemmonr�z
bin/memmonr�rgzunix://zsupervisord.sockz
stdout.logz
stderr.log)r|rrqr�rUr�r�r�r�r4rTr�r�r!r�r�rNr,r�r�r�r�r�r�r�)	rr�r�r�r�rsr6r�rrrr�/test_options_eventlistener_section_expands_here+s6

zBServerOptionsTests.test_options_eventlistener_section_expands_herec
Cs�|j�}td�}|d7}tj�}tjj|d�}t|d��}|j|�WdQRXz"ddd�|_	||_
|jgd�Wdtj
|d	d
�X|jj}|j|jtjj|d��|jd}|jd}d
tjj|d�tj�f}	|j|j|	�dS)Nze
        [supervisord]
        logfile = %(here)s/%(ENV_LOGNAME)s.log

        [program:cat]
        z\command = %(here)s/bin/cat --foo=%(ENV_FOO)s --num=%(process_num)d --node=%(host_node_name)szsupervisord.confr�Zmainlogrh)ZENV_LOGNAMEr�)rT)r�zmainlog.logrz%s --foo=bar --num=0 --node=%szbin/cat)r|rrqr�rUr�r�r�r�r�r4rTr�r�r!r�rNr�r�r�rrr�)
rr�r�r�r�rsr�Z	cat_groupZcat_0r�rrr�(test_options_expands_combined_expansionsSs.


z;ServerOptionsTests.test_options_expands_combined_expansionsc Cs�tj�}tjj|d�}td�}t|d��}|j|�WdQRX|j�}zb||_	y|j
dd�|jd�Wn<tk
r�}z |j
t|jd�d|�WYdd}~XnXWdtj|d	d
�XdS)Nzsupervisord.confzq
        [supervisord]

        [program:cat]
        command = /bin/cat
        stopsignal = NOTASIGNAL
        r�F)raznothing raisedrzQvalue 'NOTASIGNAL' is not a valid signal name in section 'program:cat' (file: %r)T)r�)rqr�rUr�r�rr�r�r|r4rXr�r"rN�strrr�r�)rr�r�r�rsr��errr�.test_options_error_handler_shows_main_filenamexs"zAServerOptionsTests.test_options_error_handler_shows_main_filenamec	'Cstj�}tjj|d�}td|�}t|d��}|j|�WdQRXtjj|d�}tj|�tjj|d�}td�}t|d��}|j|�WdQRX|j	�}zb||_
y|jdd�|jd	�Wn<t
k
r�}z |jt|jd
�d|�WYdd}~XnXWdtj|dd
�XdS)Nzsupervisord.confzP        [supervisord]

        [include]
        files=%s/conf.d/*.conf
        r�zconf.dz
included.confzY        [program:cat]
        command = /bin/cat
        stopsignal = NOTASIGNAL
        F)raznothing raisedrzQvalue 'NOTASIGNAL' is not a valid signal name in section 'program:cat' (file: %r)T)r�)rqr�rUr�r�rr�r�rr|r4rXr�r"rNr�rr�r�)	rr�r�r�rsr
Z
included_confr�r�rrr�2test_options_error_handler_shows_included_filename�s0

zEServerOptionsTests.test_options_error_handler_shows_included_filenamecCsD|j�}td�}ddlm}|�}|j|�|jt|j|dd�dS)Nz)        [program:spaces are bad]
        r)r4zprogram:spaces are bad)r|rrr4r9r9r"r})rr�r�r4rtrrr�3test_processes_from_section_bad_program_name_spaces�s

zFServerOptionsTests.test_processes_from_section_bad_program_name_spacescCsD|j�}td�}ddlm}|�}|j|�|jt|j|dd�dS)Nz)        [program:colons:are:bad]
        r)r4zprogram:colons:are:bad)r|rrr4r9r9r"r})rr�r�r4rtrrr�3test_processes_from_section_bad_program_name_colons�s

zFServerOptionsTests.test_processes_from_section_bad_program_name_colonscCsD|j�}td�}ddlm}|�}|j|�|jt|j|dd�dS)NzN        [program:foo]
        command = /bin/cat
        numprocs = 2
        r)r4zprogram:foo)r|rrr4r9r9r"r})rr�r�r4rtrrr�5test_processes_from_section_no_procnum_in_processname�s

zHServerOptionsTests.test_processes_from_section_no_procnum_in_processnamecCs�|j�}td�}ddlm}|�}|j|�y|j|dd�|jd�Wn8tk
r�}z|j|j	dj
d��WYdd}~XnXdS)Nz        [program:foo]
        r)r4zprogram:fooznothing raisedz6program section program:foo does not specify a command)r|rrr4r9r}r�r"rlrrn)rr�r�r4rtr�rrr�&test_processes_from_section_no_command�s
z9ServerOptionsTests.test_processes_from_section_no_commandcCsD|j�}td�}ddlm}|�}|j|�|jt|j|dd�dS)Nz^        [program:foo]
        command = /bin/cat
        process_name = %(not_there)s
        r)r4zprogram:foo)r|rrr4r9r9r"r})rr�r�r4rtrrr�?test_processes_from_section_missing_replacement_in_process_name�s

zRServerOptionsTests.test_processes_from_section_missing_replacement_in_process_namecCsD|j�}td�}ddlm}|�}|j|�|jt|j|dd�dS)Nz`        [program:foo]
        command = /bin/cat
        process_name = %(program_name)
        r)r4zprogram:foo)r|rrr4r9r9r"r})rr�r�r4rtrrr�:test_processes_from_section_bad_expression_in_process_name�s

zMServerOptionsTests.test_processes_from_section_bad_expression_in_process_namecCsD|j�}td�}ddlm}|�}|j|�|jt|j|dd�dS)Nz_        [program:foo]
        command = /bin/cat
        process_name = colons:are:bad
        r)r4zprogram:foo)r|rrr4r9r9r"r})rr�r�r4rtrrr�5test_processes_from_section_bad_chars_in_process_name	s

zHServerOptionsTests.test_processes_from_section_bad_chars_in_process_namecCsr|j�}td�}ddlm}|�}|j|�|j|dd�}|jt|�d�|d}|j|jd�|j|j	d�dS)Nz|        [program:foo]
        command = /bin/cat
        process_name = %(program_name)s
        stopasgroup = true
        r)r4zprogram:foorhr`T)
r|rrr4r9r}rNrOr�r�)rr�r�r4rtr�r�rrr�;test_processes_from_section_stopasgroup_implies_killasgroup	s
zNServerOptionsTests.test_processes_from_section_stopasgroup_implies_killasgroupcCsD|j�}td�}ddlm}|�}|j|�|jt|j|dd�dS)Nz�        [program:foo]
        command = /bin/cat
        process_name = %(program_name)s
        stopasgroup = true
        killasgroup = false
        r)r4zprogram:foo)r|rrr4r9r9r"r})rr�r�r4rtrrr�>test_processes_from_section_killasgroup_mismatch_w_stopasgroup 	s

zQServerOptionsTests.test_processes_from_section_killasgroup_mismatch_w_stopasgroupcCs�|j�}td�}ddlm}|�}|j|�y|j|dd�Wn4tk
rr}z|jdt|�k�WYdd}~XnX|j	d�dS)Nzh        [program:foo]
        command = /bin/cat
        environment = KEY1=val1,KEY2=val2,KEY3
        r)r4zprogram:fooz^Unexpected end of key/value pairs in value 'KEY1=val1,KEY2=val2,KEY3' in section 'program:foo'z9instance.processes_from_section should raise a ValueError)
r|rrr4r9r}r"rlr�r�)rr�r�r4rtr�rrr�=test_processes_from_section_unexpected_end_of_key_value_pairs/	s
zPServerOptionsTests.test_processes_from_section_unexpected_end_of_key_value_pairscCs�|j�}td�}tjdd���}yB|j|�|j�ddlm}|�}|j|j	�|j
|dd�Wn:tk
r�}z|j|j
dd|j	�WYdd}~XnX|jd�WdQRXdS)	Nz2        [program:foo]
        ;no command
        zw+)r�r)r4zprogram:foozZprogram section program:foo does not specify a command in section 'program:foo' (file: %r)znothing raised)r|rrqrrr�rrr4rsr,r}r"rNrr�)rr�r�rsr4rtr�rrr�=test_processes_from_section_shows_conf_filename_on_valueerrorD	s 
zPServerOptionsTests.test_processes_from_section_shows_conf_filename_on_valueerrorcCsj|j�}td�}ddlm}|�}t�|_|j|�|j|dd�|j|j	dd�|j|j	dd�dS)Nz�        [program:foo]
        command = /bin/foo
        stdout_logfile = AUTO
        stdout_logfile_maxbytes = 0
        stderr_logfile = AUTO
        stderr_logfile_maxbytes = 0
        r)r4zprogram:fooz�For [program:foo], AUTO logging used for stdout_logfile without rollover, set maxbytes > 0 to avoid filling up filesystem unintentionallyr`z�For [program:foo], AUTO logging used for stderr_logfile without rollover, set maxbytes > 0 to avoid filling up filesystem unintentionally)
r|rrr4r	rSr9r}rNr)rr�r�r4rtrrr�4test_processes_from_section_autolog_without_rolloverY	s
zGServerOptionsTests.test_processes_from_section_autolog_without_rollovercCs�td�}ddlm}|�}|j|�|j�}|j|�}|jt|�d�|d}|j|jd�|j|j	d�|jt|j
�d�dS)Nz�        [program:many]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1
        r)r4r`�manyrb)rrr4r9r|�process_groups_from_parserrNrOr,r�r�)rr�r4rtr��gconfigs�gconfigrrr�+test_homogeneous_process_groups_from_parserq	s

z>ServerOptionsTests.test_homogeneous_process_groups_from_parsercCstd�}ddlm}ddlm}|�}|j|�|j�}|j|�}|jt	|�d�|d}|j|j
d�|j|j|�|jt	|j�d�|d}|j|j
d	�|j|j
d�|j|j|�|jt	|j�d�|d}|j|j
d
�|j|j
d�|j|j|�|jt	|j�d�dS)Na        [eventlistener:dog]
        events=PROCESS_COMMUNICATION
        process_name = %(program_name)s_%(process_num)s
        command = /bin/dog
        numprocs = 2
        priority = 1

        [eventlistener:cat]
        events=PROCESS_COMMUNICATION
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 3

        [eventlistener:biz]
        events=PROCESS_COMMUNICATION
        process_name = %(program_name)s_%(process_num)s
        command = /bin/biz
        numprocs = 2
        r)r4)�default_handlerr�Zbizrbr`r��dogr8)rrr4�supervisor.dispatchersr�r9r|r�rNrOr,�result_handlerr�r�)rr�r4r�rtr�r��gconfig1rrr�%test_event_listener_pools_from_parser�	s.

z8ServerOptionsTests.test_event_listener_pools_from_parsercCsftd�}ddlm}ddlm}|j�}tj�ddddd	d
�|_|�}|j|_	|j
|�|j|�}|jt
|�d�|d}|j|jd�|j|jd�|j|j|�|jt
|j�d�|d
}|j|jd�|j|jd
�|j|j|�|jt
|j�d�|jd}	|j|	jd�|j|	jd�|j|	jd
�|jd
}
|j|
jd�|j|
jd�|j|
jd
�dS)Na�        [eventlistener:dog]
        events=PROCESS_COMMUNICATION
        process_name = %(ENV_EL1_PROCNAME)s_%(program_name)s_%(process_num)s
        command = %(ENV_EL1_COMMAND)s
        numprocs = %(ENV_EL1_NUMPROCS)s
        priority = %(ENV_EL1_PRIORITY)s

        [eventlistener:cat]
        events=PROCESS_COMMUNICATION
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 3

        r)r4)r�r�Zmyeventlistenerz/bin/dogrR�1)r�r�ZENV_EL1_PROCNAMEZENV_EL1_COMMANDZENV_EL1_NUMPROCSZENV_EL1_PRIORITYrbr�r`r�r�Zmyeventlistener_dog_0Zmyeventlistener_dog_1r8)rrr4r�r�r|rqr�r�r�r9r�rNrOr,r�r�r�r�)rr�r4r�r�rtr�Zgconfig0r�Zdog0Zdog1rrr�Atest_event_listener_pools_from_parser_with_environment_expansions�	sD




zTServerOptionsTests.test_event_listener_pools_from_parser_with_environment_expansionscCs~td�}ddlm}|�}|j|�|j�}y|j|�|jd�Wn4tk
rx}z|j|j	dd�WYdd}~XnXdS)Nzl        [eventlistener:dog]
        events=EVENT
        command = /bin/dog
        buffer_size = 0
        r)r4znothing raisedz8[eventlistener:dog] section sets invalid buffer_size (0))
rrr4r9r|r�r�r"rNr)rr�r4rtr�r�rrr�3test_event_listener_pool_disallows_buffer_size_zero�	s

zFServerOptionsTests.test_event_listener_pool_disallows_buffer_size_zerocCs~td�}ddlm}|�}|j|�|j�}y|j|�|jd�Wn4tk
rx}z|j|j	dd�WYdd}~XnXdS)Nz�        [eventlistener:dog]
        events=PROCESS_COMMUNICATION
        command = /bin/dog
        redirect_stderr = True
        r)r4znothing raisedz�[eventlistener:dog] section sets redirect_stderr=true but this is not allowed because it will interfere with the eventlistener protocol)
rrr4r9r|r�r�r"rNr)rr�r4rtr�r�rrr�2test_event_listener_pool_disallows_redirect_stderr�	s

zEServerOptionsTests.test_event_listener_pool_disallows_redirect_stderrcCsltd�}ddlm}ddlm}|�}|j|�|j�}|j|�}|jt	|�d�|d}|j|j
|�dS)Nz�        [eventlistener:dog]
        events=PROCESS_COMMUNICATION
        command = /bin/dog
        result_handler = supervisor.tests.base:dummy_handler
        r)r4)�
dummy_handlerr`)rrr4�supervisor.tests.baser�r9r|r�rNrOr�)rr�r4r�rtr�r�r�rrr�2test_event_listener_pool_with_event_result_handler
s

zEServerOptionsTests.test_event_listener_pool_with_event_result_handlercCs~td�}ddlm}|�}|j|�|j�}y|j|�|jd�Wn4tk
rx}z|j|j	dd�WYdd}~XnXdS)Nz�        [eventlistener:cat]
        events=PROCESS_COMMUNICATION
        command = /bin/cat
        result_handler = supervisor.tests.base:nonexistent
        r)r4znothing raisedzOsupervisor.tests.base:nonexistent cannot be resolved within [eventlistener:cat])
rrr4r9r|r�r�r"rNr)rr�r4rtr�r�rrr�4test_event_listener_pool_result_handler_unimportable
s

zGServerOptionsTests.test_event_listener_pool_result_handler_unimportablecCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [eventlistener:dog]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/dog
        numprocs = 2
        priority = 1
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�%test_event_listener_pool_noeventsline0
s
z8ServerOptionsTests.test_event_listener_pool_noeventslinecCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [eventlistener:dog]
        events=PROCESS_COMMUNICATION,THIS_EVENT_TYPE_DOESNT_EXIST
        process_name = %(program_name)s_%(process_num)s
        command = /bin/dog
        numprocs = 2
        priority = 1
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�*test_event_listener_pool_unknown_eventtype>
s
z=ServerOptionsTests.test_event_listener_pool_unknown_eventtypecCs`ddlm}ddlm}td�}ddlm}|�}|j|�|j�}t�}ddtj	tj
f|_t�}ddtj
f|_td|�td|�td|�d	d
����}	|	||�}
tj	tj
f}|j
t|
�d�|
d}|j
|j|�|j
|jd�|j
|jd
�|j
|jjd�|j
||jj��|j
d|jj��|j
d|jj��|j
t|j�d�|jd}
|j
|
j|�|
d
}|j
|jd�|j
|jd�|j
|jjd�|j
||jj��|j
d|jj��|j
t|j�d�|
d}|j
|jd�|j
|jjd�|j
t|j�d
�|
d}|j
|jd�|j
|jjd�|j
d|jj��|j
d|jj��|j
t|j�d
�dS)Nr)�FastCGIGroupConfig)�FastCGIProcessConfiga�        [fcgi-program:foo]
        socket = unix:///tmp/%(program_name)s.sock
        socket_owner = testuser:testgroup
        socket_mode = 0666
        socket_backlog = 32676
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1

        [fcgi-program:bar]
        socket = unix:///tmp/%(program_name)s.sock
        process_name = %(program_name)s_%(process_num)s
        command = /bin/bar
        user = testuser
        numprocs = 3

        [fcgi-program:flub]
        socket = unix:///tmp/%(program_name)s.sock
        command = /bin/flub

        [fcgi-program:cub]
        socket = tcp://localhost:6000
        command = /bin/cub
        )r4zpwd.getpwuidzpwd.getpwnamzgrp.getgrnamcSs
|j|�S)N)r�)r�rtrrr�get_process_groupsv
szMServerOptionsTests.test_fcgi_programs_from_parser.<locals>.get_process_groupsrLrgr`zunix:///tmp/foo.socki�i�rbrhi�zunix:///tmp/bar.socki�r�Zcubztcp://localhost:6000Zflubzunix:///tmp/flub.sock)rr�r�rr4r9r|rrr�r��return_valuerrNrO�	__class__r,r��
socket_config�url�	get_owner�get_mode�get_backlogr�)rr�r�r�r4rtr��pwd_mock�grp_mockr�r��	exp_owner�	gconf_foo�pconfig_fooZ	gconf_barZ	gconf_cubZ
gconf_flubrrr�test_fcgi_programs_from_parserM
sd






z1ServerOptionsTests.test_fcgi_programs_from_parsercCs�ddlm}ddlm}td�}ddlm}|j�}dddd	d
ddd
ddd�
|_|�}|j|_|j|�t	�}ddt
jt
jf|_
t	�}ddt
jf|_
td|�td|�td|�dd����}	|	||�}
t
jt
jf}|jt|
�d�|
d}|j|j|�|j|jd�|j|jd�|j|jjd�|j||jj��|jd|jj��|jd|jj��|jt|j�d�|jd}
|j|
j|�|j|
jd�dS)Nr)r�)r�a�        [fcgi-program:foo]
        socket = unix:///tmp/%(program_name)s%(ENV_FOO_SOCKET_EXT)s
        socket_owner = %(ENV_FOO_SOCKET_USER)s:testgroup
        socket_mode = %(ENV_FOO_SOCKET_MODE)s
        socket_backlog = %(ENV_FOO_SOCKET_BACKLOG)s
        process_name = %(ENV_FOO_PROCESS_PREFIX)s_%(program_name)s_%(process_num)s
        command = /bin/foo --arg1=%(ENV_FOO_COMMAND_ARG1)s
        numprocs = %(ENV_FOO_NUMPROCS)s
        priority = %(ENV_FOO_PRIORITY)s
        )r4z/tmpr�z.usockZtestuserZ0666Z32676zfcgi-rhrRr�)
r�r�ZENV_FOO_SOCKET_EXTZENV_FOO_SOCKET_USERZENV_FOO_SOCKET_MODEZENV_FOO_SOCKET_BACKLOGZENV_FOO_PROCESS_PREFIXZENV_FOO_COMMAND_ARG1ZENV_FOO_NUMPROCSZENV_FOO_PRIORITYzpwd.getpwuidzpwd.getpwnamzgrp.getgrnamcSs
|j|�S)N)r�)r�rtrrrr��
sziServerOptionsTests.test_fcgi_programs_from_parser_with_environment_expansions.<locals>.get_process_groupsr`rgzunix:///tmp/foo.usocki�i�rbz/bin/foo --arg1=bar)rr�r�rr4r|r�r�r9rrr�r�r�rrNrOr�r,r�r�r�r�r�r�r�r�)rr�r�r�r4r�rtr�r�r�r�r�r�r�rrr�:test_fcgi_programs_from_parser_with_environment_expansions�
sT





zMServerOptionsTests.test_fcgi_programs_from_parser_with_environment_expansionscCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [fcgi-program:foo]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�test_fcgi_program_no_socket�
s
z.ServerOptionsTests.test_fcgi_program_no_socketcCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [fcgi-program:foo]
        socket=junk://blah
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�)test_fcgi_program_unknown_socket_protocol�
s
z<ServerOptionsTests.test_fcgi_program_unknown_socket_protocolcCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [fcgi-program:foo]
        socket=unix://relative/path
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�$test_fcgi_program_rel_unix_sock_paths
z7ServerOptionsTests.test_fcgi_program_rel_unix_sock_pathcCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [fcgi-program:foo]
        socket=tcp://missingport
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�%test_fcgi_program_bad_tcp_sock_formats
z8ServerOptionsTests.test_fcgi_program_bad_tcp_sock_formatcCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [fcgi-program:foo]
        socket=unix:///tmp/%(process_num)s.sock
        process_name = %(program_name)s_%(process_num)s
        command = /bin/foo
        numprocs = 2
        priority = 1
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�(test_fcgi_program_bad_expansion_proc_num!s
z;ServerOptionsTests.test_fcgi_program_bad_expansion_proc_numcCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [fcgi-program:foo]
        socket=tcp://localhost:8000
        socket_owner=nobody:nobody
        command = /bin/foo
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�*test_fcgi_program_socket_owner_set_for_tcp0s
z=ServerOptionsTests.test_fcgi_program_socket_owner_set_for_tcpcCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz        [fcgi-program:foo]
        socket = tcp://localhost:8000
        socket_mode = 0777
        command = /bin/foo
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�)test_fcgi_program_socket_mode_set_for_tcp=s
z<ServerOptionsTests.test_fcgi_program_socket_mode_set_for_tcpcCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [fcgi-program:foo]
        socket = unix:///tmp/foo.sock
        socket_owner = sometotaljunkuserthatshouldnobethere
        command = /bin/foo
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�"test_fcgi_program_bad_socket_ownerJs
z5ServerOptionsTests.test_fcgi_program_bad_socket_ownercCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz        [fcgi-program:foo]
        socket = unix:///tmp/foo.sock
        socket_mode = junk
        command = /bin/foo
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�!test_fcgi_program_bad_socket_modeWs
z4ServerOptionsTests.test_fcgi_program_bad_socket_modecCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [fcgi-program:foo]
        socket = unix:///tmp/foo.sock
        socket_backlog = -1
        command = /bin/foo
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�$test_fcgi_program_bad_socket_backlogds
z7ServerOptionsTests.test_fcgi_program_bad_socket_backlogcCs�td�}ddlm}|�}|j|�|j�}|j|�}|jt|�d�|d}|j|jd�|j|j	d�|jt|j
�d�dS)Nz�        [program:one]
        command = /bin/cat

        [program:two]
        command = /bin/cat

        [group:thegroup]
        programs = one,two
        priority = 5
        r)r4r`�thegroupr�rb)rrr4r9r|r�rNrOr,r�r�)rr�r4rtr�r�r�rrr�-test_heterogeneous_process_groups_from_parserqs


[email protected]_heterogeneous_process_groups_from_parsercCs�td�}ddlm}|�}|j|�|j�}|j|�}|jt|�d�|d}|j|jd�|j|j	d�|jt|j
�d�|d}|j|jd�|j|j	d�|jt|j
�d�dS)	NaJ        [program:one]
        command = /bin/cat

        [program:two]
        command = /bin/cat

        [program:many]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1

        [group:thegroup]
        programs = one,two
        priority = 5
        r)r4rbr�r`r�r�)rrr4r9r|r�rNrOr,r�r�)rr�r4rtr�r�Z
manyconfigr�rrr�&test_mixed_process_groups_from_parser1�s 

z9ServerOptionsTests.test_mixed_process_groups_from_parser1cCs�td�}ddlm}|�}|j|�|j�}|j|�}|jt|�d�|d}|j|jd�|j|j	d�|jt|j
�d�dS)NaP        [program:one]
        command = /bin/cat

        [program:two]
        command = /bin/cat

        [program:many]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1

        [group:thegroup]
        programs = one,two, many
        priority = 5
        r)r4r`r�r�rL)rrr4r9r|r�rNrOr,r�r�)rr�r4rtr�r�r�rrr�&test_mixed_process_groups_from_parser2�s

z9ServerOptionsTests.test_mixed_process_groups_from_parser2cCs�td�}ddlm}|�}|j|�|j�}|j|�}|jt|�d�|d}|j|jd�|j|j	d�|jt|j
�d�dS)Na�        [program:one]
        command = /bin/cat

        [fcgi-program:two]
        command = /bin/cat

        [program:many]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1

        [fcgi-program:more]
        process_name = %(program_name)s_%(process_num)s
        command = /bin/cat
        numprocs = 2
        priority = 1

        [group:thegroup]
        programs = one,two,many,more
        priority = 5
        r)r4r`r�r�rK)rrr4r9r|r�rNrOr,r�r�)rr�r4rtr�r�r�rrr�&test_mixed_process_groups_from_parser3�s

z9ServerOptionsTests.test_mixed_process_groups_from_parser3cCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nz�        [program:one]
        command = /bin/cat

        [fcgi-program:one]
        command = /bin/cat

        [group:thegroup]
        programs = oner)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�-test_ambiguous_process_in_heterogeneous_group�s

[email protected]_ambiguous_process_in_heterogeneous_groupcCs@td�}ddlm}|�}|j|�|j�}|jt|j|�dS)Nzj        [program:one]
        command = /bin/cat

        [group:foo]
        programs = notthere
        r)r4)rrr4r9r|r9r"r�)rr�r4rtr�rrr�+test_unknown_program_in_heterogeneous_group�s

z>ServerOptionsTests.test_unknown_program_in_heterogeneous_groupcCs�tdt�}ddlm}|�}|j|�|j�}|j|dd�}|jt|�d�|d}|j|dd�|j|dt	j
t�|j|dd	d
d��dS)Nzv        [rpcinterface:dummy]
        supervisor.rpcinterface_factory = %s
        foo = bar
        baz = qux
        r)r4zsupervisor.rpcinterface_factoryz
rpcinterface:r`�dummyrbrhZqux)rgri)rrrr4r9r|�get_pluginsrNrO�sys�modules)rr�r4rtr��	factories�factoryrrr�test_rpcinterfaces_from_parser
s

z1ServerOptionsTests.test_rpcinterfaces_from_parsercCs�td�}ddlm}|j�}|�}tdd�|_|j|�|j|dd�}|jt	|�d�|d}|j|dd	�|j|dt
jt�|j|d
ddi�dS)Nzq        [rpcinterface:dummy]
        supervisor.rpcinterface_factory = %(factory)s
        foo = %(pet)s
        r)r4r�)r��petzsupervisor.rpcinterface_factoryz
rpcinterface:r`r�rbrg)rrr4r|rr�r9r�rNrOr�r�)rr�r4r�rtr�r�rrr�1test_rpcinterfaces_from_parser_factory_expansions!s
zDServerOptionsTests.test_rpcinterfaces_from_parser_factory_expansionscCs�td�}ddlm}|�}|j|�|j�}y|j|dd�|jd�Wn4tk
r|}z|j|j	dd�WYdd}~XnXdS)Nz]        [rpcinterface:dummy]
        # note: no supervisor.rpcinterface_factory here
        r)r4zsupervisor.rpcinterface_factoryz
rpcinterface:znothing raisedzOsection [rpcinterface:dummy] does not specify a supervisor.rpcinterface_factory)
rrr4r9r|r�r�r"rNr)rr�r4rtr�r�rrr�.test_rpcinterfaces_from_parser_factory_missing5s
zAServerOptionsTests.test_rpcinterfaces_from_parser_factory_missingcCs�td�}ddlm}|�}|j|�|j�}y|j|dd�|jd�Wn4tk
r|}z|j|j	dd�WYdd}~XnXdS)Nz[        [rpcinterface:dummy]
        supervisor.rpcinterface_factory = nonexistent
        r)r4zsupervisor.rpcinterface_factoryz
rpcinterface:znothing raisedz:nonexistent cannot be resolved within [rpcinterface:dummy])
rrr4r9r|r�r�r"rNr)rr�r4rtr�r�rrr�5test_rpcinterfaces_from_parser_factory_not_importableGs
zHServerOptionsTests.test_rpcinterfaces_from_parser_factory_not_importablec	
Cs�tj�}z�|j�}||_d}||_|jd|d�}|d}|d}t|d�}t|d�}|j�|jt	j
j|��|jt	j
j|��|jt	j
j|��|j�|j�Wdt
j|dd�XdS)	Nr�rgrez.1z.2r�T)r�)rqr�r|r�r�Zget_autochildlog_namer��clear_autochildlogdirrrUr�rKr^r�r�)	rZdnr�ZsidZlogfn�first�second�f1�f2rrr�test_clear_autochildlogdirYs$

z-ServerOptionsTests.test_clear_autochildlogdircCs4|j�}d|_t�|_|j�|j|jjdg�dS)Nz!/tmp/this/cant/possibly/existjjjjzCould not clear childlog dir)r|r�r	rSr�rNro)rr�rrr�*test_clear_autochildlogdir_listdir_oserrorns
z=ServerOptionsTests.test_clear_autochildlogdir_listdir_oserrorcCs�tj�}|j�}||_|j}tjj|d|�}t|d��}|j	d�WdQRXdd�}||_
t�|_|j
�|j|jjd|g�dS)Nzcat-stdout---%s-ayWAp9.logr��logcWsttj��dS)N)rNr��ENOENT)rrrr�
raise_oserror}szSServerOptionsTests.test_clear_autochildlogdir_unlink_oserror.<locals>.raise_oserrorzFailed to clean up '%s')rqr�r|r�r�rUr�r�r�r��remover	rSr�rNro)rr�r�Zidentrrsrrrr�)test_clear_autochildlogdir_unlink_oserrorus
z<ServerOptionsTests.test_clear_autochildlogdir_unlink_oserrorcsht�}|j�}dd�}||_g��fdd�}||_|j|�|jt��d�d}|j�dj|��dS)NcSstjtj��dS)N)r�rZr�Z
EADDRINUSE)r�rrr�raise_eaddrinuse�szhServerOptionsTests.test_openhttpservers_reports_friendly_usage_when_eaddrinuse.<locals>.raise_eaddrinusecs�j|�dS)N)r\)r.)r/rrr0�szdServerOptionsTests.test_openhttpservers_reports_friendly_usage_when_eaddrinuse.<locals>.record_usager`z$Another program is already listeningr)	rr|�make_http_serversr1�openhttpserversrNrOrlrn)rr�r�rr0r�r)r/r�;test_openhttpservers_reports_friendly_usage_when_eaddrinuse�s
zNServerOptionsTests.test_openhttpservers_reports_friendly_usage_when_eaddrinusecsjt�}|j�}dd�}||_g��fdd�}||_|j|�|jt��d�dtj}|j�d|�dS)NcSstjtj��dS)N)r�rZr��EPERM)r�rrrr�szbServerOptionsTests.test_openhttpservers_reports_socket_error_with_errno.<locals>.make_http_serverscs�j|�dS)N)r\)r.)r/rrr0�sz]ServerOptionsTests.test_openhttpservers_reports_socket_error_with_errno.<locals>.record_usager`zBCannot open an HTTP server: socket.error reported errno.EPERM (%d)r)	rr|rr1rrNrOr�r	)rr�r�rr0r�r)r/r�4test_openhttpservers_reports_socket_error_with_errno�s
zGServerOptionsTests.test_openhttpservers_reports_socket_error_with_errnocsdt�}|j�}dd�}||_g��fdd�}||_|j|�|jt��d�d}|j�d|�dS)NcSstjd��dS)Nzuh oh)r�rZ)r�rrrr�sz^ServerOptionsTests.test_openhttpservers_reports_other_socket_errors.<locals>.make_http_serverscs�j|�dS)N)r\)r.)r/rrr0�szYServerOptionsTests.test_openhttpservers_reports_other_socket_errors.<locals>.record_usager`z7Cannot open an HTTP server: socket.error reported uh ohr)rr|rr1rrNrO)rr�r�rr0r�r)r/r�0test_openhttpservers_reports_other_socket_errors�s
zCServerOptionsTests.test_openhttpservers_reports_other_socket_errorscsdt�}|j�}dd�}||_g��fdd�}||_|j|�|jt��d�d}|j�d|�dS)NcSstd��dS)Nznot prefixed with help)r")r�rrrr�szWServerOptionsTests.test_openhttpservers_reports_value_errors.<locals>.make_http_serverscs�j|�dS)N)r\)r.)r/rrr0�szRServerOptionsTests.test_openhttpservers_reports_value_errors.<locals>.record_usager`znot prefixed with helpr)rr|rr1rrNrO)rr�r�rr0r�r)r/r�)test_openhttpservers_reports_value_errors�s
z<ServerOptionsTests.test_openhttpservers_reports_value_errorscCs0t�}|j�}dd�}||_|jt|j|�dS)NcSst�dS)N)�
OverflowError)r�rrrr�szgServerOptionsTests.test_openhttpservers_does_not_catch_other_exception_types.<locals>.make_http_servers)rr|rr9r
r)rr�r�rrrr�9test_openhttpservers_does_not_catch_other_exception_types�szLServerOptionsTests.test_openhttpservers_does_not_catch_other_exception_typescCs"|j�}|jd�}|j|d�dS)NzNo user specified to setuid to!)r|�drop_privilegesrN)rr�rorrr�test_drop_privileges_user_none�s
z1ServerOptionsTests.test_drop_privileges_user_nonezpwd.getpwuidrgN��")r�z	os.getuidcCs&|j�}|jtj��}|j|d�dS)N)r|rrU�getuidrN)rr�rorrr�&test_drop_privileges_nonroot_same_user�sz9ServerOptionsTests.test_drop_privileges_nonroot_same_user�7cCs"|j�}|jd�}|j|d�dS)NrRz$Can't drop privilege as nonroot user)r|rrN)rr�rorrr�+test_drop_privileges_nonroot_different_user�s
z>ServerOptionsTests.test_drop_privileges_nonroot_different_usercCs>|j�}dd�|_t�|_|j�|jjj�|jjj�dS)NcSsdS)Nrrrrrr_�szYServerOptionsTests.test_daemonize_notifies_poller_before_and_after_fork.<locals>.<lambda>)r|Z
_daemonizerrYZ	daemonizeZbefore_daemonizeZassert_called_once_withZafter_daemonize)rr�rrr�4test_daemonize_notifies_poller_before_and_after_fork�s
zGServerOptionsTests.test_daemonize_notifies_poller_before_and_after_fork)�rrrrr|r�r�r�r�r�rrrr�r�rr	r�r
rrrrrrrr!r%r(r+r-r2r3r;r<r=r>r?r@rArBrCrDrErLrOrQrVrWrXr[rarbrcrkrlrmrnrprvrwryrrrNrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrrrrrrrrrrr��s
D	
	##
	


	

2

'(%$



.4Y@




#$

"$"$r�c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�ProcessConfigTestscCsddlm}|S)Nr)�
ProcessConfig)rr)rrrrrr�sz"ProcessConfigTests._getTargetClasscOsHi}xdD]}|||<q
Wxd D]}d||<q W|j|�|j�||�S)!Nr,r�r�r�r�r�r�r�r�r�r�r~rr�r��stderr_capture_maxbytes�stderr_events_enabledr�r�r�r�r�r^r�r�r�r��stderr_logfile_backups�stderr_logfile_maxbytesr�)r,r�r�r�r�r�r�r�r�r�r�r~rr�r�rrr�r�r�r�r�r^r�r�)r�r�rr)r$r)r�arg�kw�defaultsr,rrrr|�s"
zProcessConfigTests._makeOnecCs,t�}|j|dd�}|j|j�|j��dS)N)r�)r
r|rN�get_path)rr6r�rrr�.test_get_path_env_is_None_delegates_to_options
szAProcessConfigTests.test_get_path_env_is_None_delegates_to_optionscCs0t�}|j|ddid�}|j|j�|j��dS)Nr�r�)r�)r
r|rNr!)rr6r�rrr�8test_get_path_env_dict_with_no_PATH_delegates_to_options
szKProcessConfigTests.test_get_path_env_dict_with_no_PATH_delegates_to_optionscCsFt�}|j|ddid�}|j|j�|j��|j|j�dddg�dS)Nr�z/a:/b:/c)r�z/az/bz/c)r
r|ZassertNotEqualr!rN)rr6r�rrr�(test_get_path_env_dict_with_PATH_uses_it
sz;ProcessConfigTests.test_get_path_env_dict_with_PATH_uses_itcCsTt�}|j|�}ddlm}||_||_|j�|j|j|j�|j|j|j�dS)Nr)r�)	r
r|r3r�r�r�Zcreate_autochildlogsrNZ
tempfile_name)rr6r�r�rrr�test_create_autochildlogs
s
z,ProcessConfigTests.test_create_autochildlogscCsDt�}|j|�}|j�}ddlm}|j|j|�|j|jd�dS)Nr)�
Subprocess)r
r|�make_process�supervisor.processr&rNr�r�)rr6r��processr&rrr�test_make_process)
s
z$ProcessConfigTests.test_make_processcCsFt�}|j|�}|jd�}ddlm}|j|j|�|j|jd�dS)NrBr)r&)r
r|r'r(r&rNr�r�)rr6r�r)r&rrr�test_make_process_with_group1
s

z/ProcessConfigTests.test_make_process_with_groupc
Cs�t�}|j|�}tj���}tj���}|j|_|j|_d|_t|�}|j	|�\}}|j
|djd�ddlm
}|j
|dj|�|j
|dd�|j
|djd�ddlm}	|j
|dj|	�|j
|dd�WdQRXWdQRXdS)	NFr�rer)�ProcessCommunicationStdoutEventr\rd)�ProcessCommunicationStderrEvent)r
r|rqrrr,r�r�r�r
�make_dispatchersrN�channel�supervisor.eventsr,�
event_typer-)
rr6r�r�r��process1�dispatchersrjr,r-rrr�+test_make_dispatchers_stderr_not_redirected9
s&


z>ProcessConfigTests.test_make_dispatchers_stderr_not_redirectedc
Csxt�}|j|�}tj��V}|j|_t|�}|j|�\}}|j|dj	d�|j|dd�|j|dd�WdQRXdS)Nr�rerd)
r
r|rqrrr,r�r
r.rNr/)rr6r�r�r2r3rjrrr�'test_make_dispatchers_stderr_redirectedN
s

z:ProcessConfigTests.test_make_dispatchers_stderr_redirectedN)
rrrrr|r"r#r$r%r*r+r4r5rrrrr�s
rc@s$eZdZdd�Zdd�Zdd�ZdS)�EventListenerConfigTestscCsddlm}|S)Nr)�EventListenerConfig)rr7)rr7rrrrZ
sz(EventListenerConfigTests._getTargetClasscOsHi}xdD]}|||<q
Wxd D]}d||<q W|j|�|j�||�S)!Nr,r�r�r�r�r�r�r�r�r�r�r~rr�r�rrr�r�r�r�r�r^r�r�r�r�rrr�)r,r�r�r�r�r�r�r�r�r�r�r~rr�r�rrr�r�r�r�r�r^r�r�)r�r�rr)r$r)rrrr r,rrrr|^
s"
z!EventListenerConfigTests._makeOnec
Cst�}|j|�}tj���}tj���}|j|_|j|_d|_t|�}|j	|�\}}|j
|djd�|j
|djd�|j
|djd�ddl
m}|j
|djj|j�|j
|dd�|j
|djd	�dd
lm}	|j
|dj|	�|j
|d	d�WdQRXWdQRXdS)NFrLrer�rer)�EventListenerStatesr\rd)r-)r
r|rqrrr,r�r�r�r
r.rNr/rZZsupervisor.statesr8r)Zlistener_stateZACKNOWLEDGEDr0r-r1)
rr6r�r�r�r2r3rjr8r-rrr�test_make_dispatchersq
s*


z.EventListenerConfigTests.test_make_dispatchersN)rrrrr|r9rrrrr6Y
sr6c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�FastCGIProcessConfigTestscCsddlm}|S)Nr)r�)rr�)rr�rrrr�
sz)FastCGIProcessConfigTests._getTargetClasscOsHi}xdD]}|||<q
Wxd D]}d||<q W|j|�|j�||�S)!Nr,r�r�r�r�r�r�r�r�r�r�r~rr�r�rrr�r�r�r�r�r^r�r�r�r�rrr�)r,r�r�r�r�r�r�r�r�r�r�r~rr�r�rrr�r�r�r�r�r^r�r�)r�r�rr)r$r)rrrr r,rrrr|�
s"
z"FastCGIProcessConfigTests._makeOnecCs"t�}|j|�}|jt|j�dS)N)r
r|r9�NotImplementedErrorr')rr6r�rrrr*�
s
z+FastCGIProcessConfigTests.test_make_processcCsFt�}|j|�}|jd�}ddlm}|j|j|�|j|jd�dS)NrBr)�FastCGISubprocess)r
r|r'r(r<rNr�r�)rr6r�r)r<rrrr+�
s

z6FastCGIProcessConfigTests.test_make_process_with_groupc
Cst�}|j|�}tj���}tj���}|j|_|j|_d|_t|�}|j	|�\}}|j
|djd�|j
|djd�|j
|djd�ddl
m}|j
|dj|�|j
|dd�|j
|d	jd
�ddl
m}	|j
|d	j|	�|j
|d
d	�WdQRXWdQRXdS)NFrLreTr�rer)r,r\rd)r-)r
r|rqrrr,r�r�r�r
r.rNr/rZr0r,r1r-)
rr6r�r�r�r2r3rjr,r-rrrr9�
s*


z/FastCGIProcessConfigTests.test_make_dispatchersN)rrrrr|r*r+r9rrrrr:�
s
r:c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ProcessGroupConfigTestscCsddlm}|S)Nr)�ProcessGroupConfig)rr>)rr>rrrr�
sz'ProcessGroupConfigTests._getTargetClasscCs|j�||||�S)N)r)rr6r,r�r�rrrr|�
sz ProcessGroupConfigTests._makeOnecCsRt�}|j|ddg�}|j|j|�|j|jd�|j|jd�|j|jg�dS)N�whateveri�)r
r|rNr6r,r�r�)rr6r�rrr�	test_ctor�
sz!ProcessGroupConfigTests.test_ctorcCsBt�}t|dd�g}|j|dd|�}|j�|j|djd�dS)Nr2z
/bin/process1r?i�rT)r
rr|�after_setuidrN�autochildlogs_created)rr6r�r�rrr�test_after_setuid�
s
z)ProcessGroupConfigTests.test_after_setuidcCsJt�}t|dd�g}|j|dd|�}|j�}ddlm}|j|j|�dS)Nr2z
/bin/process1r?i�r)�ProcessGroup)r
rr|�
make_groupr(rDrNr�)rr6r�r�r�rDrrr�test_make_group�
sz'ProcessGroupConfigTests.test_make_groupN)rrrrr|r@rCrFrrrrr=�
s
r=c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�EventListenerPoolConfigTestscCsddlm}|S)Nr)�EventListenerPoolConfig)rrH)rrHrrrr�
sz,EventListenerPoolConfigTests._getTargetClasscCs|j�|||||||�S)N)r)rr6r,r�r��buffer_sizeZpool_eventsr�rrrr|�
sz%EventListenerPoolConfigTests._makeOnecCsHt�}t|dd�g}|j|dd|dgd�}|j�|j|djd�dS)Nr2z
/bin/process1r,i�r`rT)r
rr|rArNrB)rr6r�r�rrrrC�
s
z.EventListenerPoolConfigTests.test_after_setuidcCsPt�}t|dd�g}|j|dd|dgd�}|j�}ddlm}|j|j|�dS)Nr2z
/bin/process1r,i�r`r)�EventListenerPool)r
rr|rEr(rJrNr�)rr6r�r�r�rJrrrrF�
sz,EventListenerPoolConfigTests.test_make_groupN)rrrrr|rCrFrrrrrG�
srGc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�FastCGIGroupConfigTestscCsddlm}|S)Nr)r�)rr�)rr�rrrr�
sz'FastCGIGroupConfigTests._getTargetClasscOs|j�||�S)N)r)rrrrrrr|sz FastCGIGroupConfigTests._makeOnecCsjt�}td�}|j|ddg|�}|j|j|�|j|jd�|j|jd�|j|jg�|j|j|�dS)NrKr?i�)	r
rr|rNr6r,r�r�r�)rr6�sock_configr�rrrr@sz!FastCGIGroupConfigTests.test_ctorcCsZt�}td�}|j|ddg|�}td�}|j|ddg|�}|j||k�|j||k�dS)NrKr?i�)r
rr|rlr)rr6�sock_config1�	instance1�sock_config2�	instance2rrr�test_same_sockets_are_equalsz3FastCGIGroupConfigTests.test_same_sockets_are_equalcCsZt�}td�}|j|ddg|�}td�}|j|ddg|�}|j||k�|j||k�dS)NrKr?i�r\)r
rr|rlr)rr6rMrNrOrPrrr�test_diff_sockets_are_not_equalsz7FastCGIGroupConfigTests.test_diff_sockets_are_not_equalcCsFt�}td�}|j|ddg|�}|j�}ddlm}|j|j|�dS)NrKr,i�r)�FastCGIProcessGroup)r
rr|rEr(rSrNr�)rr6rLr�r�rSrrrrF&sz'FastCGIGroupConfigTests.test_make_groupN)	rrrrr|r@rQrRrFrrrrrK�
s
rKc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�SignalReceiverTestscCs&ddlm}|�}|j|j�d�dS)Nr)�SignalReceiver)rrUrNr$)rrU�srrrr�test_returns_None_initially/sz/SignalReceiverTests.test_returns_None_initiallycCsfddlm}|�}|jtjd�|jtjd�|j|j�tj�|j|j�tj�|j|j�d�dS)Nr)rU�frame)rrUr"r�r�r#rNr$)rrUrVrrr�&test_returns_signals_in_order_received4sz:SignalReceiverTests.test_returns_signals_in_order_receivedcCsTddlm}|�}|jtjd�|jtjd�|j|j�tj�|j|j�d�dS)Nr)rUrX)rrUr"r�r�rNr$)rrUrVrrr�%test_does_not_queue_duplicate_signals=sz9SignalReceiverTests.test_does_not_queue_duplicate_signalscCsvddlm}|�}|jtjd�|j|j�tj�|j|j�d�|jtjd�|j|j�tj�|j|j�d�dS)Nr)rUrX)rrUr"r�r�rNr$r#)rrUrVrrr�%test_queues_again_after_being_emptiedEsz9SignalReceiverTests.test_queues_again_after_being_emptiedN)rrrrWrYrZr[rrrrrT.s	rTc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�UnhosedConfigParserTestscCsddlm}|S)Nr)r4)rr4)rr4rrrrPsz(UnhosedConfigParserTests._getTargetClasscOs|j�||�S)N)r)rrrrrrr|Tsz!UnhosedConfigParserTests._makeOnecCs6|j�}|jd�ddlm}|j|j|jdd�dS)Nz[supervisord]
r)�ConfigParserr��missing)r|r9rr]r9Z
NoOptionError�saneget)rrr]rrr�test_saneget_no_defaultWs

z0UnhosedConfigParserTests.test_saneget_no_defaultcCs2|j�}|jd�|jdddd�}|j|d�dS)Nz[supervisord]
r�r^rB)r+)r|r9r_rN)rr�resultrrr�test_saneget_with_default^s
z2UnhosedConfigParserTests.test_saneget_with_defaultcCs<|j�}ddi|_|jd�|jdddd�}|j|d�dS)Nr�r�z[supervisord]
r�rgz%(pet)s)r+)r|r�r9r_rN)rrrarrr�$test_saneget_with_default_and_expandds


z=UnhosedConfigParserTests.test_saneget_with_default_and_expandcCs>|j�}ddi|_|jd�|jddddd�}|j|d�dS)	Nr�r�z[supervisord]
r�rgz%(pet)sF)r+�	do_expand)r|r�r9r_rN)rrrarrr�#test_saneget_with_default_no_expandks


z<UnhosedConfigParserTests.test_saneget_with_default_no_expandcCs2|j�}|jd�|jdddd�}|j|d�dS)Nz[supervisord]
foo=%(pet)s
r�rgF)rdz%(pet)s)r|r9r_rN)rrrarrr�!test_saneget_no_default_no_expandss
z:UnhosedConfigParserTests.test_saneget_no_default_no_expandcCs8|j�}ddi|_|jd�|jdd�}|j|d�dS)Nr�r�z[supervisord]
foo=%(pet)s
r�rg)r|r�r9r_rN)rrrarrr�(test_saneget_expands_instance_expansionsys


zAUnhosedConfigParserTests.test_saneget_expands_instance_expansionscCs@|j�}ddi|_|jd�|jddddid�}|j|d�dS)Nr�r�z[supervisord]
foo=%(pet)s
r�rgr�)r�)r|r�r9r_rN)rrrarrr�#test_saneget_expands_arg_expansions�s

z<UnhosedConfigParserTests.test_saneget_expands_arg_expansionscCs.|j�}|jd|j�|j|jd�d�dS)Nz
[%s]
foo=bar
rgrh)r|r9Z	mysectionrNZ
getdefault)rrrrr�+test_getdefault_does_saneget_with_mysection�szDUnhosedConfigParserTests.test_getdefault_does_saneget_with_mysectionc
CsR|j�}tjdd��$}|jd�|j�|j|j�}WdQRX|j||jg�dS)Nzw+)r�z[foo]
)r|rqrrr�rrsr,rN)rrrs�ok_filenamesrrr�test_read_filenames_as_string�s
z6UnhosedConfigParserTests.test_read_filenames_as_stringc
CsT|j�}tjdd��&}|jd�|j�|j|jg�}WdQRX|j||jg�dS)Nzw+)r�z[foo]
)r|rqrrr�rrsr,rN)rrrsrjrrr�test_read_filenames_as_list�s
z4UnhosedConfigParserTests.test_read_filenames_as_listc
Csltjjtjjt�d�}|j�}tjdd��(}|jd�|j	�|j
||jg�}WdQRX|j||jg�dS)Nr�zw+)r�z[foo]
)
rUr�r�r�r�r|rqrrr�rrsr,rN)rr�rrsrjrrr�3test_read_returns_ok_filenames_like_rawconfigparser�s
zLUnhosedConfigParserTests.test_read_returns_ok_filenames_like_rawconfigparsercCs|j�}|j|ji�dS)N)r|rN�section_to_file)rrrrr�)test_read_section_to_file_initially_empty�szBUnhosedConfigParserTests.test_read_section_to_file_initially_emptyc
CsX|j�}tjdd��&}|jd�|j�|j|jg�WdQRX|j|jd|j�dS)Nzw+)r�z[foo]
rg)	r|rqrrr�rrsr,rNrn)rrrsrrr�'test_read_section_to_file_read_one_file�s
[email protected]_read_section_to_file_read_one_filecCs�|j�}tjdd��T}tjdd��<}|jd�|j�|jd�|j�|j|j|jg�WdQRXWdQRX|j|jd|j�|j|jd|j�dS)Nzw+)r�z[foo]
z[bar]
rgrh)	r|rqrrr�rrsr,rNrn)rrr�r�rrr�-test_read_section_to_file_read_multiple_files�s

&zFUnhosedConfigParserTests.test_read_section_to_file_read_multiple_filesN)rrrrr|r`rbrcrerfrgrhrirkrlrmrorprqrrrrr\Os 	r\c@seZdZdd�Zdd�ZdS)�UtilFunctionsTestscCs4ddlm}|j|dd�d�|j|dd�d�dS)Nr)�
make_namespecr�r)z
group:process)rrsrN)rrsrrr�test_make_namespec�sz%UtilFunctionsTests.test_make_namespeccCsTddlm}|}|j|d�d�|j|d�d	�|j|d�d
�|j|d�d�dS)Nr)�split_namespecz
process:groupr)r�zgroup:zgroup:*)r)r�)r)r))r�N)r�N)rrurN)rrur�rrr�test_split_namespec�sz&UtilFunctionsTests.test_split_namespecN)rrrrtrvrrrrrr�srrcCstjtjt�S)N)�unittestZ
findTestCasesr�r�rrrrr�
test_suite�srx�__main__)ZdefaultTest)+�__doc__rUr�rqr�rwr�r�r�rrrrr�rrrZsupervisor.loggersrrr	r
rrr
rrZTestCaserrzr�rr6r:r=rGrKrTr\rrrxr�mainrrrr�<module>sxh7Sb0<0!o