
    `i[                         d dl m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 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S )	    )unicode_literalsN)resource_filename	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 Zd ZdS )EndToEndTestsc                 d   d}d}t          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)r   __package__osenvironpexpectspawnsys
executable
addCleanupkillsignalSIGINTexpect_exact)selfkeyvalfilenameargssupervisords         t/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/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     &&$[2LMM.h?	 !BJsO!-wOOOKOOK,fm<<<$$S3Y_555
3
3s   A0B   B/c                     t          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    expectEOF)r!   r$   r%   r&   supervisorctls        r'   test_issue_550zEndToEndTests.test_issue_550&   s     %[2KLL.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          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    ranger!   r$   r%   r&   r/   ilines          r'   test_issue_565zEndToEndTests.test_issue_5656   s     %[2KLL.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 	9r1   c                    t          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'r9   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   version_infor    r-   )r!   r$   r%   r&   is_py2b_prefixs         r'   test_issue_638zEndToEndTests.test_issue_638G   s     %[2KLL.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r1   c                 H   t          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      OKREADYrF   r:   zBUSY -> ACKNOWLEDGEDr9   N)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_663Z   s     %[2KLL.h?mCND7KKK(&-888q 	I 	IA$$Y$;;;$$%;R$HHHH	I 	Ir1   c                    t          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 staterF   r:   r*   statusu   test_öäü\s+RUNNINGr9   TFNr   r   r   r   r   r   r   r   r   r   r    r-   ExceptionPexpect
assertTruer!   r$   r%   r&   r/   seens         r'   test_issue_664zEndToEndTests.test_issue_664e   s    %[2KLL.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! !C54C5c                 Z   t          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_733y   s     %[2KLL.h?mCND7KKK(&-888  !KLLL  !KLLL7;'''''r1   c                 L   t          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 staterF   r:   rD   zunix:///tmp/issue-835.sockzhttp://anything/RPC2)"   The Øresund bridge ends in Malmör6   catr9   )r   r   r   r   r   r   r   r   r   r   r    r   r   ServerProxy
supervisorsendProcessStdinrS   
connectionclose)r!   r$   r%   r&   	transportserversresults           r'   test_issue_835zEndToEndTests.test_issue_835   s(   $[2KLL.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          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[   rF   r:   r*   fgr]   )HiHellor\   TF)r   r   r   r   r   r   r   r   r   r   r    sendlinerR   rS   )r!   r$   r%   r&   r/   re   rU   s          r'   test_issue_836zEndToEndTests.test_issue_836   sb   $[2KLL.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:9D:c                     t          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    rX   s       r'   1test_issue_986_command_string_with_double_percentz?EndToEndTests.test_issue_986_command_string_with_double_percent   so     %[2KLL.h?mCND7KKK(&-888  !UVVVVVr1   c                    t          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[   rF   r:   r*   availzcat\s+in use\s+autor9   TFNrQ   rT   s         r'   test_issue_1054zEndToEndTests.test_issue_1054   s     %[2LMM.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   "B< <CCc                     t          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] sectionNro   rX   s       r'   test_issue_1170azEndToEndTests.test_issue_1170a   so     %[2MNN.h?mCND7KKK(&-888  !ABBBBBr1   c                     t          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] sectionNro   rX   s       r'   test_issue_1170bzEndToEndTests.test_issue_1170b   so    
 %[2MNN.h?mCND7KKK(&-888  !=>>>>>r1   c                     t          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] sectionNro   rX   s       r'   test_issue_1170czEndToEndTests.test_issue_1170c   so    
 %[2MNN.h?mCND7KKK(&-888  !CDDDDDr1   c                     t          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[   rF   r:   Nro   rX   s       r'   test_issue_1224zEndToEndTests.test_issue_1224   st    
 %[2LMM.h?mCND7KKK(&-888  !<b IIIIIr1   c                    t          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   r3   r*   r4   r5   r6   r7   r8      %d - hash=57d94b…381088r9   r:   Nr<   r>   s          r'   test_issue_1231azEndToEndTests.test_issue_1231a   s     %[2MNN.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 	9r1   c                 2   t          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   r3   r*   r4   r5   r6   oopsLANGr   envNrL   rC      'Warning: sys.stdout.encoding is set to r9   r:   Unicode output may fail.r7   r8   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   copyrG   r-   r=   
exceptionsr.   assertInbefore)r!   r$   r%   r&   r   r/   r?   r@   s           r'   test_issue_1231bzEndToEndTests.test_issue_1231b   s    %[2MNN.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                 f   t          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   r3   r*   r4   r6   r   r   r   NrL   r   r   r9   r:   r   )r   r   r   r   r   r   r   r   r   r   r    r   r   r   rG   r-   )r!   r$   r%   r&   r   r/   s         r'   test_issue_1231czEndToEndTests.test_issue_1231c!  s4    %[2MNN.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 )(r1   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&   r/   s       r'   test_issue_1251zEndToEndTests.test_issue_12519  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[)))))r1   c                    t          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 2r9   r:   N)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_1298J  s     %[2LMM.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,,,,,r1   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   rD   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5r1   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_argsd  s~     [ZZ=HHHv}555$$$..00%88888r1   c                    t          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   rD   zunix:///tmp/issue-1483a.sock"http://transport.ignores.host/RPC2r_   Nr   r   r   r   r   r   r   r   r   r   r    supervisor.compatr   supervisor.xmlrpcr   r^   r_   getIdentificationrb   r   	r!   r$   r%   r&   r   r   rc   rd   idents	            r'   #test_issue_1483a_identifier_defaultz1EndToEndTests.test_issue_1483a_identifier_defaultm  s    %[2MNN.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          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   rD   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    %[2MNN.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          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   rD   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    %[2MNN.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(c                     ddg}t          j        t          j        |d          }|                     |j        t          j                   |                    d           dS )zThe command echo_supervisord_conf, whose implementation depends on
        importlib.resources to work, should print the example config.r   z0from supervisor import confecho; confecho.main()r   r   zSample supervisor config fileN)	r   r   r   r   r   r   r   SIGKILLr    )r!   r%   echo_supervisord_confs      r'   ,test_pull_request_1578_echo_supervisord_confz:EndToEndTests.test_pull_request_1578_echo_supervisord_conf  s]     HI 'cndW U U U-2FNCCC**+JKKKKKr1   c                 >   t          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d|          } |j        ||          }	|	j                                         |                                  |dd|          }
 |j        ||
          }|j                                         |
                                 dS )a!  If the socket is already closed when socket.shutdown(socket.SHUT_RDWR)
        is called in the close() method of an asyncore dispatcher, an exception
        will be raised (at least with Python 3.11.7 on macOS 14.2.1).  If it is
        not caught in that method, supervisord will crash.zfixtures/issue-1596.confr   r   r   r   r   r   r   r   r   zunix:///tmp/issue-1596.sockr   rD   N)r   r   r   r   r   r   r   r   r   r   r    r   r   r   r   r^   systemlistMethodsrb   )r!   r$   r%   r&   r   r   
socket_url	dummy_urlt1s1t2s2s               r'   -test_issue_1596_asyncore_close_does_not_crashz;EndToEndTests.test_issue_1596_asyncore_close_does_not_crash  s1   
 %[2LMM.h?mCND7KKK(&-888  !?@@@//////9999992
8	 ! R44"Y"9b11
	



 ! R44"Y"9b11
	





r1   N)__name__
__module____qualname__r(   r0   rA   rJ   rN   rV   rY   rg   rm   rp   rs   ru   rw   ry   r{   r   r   r   r   r   r   r   r   r   r   r   r    r1   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&L L L    r1   r   )
__future__r   r   r   r   unittestr   r   r   r   r   r   r   TestCaseBaseTestCaseobjectr   r   r1   r'   <module>r      s    ' ' ' ' ' ' 				  



  / / / / / / ' ' ' ' ' ' 1 1 1 1 1 1 2:NNN$LLLu u u u uL u u u u ur1   