
    vg%U                         d dl mZ d dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 dej        v rd dlZej        ZneZ G d de          Zd Zed	k    r ej        d
           dS dS )    )unicode_literalsN	xmlrpclibSupervisorTransport
END_TO_ENDc                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )EndToEndTestsc                 n   d}d}t          j        t          d          }ddd|g}	 |t          j        |<   t          j        t          j        |d          }| 	                    |j
        t          j                   |                    |d	z   |z              t          j        |= d
S # t          j        |= w xY w)zWhen an environment variable whose value contains a percent sign is
        present in the environment before supervisord starts, the value is
        passed to the child without the percent sign being mangled.SUPERVISOR_TEST_1441Bzfoo_%s_%_%%_%%%_%2_barzfixtures/issue-291a.conf-msupervisor.supervisord-cutf-8encoding=N)pkg_resourcesresource_filename__name__osenvironpexpectspawnsys
executable
addCleanupkillsignalSIGINTexpect_exact)selfkeyvalfilenameargssupervisords         ]/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/supervisor/tests/test_end_to_end.py;test_issue_291a_percent_signs_in_original_env_are_preservedzIEndToEndTests.test_issue_291a_percent_signs_in_original_env_are_preserved   s     && 28=WXX.h?	 !BJsO!-wOOOKOOK,fm<<<$$S3Y_555
3
3s   A0B% %B4c                 *   t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           |                    d           dd	d|d
dg}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           |                    t          j                   dS )zWhen an environment variable is set in the [supervisord] section,
        it should be put into the environment of the subprocess.zfixtures/issue-550.confr   r   r   r   r   z(success: print_env entered RUNNING statez+exited: print_env (exit status 0; expected)supervisor.supervisorctlztail -100000	print_envzTHIS_SHOULD=BE_IN_CHILD_ENVNr   r   r   r   r   r   r   r   r   r   r    r!   expectEOF)r"   r%   r&   r'   supervisorctls        r(   test_issue_550zEndToEndTests.test_issue_550'   s     !28=VWW.h?mCND7KKK(&-888  !KLLL  !NOOO0$.R]^cndWMMM*FM:::""#@AAAW[)))))    c                    t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           ddd|d	d
dg}t          j        t
          j        |d          }|                     |j        t          j
                   t          dd          D ]}d|z  }|                    |d           dS )zeWhen a log file has Unicode characters in it, 'supervisorctl
        tail -f name' should still work.zfixtures/issue-565.confr   r   r   r   r   $success: hello entered RUNNING stater+   tail-fhello      u'   The Øresund bridge ends in Malmö - %d   timeoutNr   r   r   r   r   r   r   r   r   r   r    r!   ranger"   r%   r&   r'   r0   ilines          r(   test_issue_565zEndToEndTests.test_issue_5657   s     !28=VWW.h?mCND7KKK(&-888  !GHHH0$&$PWXcndWMMM*FM:::q! 	9 	9A<q@D&&tR&8888	9 	9r2   c                    t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   t
          j        d         dk     }|rd	}nd
}|                    d|z  d           |                    dd           |r|                    dd           dS dS )zWhen a process outputs something on its stdout or stderr file
        descriptor that is not valid UTF-8, supervisord should not crash.zfixtures/issue-638.confr   r   r   r   r   r       bzUndecodable: %s'\x88\n'r:   r;   z)received SIGCH?LD indicating a child quitzVgave up: produce-unicode-error entered FATAL state, too many start retries too quickly<   N)r   r   r   r   r   r   r   r   r   r   r    version_infor!   r.   )r"   r%   r&   r'   is_py2b_prefixs         r(   test_issue_638zEndToEndTests.test_issue_638H   s    !28=VWW.h?mCND7KKK(&-888!!$q( 	HHH  !;h!FPR SSSFPRSSS 	W$$ &JSU % W W W W W	W 	Wr2   c                 R   t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   t          d          D ]0}|                    dd	
           |                    dd
           1dS )zSWhen Supervisor is run on Python 3, the eventlistener protocol
        should work.zfixtures/issue-663.confr   r   r   r   r      OKREADYrG   r;   zBUSY -> ACKNOWLEDGEDr:   N)r   r   r   r   r   r   r   r   r   r   r    r>   r!   )r"   r%   r&   r'   r@   s        r(   test_issue_663zEndToEndTests.test_issue_663[   s     !28=VWW.h?mCND7KKK(&-888q 	I 	IA$$Y$;;;$$%;R$HHHH	I 	Ir2   c                 (   t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    dd	           dd
