Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/bsddb/test/test_replication.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@s�dZddlZddlZddlZddlmZmZmZmZm	Z	m
Z
dejfd��YZdefd��YZ
defd	��YZd
�Zedkr�ejdd
�ndS(s(TestCases for distributed transactions.
i�N(tdbttest_supportthave_threadstverbosetget_new_environment_pathtget_new_database_patht
DBReplicationcBseZd�Zd�ZRS(cs2t��_t��_tj��_tj��_�jj�jtjtj	Btj
BtjBtjBtj
BtjBtjBd��jj�jtjtj	Btj
BtjBtjBtj
BtjBtjBd�t�_�_�fd�}�fd�}�jj|��jj|�d�_�_dS(Ni�cs|tjkrt�_ndS(N(RtDB_EVENT_REP_MASTERtTruetconfirmed_master(tatbtc(tself(s1/sys/lib/python2.7/bsddb/test/test_replication.pyR	!scs|tjkrt�_ndS(N(RtDB_EVENT_REP_STARTUPDONERtclient_startupdone(R
RR(R
(s1/sys/lib/python2.7/bsddb/test/test_replication.pyR%s(Rt
homeDirMastert
homeDirClientRtDBEnvtdbenvMastertdbenvClienttopent	DB_CREATEtDB_INIT_TXNtDB_INIT_LOGt
DB_INIT_MPOOLtDB_INIT_LOCKtDB_INIT_REPt
DB_RECOVERt	DB_THREADtFalseR	Rtset_event_notifytNonetdbMastertdbClient(R
R	R((R
s1/sys/lib/python2.7/bsddb/test/test_replication.pytsetUps>>cCs�|jr|jj�n|jr2|jj�nd�}|jj|�|jj|�|jj�|jj�tj|j�tj|j	�dS(NcWsdS(N((targs((s1/sys/lib/python2.7/bsddb/test/test_replication.pytdummy=s(
R"tcloseR!RRRRtrmtreeRR(R
R%((s1/sys/lib/python2.7/bsddb/test/test_replication.pyttearDown4s			

(t__name__t
__module__R#R((((s1/sys/lib/python2.7/bsddb/test/test_replication.pyRs	%tDBReplicationManagercBseZd�ZRS(cCs$tj�}tj�}tj�dkr#|jjd|�|_|jjtjt	�|jjtj
t	�|jjd|�|_|jjd|�|_
|j
jtjt	�|jjd|�|_|jjtj
t	�ittt	tgtj6t	tttgtj6ttttgtj6t	ttt	gtj
6ttttgtj6}x�|j�D]y\}}xjt|j|j|j
|jg|�D]A\}}|r�|j|j|��q�|j|j|��q�WqcW|j|jj�|jj��|j|j
j�|jj��xct|j|j|j
|jg||||g�D].\}}|j�}|j|d|f�qXWxH|j|jgD]4}|j|j�|jj|j��j��q�Wx�|j
|jgD]4}|j|j�|jj|j��j��q�nl|jjd|�|jjd|�|jjd|�|jjd|�|jjd�|jjd�|jj d�|jj d�|jj!tj"d�|jj!tj"d�|j|jj#tj"�d�|j|jj#tj"�d�|jj!tj$d�|jj!tj$d	�|j|jj#tj$�d�|j|jj#tj$�d	�|jj!tj%d
�|jj!tj%d�|j|jj#tj%�d
�|j|jj#tj%�d�|jj&tj'�|jj&tj'�|jj(dtj)�|jj(dtj*�|j|jj+�d�|j|jj+�d�|j|jj,�d�|j|jj,�d�|j|jj-�tj'�|j|jj-�tj'�d
dl.}	|	j.�d}
x6|	j.�|
kr/|j/o|j0r/|	j1d�q�	j.�|
krdd
dl2}|j3dIJt	}n|jj4�}|jt5|�d�|j6�d}|j|dd�|j|d|�|j|dtj7kp�dtj8k�|jj4�}|jt5|�d�|j6�d}|j|dd�|j|d|�|j|dtj7kpt|dtj8k�tj�dkr�|jj9dtj:�}|jd|k�ntj;|j�|_<|jj=�}
|j<j>dtj?tj@dd|
�|
jA�d
dl.}	d
dlB}|	j.�d}
xH|	j.�|
kr}|jCjD|jCjE|jFd��r}|	j1d�q6Wtj;|j�|_Gx�t	r.	|jj=�}
y/|jGj>dtj?dtjHddd|
�WnCtjIk
r	|
jJ�|jGjK�tj;|j�|_Gq�nX|
jA�Pq�W|jj=�}
|j<jLddd|
�|
jA�d
dl.}	|	j.�d}
d}xo|	j.�|
kr�dkr�jj=�}
|jGjNdd|
�}|
jA�|dkr�|	j1d�q�q�W|	j.�|
kr
|r
|jOd�n|j|	j.�|
k�|jd|�|jj=�}
|j<jPdd|
�|
jA�|	j.�d}
xo|	j.�|
kr�dk	r�jj=�}
|jGjNdd|
�}|
jA�|dkr�|	j1d�q�q�W|j|	j.�|
k�|jd|�dS(Niis	127.0.0.1i
ii�i�i�iP�i�i�ii�i<gz��?sBXXX: timeout happened beforestartup was confirmed - see issue 3892iitflagstmsgs_queuedttesti�ttxngz��?tmodetABCt123s>replication test skipped due to random failure, see issue 3892(ii(ii(QRtfind_unused_portRtversionRtrepmgr_sitetsitet
set_configtDB_GROUP_CREATORRt
DB_LOCAL_SITEtsite2Rtsite3tDB_BOOTSTRAP_HELPERtsite4Rt	DB_LEGACYtDB_REPMGR_PEERtitemstzipt
assertTruet
get_configtassertFalsetassertNotEqualtget_eidtget_addresstassertEqualtrepmgr_site_by_eidtrepmgr_set_local_sitetrepmgr_add_remote_sitetrep_set_nsitestrep_set_prioritytrep_set_timeouttDB_REP_CONNECTION_RETRYtrep_get_timeouttDB_REP_ELECTION_TIMEOUTtDB_REP_ELECTION_RETRYtrepmgr_set_ack_policytDB_REPMGR_ACKS_ALLtrepmgr_startt
DB_REP_MASTERt
DB_REP_CLIENTtrep_get_nsitestrep_get_prioritytrepmgr_get_ack_policyttimeR	Rtsleeptsyststderrtrepmgr_site_listtlentvaluestDB_REPMGR_CONNECTEDtDB_REPMGR_DISCONNECTEDtrepmgr_statt
DB_STAT_CLEARtDBR!t	txn_beginRtDB_HASHRtcommittos.pathtpathtexiststjoinRR"t	DB_RDONLYtDBRepHandleDeadErrortabortR&tputR tgettskipTesttdelete(R
tmaster_porttclient_porttdtitjtktvtaddrR[ttimeoutR]tstartup_timeoutR/tos((s1/sys/lib/python2.7/bsddb/test/test_replication.pyttest01_basic_replicationHs(1""!#&

(
	%
%	



!

!
(R)R*R�(((s1/sys/lib/python2.7/bsddb/test/test_replication.pyR+GstDBBaseReplicationcBs�eZd�Zd�Zd�Zd�Zej�d
krHd�Znej�dkrfd�Z	nej�dkr�d	�Z
nRS(
cs�tj���fd�}�fd�}�jj|��jj|�ddl}|j��_|j��_�fd�}�fd�}�jjd|��jj	d��jjd|��jj	d	��j
�jj�d��j
�jj�d	��fd
�}�fd�}ddlm
}|d
|�}	|d
|�}
ddl}|jd	dkr�|	jt�|
jt�nt|	_t|
_|	�_|
�_d�_�_tg�_tg�_dS(Ncs.|tjks|tjkr*t�_ndS(N(RRtDB_EVENT_REP_ELECTEDRR	(R
RR(R
(s1/sys/lib/python2.7/bsddb/test/test_replication.pyR	
scs|tjkrt�_ndS(N(RRRR(R
RR(R
(s1/sys/lib/python2.7/bsddb/test/test_replication.pyRsi�cs�jj||f�dS(N(tm2cRq(tdbenvtcontroltrectlsnptenvidR,(R
(s1/sys/lib/python2.7/bsddb/test/test_replication.pyR�scs�jj||f�dS(N(tc2mRq(R�R�R�R�R�R,(R
(s1/sys/lib/python2.7/bsddb/test/test_replication.pyR�!si
i
iics"�j�j�jd�jt�S(Ni(t	thread_doRR�tmaster_doing_electionR((R
(s1/sys/lib/python2.7/bsddb/test/test_replication.pyt
thread_master1scs"�j�j�jd�jt�S(Ni
(R�RR�tclient_doing_electionR((R
(s1/sys/lib/python2.7/bsddb/test/test_replication.pyt
thread_client5s(tThreadttarget(RR#RRRtQueueR�R�trep_set_transportRMRHRYt	threadingR�R]tversion_infot	setDaemonRtdaemontt_mtt_cR R!R"RR�R�(R
R	RR�R�R�R�R�R�R�R�R]((R
s1/sys/lib/python2.7/bsddb/test/test_replication.pyR#s@

				cCs�|jr|jj�n|jr2|jj�n|jjd�|jjd�|jj�|j	j�d�}|j
j|�|jj|�|j
j
d|�|jj
d|�|jj�|j
j�tj|j�tj|j�dS(NcWsdS(N((R$((s1/sys/lib/python2.7/bsddb/test/test_replication.pyR%Zsi
i(R"R&R!R�RqR R�R�RmR�RRRR�RR'RR(R
R%((s1/sys/lib/python2.7/bsddb/test/test_replication.pyR(Ms"		

	

cCs\|jjdtj�|jjdtj�d�}||_|jj�|j	j�dS(NR,cSsHxAtrC|j�}|dkr%dS|j|d|d|�qWdS(Nii(RRrR trep_process_message(tenvtqR�telection_statustmust_be_masterR{((s1/sys/lib/python2.7/bsddb/test/test_replication.pyR�js
	(
Rt	rep_startRRVRRWR�R�tstartR�(R
R�((s1/sys/lib/python2.7/bsddb/test/test_replication.pytbasic_rep_threadingfs		
cCs�|j�ddl}|j�d}x6|j�|kr^|joJ|jr^|jd�q)W|j|j�|k�tj|j�|_	|jj
�}|j	jdtjtj
dd|�|j�ddl}ddl}|j�d}xH|j�|kr=|jj|jj|jd��r=|jd�q�j|j�|_x�tr�jj
�}y/|jjdtjd	tjd
dd|�WnCtjk
r�|j�|jj�tj|j�|_qVnX|j�PqVW|jjd	tj�}|jd|k�|jj
�}|j	jdd
d|�|j�ddl}|j�d}d}xo|j�|kr�|dkr�|jj
�}|jjdd|�}|j�|dkrq|jd�qqqqW|j|j�|k�|j d
|�|jj
�}|j	j!dd|�|j�|j�d}xo|j�|kr�|dk	r�|jj
�}|jjdd|�}|j�|dkrK|jd�qKqKW|j|j�|k�|j d|�dS(Ni�i<gz��?R.i�R/i
gz��?R,R0tmaster_changesR1R2("R�R[R	RR\RBRRfRR!RgRRhRRiRjRkRlRmRRR"RRnRoRpR&trep_statReRqR RrRHRt(R
R[R}R/RRwR{((s1/sys/lib/python2.7/bsddb/test/test_replication.pyR�usr

%
%	



!

!
iicCse|j�|jj�\}}|jj|d|d�|j|jj�|d|df�dS(Ni(R�Rtrep_get_requesttrep_set_requestRH(R
tminimumtmaximum((s1/sys/lib/python2.7/bsddb/test/test_replication.pyttest02_test_request�s

ics�jjdtj��jjdtj��fd�}|�_�jj��jj��jj	tj
d��jj	tj
d�t�jd<xFtr�y%�jj
dd�t�jd<PWq�tjk
r�q�Xq�W�j�j�x�jj�ds	q�S(NR,cs#xtr|j�}|dkr%dS�j|d|d|�}|rp�jrp�jjdtj�t	}n|dtj
kr��fd�}�dr�jrddlm}t�d<|d|�}	ddl
}
|
jddkr|	jt�n	t|	_|	j�qqqWdS(	NiiR,csGx@trBy�jdd�t�d<PWqtjk
r>qXqWdS(Niii(Rt	rep_electRRtDBRepUnavailError((R�R�(s1/sys/lib/python2.7/bsddb/test/test_replication.pytelect�s	
i�(R�R�i(RRrR R�R	RR�RRVRtDB_REP_HOLDELECTIONR�R�R]R�R�R�R�(R�R�R�R�R�R{trR�R�ttR](R
(R�R�s1/sys/lib/python2.7/bsddb/test/test_replication.pyR��s&		
	iP�iiitstartup_complete(RR�RRWRR�R�R�R�RNRQRR�R�RR�RBR	R�(R
R�((R
s1/sys/lib/python2.7/bsddb/test/test_replication.pyttest03_master_election�s&	


	
cCsLd\}}|jj||�|j||f|jj��|j�dS(Ni�i�(i�i�(Rtrep_set_clockskewRHtrep_get_clockskewR�(R
tfasttslow((s1/sys/lib/python2.7/bsddb/test/test_replication.pyttest04_test_clockskews
(ii(ii(ii(R)R*R#R(R�R�RR4R�R�R�(((s1/sys/lib/python2.7/bsddb/test/test_replication.pyR�
s	B			F<cCs�tj�}tj�dkr�tj�}y|j�t}Wn
t}nX|j�~|rz|j	tj
t��ntr�|j	tj
t
��q�n|S(Nii(ii(tunittestt	TestSuiteRR4RRZRRR&taddTestt	makeSuiteR+RR�(tsuiteR�tReplicationManager_available((s1/sys/lib/python2.7/bsddb/test/test_replication.pyt
test_suite
s



t__main__tdefaultTestR�(t__doc__RR[R�ttest_allRRRRRRtTestCaseRR+R�R�R)tmain(((s1/sys/lib/python2.7/bsddb/test/test_replication.pyt<module>s.9��

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.