ó
X\¬Qc           @   s×   d  Z  d d l Z d d l Z d d l m Z m Z m Z m Z d d l m Z d e j	 f d „  ƒ  YZ
 d e
 f d „  ƒ  YZ d	 e
 f d
 „  ƒ  YZ d e
 f d „  ƒ  YZ d „  Z e d k rÓ e j d d ƒ n  d S(   s(   TestCases for distributed transactions.
iÿÿÿÿN(   t   dbt   test_supportt   get_new_environment_patht   get_new_database_path(   t   verboset   DBTxn_distributedc           B   sP   e  Z d  Z e Z e Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z RS(   iÒ  c         C   sL  t  j ƒ  |  _ |  j j |  j ƒ |  j j |  j d ƒ |  j j |  j d ƒ |  j j |  j d ƒ |  j r‰ |  j j	 t  j
 t ƒ n  |  j j |  j t  j t  j Bt  j Bt  j Bt  j Bt  j Bt  j Bd ƒ t  j |  j ƒ |  _  |  j  j t  j ƒ | rH|  j j ƒ  } |  j  j |  j t  j t  j t  j Bd d | ƒ| j ƒ  n  d  S(   Ni   i¶  t   txn(   R    t   DBEnvt   dbenvt
   set_tx_maxt   num_txnst   set_lk_max_lockerst   set_lk_max_lockst   set_lk_max_objectst   nosynct	   set_flagst   DB_TXN_NOSYNCt   Truet   opent   homeDirt	   DB_CREATEt	   DB_THREADt
   DB_RECOVERt   DB_INIT_TXNt   DB_INIT_LOGt   DB_INIT_MPOOLt   DB_INIT_LOCKt   DBt
   set_re_lent   DB_GID_SIZEt	   txn_begint   filenamet   DB_QUEUEt   commit(   t   selft   must_open_dbR   (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyt   _create_env   s$    	)c         C   s%   t  ƒ  |  _ d |  _ |  j d t ƒ S(   Nt   testR#   (   R   R   R   R$   R   (   R"   (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyt   setUp'   s    	c         C   sM   |  j  s t j ƒ  d  d k r/ |  j j ƒ  n  |  j j ƒ  |  j j ƒ  d  S(   Ni   i   i   (   i   i   (   R   R    t   versionR   t	   log_flusht   close(   R"   (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyt   _destroy_env,   s    c         C   s   |  j  ƒ  t j |  j ƒ d  S(   N(   R*   R   t   rmtreeR   (   R"   (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyt   tearDown2   s    
c         C   s   |  j  ƒ  |  j | ƒ d  S(   N(   R*   R$   (   R"   R#   (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyt   _recreate_env6   s    
c         C   sÙ  t  ƒ  } d „  } d d  l } | j d d k r= d „  } n  x t |  j ƒ D]n } |  j j ƒ  } d t j } | | | ƒ } |  j j	 | | d | d t j
 ƒ| j | ƒ | j | ƒ qM W~ |  j |  j ƒ |  j j ƒ  } |  j |  j t | ƒ ƒ x' | D] \ } } |  j | | k ƒ qW~ ~ |  j |  j ƒ |  j j ƒ  } |  j |  j t | ƒ ƒ t  ƒ  } t  ƒ  }	 d }
 x• | D] \ } } |
 d k s¥|
 d	 k r¿|	 j | ƒ | j ƒ  nE |
 d
 k rØ| j ƒ  n, |
 d k r| j ƒ  | j | ƒ d }
 n  |
 d	 7}
 qW~ ~ |  j |  j ƒ |  j j ƒ  } |  j t | ƒ t | ƒ ƒ x | D] \ } } | j ƒ  qZW~ ~ |  j d t ƒ |  j j ƒ  } |  j t | ƒ d k ƒ |  j t |	 ƒ |  j j ƒ  d ƒ d  S(   Nc         S   s   |  S(   N(    (   t   x(    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyt   <lambda><   s    iÿÿÿÿi    i   c         S   s   t  |  d ƒ S(   Nt   ascii(   t   bytes(   R.   (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyR/   ?   s    s   %%%ddR   t   flagsi   i   R#   t   nkeys(   t   sett   syst   version_infot   xrangeR
   R   R   R    R   t   putt	   DB_APPENDt   addt   prepareR-   R#   t   txn_recovert   assertEqualt   lent
   assertTrueR!   t   abortt   discardR   t   stat(   R"   t   txnst   adaptR5   t   iR   t   gidt   recovered_txnst   discard_txnst   committed_txnst   state(    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyt   test01_distributed_transactions:   sd    		"		
	(   t   __name__t
   __module__R
   R   R   t   FalseR#   R$   R&   R*   R,   R-   RK   (    (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyR      s   					t   DBTxn_distributedSYNCc           B   s   e  Z e Z RS(    (   RL   RM   RN   R   (    (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyRO   €   s   t   DBTxn_distributed_must_open_dbc           B   s   e  Z e Z RS(    (   RL   RM   R   R#   (    (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyRP   ƒ   s   t"   DBTxn_distributedSYNC_must_open_dbc           B   s   e  Z e Z e Z RS(    (   RL   RM   RN   R   R   R#   (    (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyRQ   †   s   c          C   s’   t  j ƒ  }  t j ƒ  d k rM |  j t  j t ƒ ƒ |  j t  j t ƒ ƒ n  t j ƒ  d k rŽ |  j t  j t ƒ ƒ |  j t  j t	 ƒ ƒ n  |  S(   Ni   i   i   (   i   i   (   i   i   (
   t   unittestt	   TestSuiteR    R'   t   addTestt	   makeSuiteR   RO   RP   RQ   (   t   suite(    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyt
   test_suiteŒ   s    t   __main__t   defaultTestRW   (   t   __doc__t   osRR   t   test_allR    R   R   R   R   t   TestCaseR   RO   RP   RQ   RW   RL   t   main(    (    (    sp   /tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/bsddb/test/test_distributed_transactions.pyt   <module>   s   "r	