d|dg}t          j        t
          j        |d          }|                     |j        t          j
                   	 |                    dd	           d}n# t          j        $ r d}Y nw xY w|                     |           dS )zWhen a subprocess name has Unicode characters, 'supervisord'
        should not send incomplete XML-RPC responses and 'supervisorctl
        status' should work.zfixtures/issue-664.confr   r   r   r   r   u!   test_öäü entered RUNNING staterG   r;   r+   statusu   test_öäü\s+RUNNINGr:   TFNr   r   r   r   r   r   r   r   r   r   r    r!   r.   ExceptionPexpect
assertTruer"   r%   r&   r'   r0   seens         r(   test_issue_664zEndToEndTests.test_issue_664f   s    !28=VWW.h?mCND7KKK(&-888  !Db QQQ0$(KcndWMMM*FM:::	  !92 FFFDD' 	 	 	DDD	s   C& &C:9C:c                 d   t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           |                    d           |                    t          j                   d	S )
zzWhen a subprocess enters the FATAL state, a one-line eventlistener
        can be used to signal supervisord to shut down.zfixtures/issue-733.confr   r   r   r   r   z(gave up: nonexistent entered FATAL statez(received SIGTERM indicating exit requestNr-   r"   r%   r&   r'   s       r(   test_issue_733zEndToEndTests.test_issue_733z   s     !28=VWW.h?mCND7KKK(&-888  !KLLL  !KLLL7;'''''r2   c                 V   t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    dd	           t          d
d
d          }t          j        d|          }	 dD ]I}|j                            d|          }|                     |           |                    |d	           J	 |j                                         d S # |j                                         w xY w)Nzfixtures/issue-835.confr   r   r   r   r   cat entered RUNNING staterG   r;   rE   zunix:///tmp/issue-835.sockzhttp://anything/RPC2)"   The Øresund bridge ends in Malmör7   catr:   )r   r   r   r   r   r   r   r   r   r   r    r!   r   r   ServerProxy
supervisorsendProcessStdinrT   
connectionclose)r"   r%   r&   r'   	transportserversresults           r(   test_issue_835zEndToEndTests.test_issue_835   s+    28=VWW.h?mCND7KKK(&-888  !<b III'B0LMM	&'=yII	)D 8 8*;;E1EE'''((B(77778
  &&(((((I &&((((s   %AD D(c                    t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    dd	           dd
d|ddg}t          j        t
          j        |d          }|                     |j        t          j
                   	 dD ]X}|                    |           |                    |d	           |                    |           |                    |           Yd}n# t          j        $ r d}Y nw xY w|                     |           d S )Nzfixtures/issue-836.confr   r   r   r   r   r\   rG   r;   r+   fgr^   )HiHellor]   TF)r   r   r   r   r   r   r   r   r   r   r    r!   sendlinerS   rT   )r"   r%   r&   r'   r0   rf   rV   s          r(   test_issue_836zEndToEndTests.test_issue_836   se    28=VWW.h?mCND7KKK(&-888  !<b III0$$NcndWMMM*FM:::	J . .&&q)))((B(777**1---**1----DD' 	 	 	DDD	s   AD+ +D?>D?c                     t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           dS )	zyA percent sign can be used in a command= string without being
        expanded if it is escaped by a second percent sign.zfixtures/issue-986.confr   r   r   r   r   z2dhcrelay -d -q -a %h:%p %P -i Vlan1000 192.168.0.1Nr   r   r   r   r   r   r   r   r   r   r    r!   rY   s       r(   1test_issue_986_command_string_with_double_percentz?EndToEndTests.test_issue_986_command_string_with_double_percent   sr     !28=VWW.h?mCND7KKK(&-888  !UVVVVVr2   c                    t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    dd	           dd
d|dg}t          j        t
          j        |d          }	 |                    dd	           d}n# t          j        $ r d}Y nw xY w|                     |           dS )zLWhen run on Python 3, the 'supervisorctl avail' command
        should work.zfixtures/issue-1054.confr   r   r   r   r   r\   rG   r;   r+   availzcat\s+in use\s+autor:   TFNrR   rU   s         r(   test_issue_1054zEndToEndTests.test_issue_1054   s     !28=WXX.h?mCND7KKK(&-888  !<b III0$'JcndWMMM	  !8" EEEDD' 	 	 	DDD	s   'C CCc                     t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           dS )	zWhen the [supervisord] section has a variable defined in
        environment=, that variable should be able to be used in an
        %(ENV_x) expansion in a [program] section.zfixtures/issue-1170a.confr   r   r   r   r   zset from [supervisord] sectionNrp   rY   s       r(   test_issue_1170azEndToEndTests.test_issue_1170a   sr     !28=XYY.h?mCND7KKK(&-888  !ABBBBBr2   c                     t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           dS )	zWhen the [supervisord] section has a variable defined in
        environment=, and a variable by the same name is defined in
        enviroment= of a [program] section, the one in the [program]
        section should be used.zfixtures/issue-1170b.confr   r   r   r   r   zset from [program] sectionNrp   rY   s       r(   test_issue_1170bzEndToEndTests.test_issue_1170b   sr    
 !28=XYY.h?mCND7KKK(&-888  !=>>>>>r2   c                     t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           dS )	zWhen the [supervisord] section has a variable defined in
        environment=, and a variable by the same name is defined in
        enviroment= of an [eventlistener] section, the one in the
        [eventlistener] section should be used.zfixtures/issue-1170c.confr   r   r   r   r   z set from [eventlistener] sectionNrp   rY   s       r(   test_issue_1170czEndToEndTests.test_issue_1170c   sr    
 !28=XYY.h?mCND7KKK(&-888  !CDDDDDr2   c                     t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    dd	           d
S )zWhen the main log file does not need rotation (logfile_maxbyte=0)
        then the non-rotating logger will be used to avoid an
        IllegalSeekError in the case that the user has configured a
        non-seekable file like /dev/stdout.zfixtures/issue-1224.confr   r   r   r   r   r\   rG   r;   Nrp   rY   s       r(   test_issue_1224zEndToEndTests.test_issue_1224   sw    
 !28=WXX.h?mCND7KKK(&-888  !<b IIIIIr2   c                    t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           ddd|d	d
dg}t          j        t
          j        |d          }|                     |j        t          j
                   t          dd          D ]}d|z  }|                    |d           dS )bWhen 'supervisorctl tail -f name' is run and the log contains
        unicode, it should not fail.zfixtures/issue-1231a.confr   r   r   r   r   r4   r+   r5   r6   r7   r8   r9      %d - hash=57d94b…381088r:   r;   Nr=   r?   s          r(   test_issue_1231azEndToEndTests.test_issue_1231a   s     !28=XYY.h?mCND7KKK(&-888  !GHHH0$&$PWXcndWMMM*FM:::q! 	9 	9A.2D&&tR&8888	9 	9r2   c                 <   t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           ddd|d	d
dg}t          j                                        }d|d<   t          j        t
          j        |d|          }|                     |j        t          j
                   t
          j        dd         dk     r.|                    dd           |                    dd           t#          dd          D ]V}d|z  }	 |                    |d            # t          j        j        $ r  |                     d|j                   Y  dS w xY wdS )r~   zfixtures/issue-1231b.confr   r   r   r   r   r4   r+   r5   r6   r7   oopsLANGr   envNrM   rD      'Warning: sys.stdout.encoding is set to r:   r;   Unicode output may fail.r8   r9   r   z:Unable to write Unicode to stdout because it has encoding )r   r   r   r   r   r   r   r   r   r   r    r!   r   r   copyrH   r.   r>   
exceptionsr/   assertInbefore)r"   r%   r&   r'   r   r0   r@   rA   s           r(   test_issue_1231bzEndToEndTests.test_issue_1231b   s    !28=XYY.h?mCND7KKK(&-888  !GHHH0$&$PWXjooFcndW*-/ / /*FM:::
 BQB&((  !J)+ ! - - -  !;R HHHq! 	 	A.2D**4*<<<<%)    .+24 4 4 			 	s   E%%/FFc                 p   t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           ddd|d	d
g}t          j                                        }d|d<   t          j        t
          j        |d|          }|                     |j        t          j
                   t
          j        dd         dk     r0|                    dd           |                    dd           dS dS )r~   zfixtures/issue-1231c.confr   r   r   r   r   r4   r+   r5   r7   r   r   r   NrM   r   r   r:   r;   r   )r   r   r   r   r   r   r   r   r   r   r    r!   r   r   r   rH   r.   )r"   r%   r&   r'   r   r0   s         r(   test_issue_1231czEndToEndTests.test_issue_1231c"  s7    !28=XYY.h?mCND7KKK(&-888  !GHHH0$&'RjooFcndW*-/ / /*FM:::
 BQB&((  !J)+ ! - - -  !;R HHHHH )(r2   c                 R   g d}t          j        t          j        |d          }|                     |j        t          j                   |                    d           |                    d           |	                    t           j
                   g d}t          j        t          j        |d          }|                     |j        t          j                   |                    d           |                    d           |	                    t           j
                   d	S )
z`When -? is given to supervisord or supervisorctl, help should be
        displayed like -h does.)r   r   -?r   r   z(supervisord -- run a set of applicationsz(-l/--logfile FILENAME -- use FILENAME as)r   r+   r   z%supervisorctl -- control applicationsz(-i/--interactive -- start an interactiveN)r   r   r   r   r   r   r   r    r!   r.   r/   )r"   r&   r'   r0   s       r(   test_issue_1251zEndToEndTests.test_issue_1251:  s    655mCND7KKK(&-888  !KLLL  !KLLL7;'''777cndWMMM*FM:::""#JKKK""#MNNNW[)))))r2   c                    t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           dt
          j        d	|d
}t          j        dd|gd          }|                     |j        t          j
                   |                    dd           dS )zWhen the output of 'supervisorctl tail -f worker' is piped such as
        'supervisor tail -f worker | grep something', 'supervisorctl' should
        not crash.zfixtures/issue-1298.confr   r   r   r   r   z#success: spew entered RUNNING state'z"' -m supervisor.supervisorctl -c 'z' tail -f spew | /bin/cat -uz/bin/shz	spewage 2r:   r;   N)r   r   r   r   r   r   r   r   r   r   r    r!   r.   )r"   r%   r&   r'   cmdbashs         r(   test_issue_1298zEndToEndTests.test_issue_1298K  s     !28=WXX.h?mCND7KKK(&-888  !FGGGG NNNHHH }YsgFFF	6=111K,,,,,r2   c                 2   g d}t          j        t          j        |d          }|                     |j        t          j                   |                    t           j	                   | 
                    |j                                        d           dS )z\When pidproxy is given a command to run that has no arguments, it
        runs that command.)r   supervisor.pidproxynonexistent-pidfile	/bin/echor   r   rE   Nr   r   r   r   r   r   r   r    r.   r/   assertEqualr   stripr"   r&   pidproxys      r(   )test_issue_1418_pidproxy_cmd_with_no_argsz7EndToEndTests.test_issue_1418_pidproxy_cmd_with_no_args\  s~     QPP=HHHv}555$$$..00"55555r2   c                 2   g d}t          j        t          j        |d          }|                     |j        t          j                   |                    t           j	                   | 
                    |j                                        d           dS )zYWhen pidproxy is given a command to run that has arguments, it
        runs that command.)r   r   r   r   12r   r   z1 2Nr   r   s      r(   &test_issue_1418_pidproxy_cmd_with_argsz4EndToEndTests.test_issue_1418_pidproxy_cmd_with_argse  s~     [ZZ=HHHv}555$$$..00%88888r2   c                    t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           dd	lm} dd
lm}  |ddd          }	  |j        d|          }|j                                        }|                                 n# |                                 w xY w|                     |d           dS )zfWhen no identifier is supplied on the command line or in the config
        file, the default is used.zfixtures/issue-1483a.confr   r   r   r   r   supervisord started with pidr   r   r   rE   zunix:///tmp/issue-1483a.sock"http://transport.ignores.host/RPC2r`   Nr   r   r   r   r   r   r   r   r   r   r    r!   supervisor.compatr   supervisor.xmlrpcr   r_   r`   getIdentificationrc   r   	r"   r%   r&   r'   r   r   rd   re   idents	            r(   #test_issue_1483a_identifier_defaultz1EndToEndTests.test_issue_1483a_identifier_defaultn  s    !28=XYY.h?mCND7KKK(&-888  !?@@@//////999999''B0NOO		*Y*+OQZ[[F%7799EOOIOO-----   *C C+c                    t          j        t          d          }ddd|g}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d           dd	lm} dd
lm}  |ddd          }	  |j        d|          }|j                                        }|                                 n# |                                 w xY w|                     |d           dS )zpWhen the identifier is supplied in the config file only, that
        identifier is used instead of the default.zfixtures/issue-1483b.confr   r   r   r   r   r   r   r   r   rE   zunix:///tmp/issue-1483b.sockr   from_config_fileNr   r   s	            r(   ,test_issue_1483b_identifier_from_config_filez:EndToEndTests.test_issue_1483b_identifier_from_config_file  s    !28=XYY.h?mCND7KKK(&-888  !?@@@//////999999''B0NOO		*Y*+OQZ[[F%7799EOOIOO 233333r   c                    t          j        t          d          }ddd|ddg}t          j        t
          j        |d          }|                     |j        t          j
                   |                    d	           d
dlm} d
dlm}  |ddd          }	  |j        d|          }|j                                        }|                                 n# |                                 w xY w|                     |d           dS )z~When an identifier is supplied in both the config file and on the
        command line, the one from the command line is used.zfixtures/issue-1483c.confr   r   r   z-ifrom_command_liner   r   r   r   r   r   rE   zunix:///tmp/issue-1483c.sockr   Nr   r   s	            r(   -test_issue_1483c_identifier_from_command_linez;EndToEndTests.test_issue_1483c_identifier_from_command_line  s    !28=XYY.hFYZmCND7KKK(&-888  !?@@@//////999999''B0NOO		*Y*+OQZ[[F%7799EOOIOO 344444s   *C C-N)r   
__module____qualname__r)   r1   rB   rK   rO   rW   rZ   rh   rn   rq   rt   rv   rx   rz   r|   r   r   r   r   r   r   r   r   r   r    r2   r(   r
   r
      s             * * * 9 9 9"W W W&	I 	I 	I  (	( 	( 	() ) )   *W W W  "C C C	? 	? 	?	E 	E 	E	J 	J 	J9 9 9"     DI I I0* * *"- - -"6 6 69 9 9. . .&4 4 4&5 5 5 5 5r2   r
   c                  T    t          j        t          j        t                             S )N)unittestfindTestCasesr   modulesr   r   r2   r(   
test_suiter     s    !#+h"7888r2   __main__r   )defaultTest)
__future__r   r   r   r   r   r   r   r   r   r   r   r   TestCaseBaseTestCaseobjectr
   r   r   mainr   r2   r(   <module>r      s   ' ' ' ' ' ' 				  



      ' ' ' ' ' ' 1 1 1 1 1 1 2:NNN$LLLP5 P5 P5 P5 P5L P5 P5 P5d9 9 9 zHMl++++++ r2   