+
    nDj                       ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIHt  ^ RIt^ RIt^ RIt^ RIHtHtHtHt ^ RIHt ^ RIHt  ^ RIHt ^ RIH t H!t!H"t"H#t#H$t$H%t%H&t&H't'H(t( ]PT                  P<                  t+R t,R	 t-R
 t.R t/R t0R t1R t2 ! R R]!4      t3 ! R R]!4      t4 ! R R]!4      t5 ! R R]54      t6 ! R R]54      t7 ! R R]54      t8 ! R R]!4      t9 ! R R]!4      t: ! R R ]!4      t; ! R! R"]!4      t< ! R# R$]!4      t= ! R% R&]!4      t> ! R' R(]!4      t? ! R) R*]!4      t@ ! R+ R,]!4      tA ! R- R.]"4      tB ! R/ R0]#4      tC ! R1 R2]"4      tD ! R3 R4]#4      tE ! R5 R6]"4      tFR7 tG ! R8 R9]'4      tH ! R: R;]&4      tI ! R< R=]%4      tJ ! R> R?]$4      tK ! R@ RA]!4      tL ! RB RC]%4      tM ! RD RE]$4      tN ! RF RG]!4      tO ! RH RI]$4      tP ! RJ RK]%4      tQ ! RL RM]!4      tR ! RN RO]!4      tS ! RP RQ]%4      tT ! RR RS]'4      tU ! RT RU]&4      tV ! RV RW]%4      tW ! RX RY]'4      tX ! RZ R[]'4      tY ! R\ R]]&4      tZ ! R^ R_]%4      t[ ! R` Ra]$4      t\ ! Rb Rc]!4      t]Rd t^Re t_Rf t`Rg taRh tb]PT                  P                  ]PT                  P                  Ri 4       4       tdRj teRk tfRl tg]PT                  P                  Rm 4       tiRn tjRo tkRp tlRq tmRr tn ! Rs Rt]!4      toRu tpRv tqRw tr]PT                  P                  ]P                  Rx8H  RyRz7      R{ 4       tu]PT                  P                  R| 4       tvR} twR~ txR tyR tzR t{R t|R t}R t~R tR t]B! RR/R7      t]D! RR/R7      t]PT                  P                  R 4       t]PT                  P                  ]P                  Rx8H  RRz7      R 4       tR tR tR t]J! 4       t]F! 4       tR tR tR tR tR tR tR t]PT                  P                  ]PT                  EP"                  R 4       4       t]PT                  EP"                  R 4       t]PT                  EP"                  R 4       t]PT                  EP"                  R 4       tR tR tR tR t]PT                  P                  R 4       t]PT                  P                  R 4       t]PT                  P                  ]PT                  P                  R 4       4       tR tR tR tR tR tR tR tR t]PT                  EP"                  R 4       tR tR tR tR tR tR t]PT                  EP"                  R 4       t ! R R]!4      t]PT                  P                  R 4       tR t]PT                  EP`                  ]PT                  P                  R 4       4       t]PT                  EP`                  ]PT                  P                  R 4       4       t ! R R]54      tR t]PT                  P                  R 4       tR t ! R R]!4      tR t]PT                  P                  ]EPr                  R8H  RRz7      R 4       tR tR tR t]EP|                  R 4       t]PT                  EP                  RRR.RR7      R 4       tR#   ] d    Rt ELzi ; i  ] d    Rt])])ut t!])])ut"t#])])ut$t%])])ut&t'])t( ELci ; i)    N)datetime)IpcReadOptions	ReadStatsis_opentelemetry_enabledtobytes)find_free_port)util)flight)	FlightClientFlightServerBaseServerAuthHandlerClientAuthHandlerServerMiddlewareServerMiddlewareFactoryClientMiddlewareClientMiddlewareFactoryFlightCallOptionsc                      ^ RI p R# )r   N)pyarrow.flight)pyarrows    S/data/cameron/venvs/s3viz/lib/python3.14/site-packages/pyarrow/tests/test_flight.pytest_importr   C   s        c                     \         P                  P                  R4      '       g   \        R4      h\        P
                  ! \         P                  R,          4      R,          # )z-Get the path to the test resources directory.ARROW_TEST_DATAzITest resources not found; set ARROW_TEST_DATA to <repo root>/testing/datar
   )osenvirongetRuntimeErrorpathlibPath r   r   resource_rootr#   H   sI    ::>>+,, I J 	J<<

#456AAr   c                :   \        4       pV'       g   R#  W,          P                  R4      ;_uu_ 4       pVP                  4       uuRRR4       #   + '       g   i     R# ; i  \         d,    \	        RY,           R\
        P                  ! 4        24      hi ; i)z)Get the contents of a test resource file.NrbzTest resource z< not found; did you initialize the test resource submodule?
)r#   openreadFileNotFoundErrorr   	traceback
format_exc)pathrootfs   &  r   read_flight_resourcer.   P   s    ?D
k%%668 &%%% 
T[M *))2)=)=)?(@B
 	

s(   A$ A
A$ A!	A$ !A$ $6Bc            
         R\        R4      R\        P                  ! \        R4      \        R4      R7      \        P                  ! \        R4      \        R4      R7      ./# )	z'Get the paths to test TLS certificates.	root_certzroot-ca.pemcertificatesz	cert0.pemz	cert0.key)certkeyz	cert1.pemz	cert1.key)r.   r
   CertKeyPairr"   r   r   example_tls_certsr5   _   s_     	)-8)+6(5 )+6(5	
 r   c                  x    \         P                  ! . RO4      .p \         P                  P                  V R.R7      # )
   	some_intsnamesir      r7   )paarrayTablefrom_arrays)datas    r   simple_ints_tablerC   p   s4    
$%D 88[M::r   c                     \         P                  ! . RO\         P                  ! 4       R7      p \         P                  ! . RO\         P                  ! 4       R7      p\         P                  ! \         P                  P                  . ROV 4      \         P                  P                  ^^.V 4      \         P                  P                  ^ ^.V4      .4      .p\         P                  P                  VR.R7      # )footype
some_dictsr9   )rE   bazquux)rE   rI   rJ   new)   r   N)r>   r?   utf8chunked_arrayDictionaryArrayrA   r@   )dict_valuesnew_dict_valuesrB   s      r   simple_dicts_tablerR   w   s    ((1	BKhh<2779MO
**<E**Aq6;?**Aq6?C
 	D 88\N;;r   c                      \         P                  P                  \         P                  ! . RO4      \         P                  ! . RO4      .RR.R7      # )rE   abr9   )rE   barrI   quxrL            )r>   r@   rA   r?   r"   r   r   multiple_column_tabler\      sB    88*F!G!#,!7!9'*Cj   2 2r   c                   J   a a ] tR t^t oRtRtRV 3R lltR tR tRt	Vt
V ;t# )ConstantFlightServerzA Flight server that always returns the same data.

See ARROW-4796: this server implementation will segfault if Flight
does not properly hold a reference to the Table object.
s   the expected criteriac                h   < \         SV `  ! V3/ VB  R \        R\        R\        /V n        W n        R# )   ints   dicts   multiN)super__init__rC   rR   r\   table_factoriesoptions)selflocationrf   kwargs	__class__s   &&&,r   rd   ConstantFlightServer.__init__   s:    ,V, &(+ 

 r   c              #     "   W P                   8X  dN   \        P                  ! \        P                  ! . 4      \        P
                  P                  R 4      . 4      x  R# R# 5i)/fooN)CRITERIAr
   
FlightInfor>   schemaFlightDescriptorfor_pathrg   contextcriterias   &&&r   list_flights!ConstantFlightServer.list_flights   sI     }}$##		"''008  %s   A A"c                    V P                   VP                  ,          ! 4       p\        P                  ! W0P                  R 7      # )rf   )re   ticketr
   RecordBatchStreamrf   )rg   rt   rz   tables   &&& r   do_getConstantFlightServer.do_get   s0     $$V]]35''||DDr   )rf   re   NN)__name__
__module____qualname____firstlineno____doc__rn   rd   rv   r}   __static_attributes____classdictcell____classcell__rj   __classdict__s   @@r   r^   r^      s'      (HE Er   r^   c                   V   a a ] tR t^t oRtRV 3R lltR tR t]R 4       t	Rt
VtV ;t# )MetadataFlightServerz4A Flight server that numbers incoming/outgoing data.c                4   < \         SV `  ! R/ VB  Wn        R # Nr"   rc   rd   rf   rg   rf   ri   rj   s   &&,r   rd   MetadataFlightServer.__init__       "6"r   c                    \         P                  ! . RO4      .p\         P                  P                  VR.R7      p\        P
                  ! VP                  V P                  V4      V P                  R7      # )r7   rT   r9   ry   r;   )	r>   r?   r@   rA   r
   GeneratorStreamrp   number_batchesrf   )rg   rt   rz   rB   r|   s   &&&  r   r}   MetadataFlightServer.do_get   sb    HH()
 $$T#$7%%LL&LL" 	"r   c           	     F   ^ p. ROpVP                   P                  ^8X  g   Q hV F  w  rxVP                  \        P                  P                  \        P                  ! We,          .4      .R.4      4      '       g   Q hVf   Q h\        P                  ! RVP                  4       4      w  p	WY8X  g   Q hVP                  \        P                  ! RV4      4       V^,          pK  	  VP                   P                  ^8X  g   Q hVP                   P                  ^8X  g   Q hR# )r   rT   N<ir;   )statsnum_messagesequalsr>   RecordBatchrA   r?   structunpack
to_pybyteswritepacknum_record_batches)
rg   rt   
descriptorreaderwritercounterexpected_databatchbufclient_counters
   &&&&&     r   do_putMetadataFlightServer.do_put   s    +||((A--- JE<< : :=1234!     ?"?$mmD#..2BCON,,,LLT734qLG ! ||((A---||..!333r   c              #     "   \        V P                  4       4       F!  w  r\        P                  ! R V4      pW#3x  K#  	  R# 5i)r   N)	enumerate
to_batchesr   r   )r|   idxr   r   s   &   r   r   #MetadataFlightServer.number_batches   s7     #E$4$4$67JC++dC(C* 8s   AAry   N)r   r   r   r   r   rd   r}   r   staticmethodr   r   r   r   r   s   @@r   r   r      s0     >"4"   r   r   c                   L   a a ] tR t^t oRtRV 3R lltR tR tR tRt	Vt
V ;t# )EchoFlightServerz4A Flight server that returns the last data uploaded.c                D   < \         SV `  ! V3/ VB  R V n        W n        R # r   )rc   rd   last_messageexpected_schema)rg   rh   r   ri   rj   s   &&&,r   rd   EchoFlightServer.__init__   s#    ,V, .r   c                B    \         P                  ! V P                  4      # r   )r
   r{   r   rg   rt   rz   s   &&&r   r}   EchoFlightServer.do_get   s    ''(9(9::r   c                    V P                   '       d   V P                   VP                  8X  g   Q hVP                  4       V n        R # r   )r   rp   read_allr   rg   rt   r   r   r   s   &&&&&r   r   EchoFlightServer.do_put   s5    ''6==888"OO-r   c                    V F  pK  	  R # r   r"   )rg   rt   r   r   r   chunks   &&&&& r   do_exchangeEchoFlightServer.do_exchange   s    E r   )r   r   r   )r   r   r   r   r   rd   r}   r   r   r   r   r   r   s   @@r   r   r      s!     >/
;.
 r   r   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )EchoStreamFlightServerz6An echo server that streams individual record batches.c                    \         P                  ! V P                  P                  V P                  P	                  R R7      4      # )   max_chunksize)r
   r   r   rp   r   r   s   &&&r   r}   EchoStreamFlightServer.do_get   s;    %%$$((t(<> 	>r   c                    . # r   r"   rg   rt   s   &&r   list_actions#EchoStreamFlightServer.list_actions       	r   c                    VP                   R 8X  d0   VP                  4       VP                  4       P                  R4      .# \        hwho-am-iutf-8rG   peer_identitypeerencodeNotImplementedErrorrg   rt   actions   &&&r   	do_action EchoStreamFlightServer.do_action   9    ;;*$))+W\\^-B-B7-KLL!!r   r"   N
r   r   r   r   r   r}   r   r   r   r   r   s   @r   r   r      s     @>
" "r   r   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )EchoTableStreamFlightServerz,An echo server that streams the whole table.c                n    \         P                  ! V P                  P                  V P                  .4      # r   )r
   r   r   rp   r   s   &&&r   r}   "EchoTableStreamFlightServer.do_get   s0    %%$$! 	!r   c                    . # r   r"   r   s   &&r   r   (EchoTableStreamFlightServer.list_actions  r   r   c                    VP                   R 8X  d0   VP                  4       VP                  4       P                  R4      .# \        hr   r   r   s   &&&r   r   %EchoTableStreamFlightServer.do_action  r   r   r"   Nr   r   s   @r   r   r      s     6!
" "r   r   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )'EchoRecordBatchReaderStreamFlightServeri  zCAn echo server that streams the whole table as a RecordBatchReader.c                    \         P                  ! V P                  P                  V P                  P	                  4       .4      # r   )r
   r   r   rp   	to_readerr   s   &&&r   r}   .EchoRecordBatchReaderStreamFlightServer.do_get  s9    %%$$((*+- 	-r   c                    . # r   r"   r   s   &&r   r   4EchoRecordBatchReaderStreamFlightServer.list_actions  r   r   c                    VP                   R 8X  d0   VP                  4       VP                  4       P                  R4      .# \        hr   r   r   s   &&&r   r   1EchoRecordBatchReaderStreamFlightServer.do_action  r   r   r"   Nr   r   s   @r   r   r     s     M-
" "r   r   c                   0   a  ] tR tRt o RtR tR tRtV tR# )GetInfoFlightServeri  z)A Flight server that tests GetFlightInfo.c                   \         P                  ! \        P                  ! R \        P                  ! 4       3.4      V\         P
                  ! RR.4      \         P
                  ! R\         P                  P                  RR4      .\        P                  ! R4      P                  \        P                  ! R4      4      R4      .^^*RR	4      # )
rT   r   grpc://test	localhost  2023-04-05T12:34:56.789012345nszendpoint app metadataTzinfo app metadata)r
   ro   r>   rp   int32FlightEndpointLocationfor_grpc_tcpscalarcast	timestamprg   rt   r   s   &&&r   get_flight_info#GetInfoFlightServer.get_flight_info   s      IIRXXZ()*%%cM?;%%__11+tDEII=>CCBLLQUDVW+	 
 	
r   c                d    V P                  W4      p\        P                  ! VP                  4      # r   )r  r
   SchemaResultrp   )rg   rt   r   infos   &&& r   
get_schemaGetInfoFlightServer.get_schema3  s'    ##G8""4;;//r   r"   N)	r   r   r   r   r   r  r  r   r   r   s   @r   r   r     s     3
&0 0r   r   c                   :   a  ] tR tRt o Rt]R 4       tR tRtV t	R# )ListActionsFlightServeri8  'A Flight server that tests ListActions.c                6    RR\         P                  ! RR4      .# )action-1zaction-3zmore detail)r  description)zaction-2 r
   
ActionType)clss   &r   expected_actions(ListActionsFlightServer.expected_actions;  s$     (j-8
 	
r   c              #  B   "   V P                  4        R j  xL
  R #  L5ir   )r  r   s   &&r   r   $ListActionsFlightServer.list_actionsC  s     ((***s   r"   N)
r   r   r   r   r   classmethodr  r   r   r   r   s   @r   r	  r	  8  s$     1
 
+ +r   r	  c                   *   a  ] tR tRt o RtR tRtV tR# )ListActionsErrorFlightServeriG  r
  c              #     "   Rx  Rx  R# 5i)r  rE   N)r  r  r"   r   s   &&r   r   )ListActionsErrorFlightServer.list_actionsJ  s     s   r"   N)r   r   r   r   r   r   r   r   r   s   @r   r  r  G  s     1 r   r  c                   F   a a ] tR tRt oRtRV 3R lltR tR tRtVt	V ;t
# )CheckTicketFlightServeriO  zDA Flight server that compares the given ticket to an expected value.c                6   < \         SV `  ! V3/ VB  Wn        R # r   )rc   rd   expected_ticket)rg   r  rh   ri   rj   s   &&&,r   rd    CheckTicketFlightServer.__init__R  s    ,V,.r   c                   V P                   VP                  8X  g   Q h\        P                  ! . RO\        P                  ! 4       R7      .p\        P
                  P                  VR.R7      p\        P                  ! V4      # )r7   rF   rT   r9   r;   )	r  rz   r>   r?   r   r@   rA   r
   r{   )rg   rt   rz   data1r|   s   &&&  r   r}   CheckTicketFlightServer.do_getV  s`    ##v}}444-BHHJ?@$$U3%$8''..r   c                0    VP                  4       V n        R # r   )r   r   )rg   rt   r   r   s   &&&&r   r   CheckTicketFlightServer.do_put\  s    "OO-r   )r  r   r   )r   r   r   r   r   rd   r}   r   r   r   r   r   s   @@r   r  r  O  s     N//. .r   r  c                   r   a  ] tR tRt o Rt]P                  ! R]P                  ! 4       3.4      tR tRt	V t
R# )InvalidStreamFlightServeri`  zEA Flight server that tries to return messages with differing schemas.rT   c                   \         P                  ! . RO\         P                  ! 4       R7      .p\         P                  ! . RO\         P                  ! 4       R7      .pVP                  VP                  8w  g   Q h\         P
                  P                  VR.R7      p\         P
                  P                  VR.R7      pVP                  V P                  8X  g   Q h\        P                  ! V P                  WV.4      # )r7   rF   rT   r9   r;   )g      $g      g              @g      $@)
r>   r?   r   float64rG   r@   rA   rp   r
   r   )rg   rt   rz   r!  data2table1table2s   &&&    r   r}    InvalidStreamFlightServer.do_gete  s    -BHHJ?@7bjjlKLzzUZZ'''%%eC5%9%%eC5%9}}+++%%dkkF3CDDr   r"   Nr   r   r   r   r   r>   rp   r   r}   r   r   r   s   @r   r&  r&  `  s0     OYYbhhj)*+FE Er   r&  c                   r   a  ] tR tRt o Rt]P                  ! R]P                  ! 4       3.4      tR tRt	V t
R# )NeverSendsDataFlightServerip  z0A Flight server that never actually yields data.rT   c                   VP                   R 8X  d   V P                  P                  4       V P                  P                  4       \        P                  P                  \        ^4      .V P                  R7      .p\        P                  ! V P                  V4      # \        P                  ! V P                  \        P                  ! V P                  P                  4       4      4      # )
   yield_datarp   )rz   rp   empty_tabler>   r   rA   ranger
   r   	itertoolsrepeat)rg   rt   rz   rB   s   &&& r   r}   !NeverSendsDataFlightServer.do_getu  s    ==M) '')'')**E!H:dkk*JD
 ))$++t<<%%KK))$++*A*A*CDF 	Fr   r"   Nr.  r   s   @r   r0  r0  p  s0     :YYbhhj)*+FF Fr   r0  c                   @   a  ] tR tRt o RtR tR t]R 4       tRt	V t
R# )SlowFlightServeri  z;A Flight server that delays its responses to test timeouts.c                    \         P                  ! \        P                  ! R \        P                  ! 4       3.4      V P                  4       4      # )rT   )r
   r   r>   rp   r   slow_streamr   s   &&&r   r}   SlowFlightServer.do_get  s:    %%bii#rxxz1B0C&D&*&6&6&8: 	:r   c                2    \         P                  ! R 4       . # )      ?)timesleepr   s   &&&r   r   SlowFlightServer.do_action  s    

3	r   c               #  &  "   \         P                  ! . RO\         P                  ! 4       R7      .p \         P                  P	                  V R.R7      x  \
        P                  ! ^
4       \         P                  P	                  V R.R7      x  R# 5i)r7   rF   rT   r9   Nr;   )r>   r?   r   r@   rA   r@  rA  )r!  s    r   r<  SlowFlightServer.slow_stream  sd     -BHHJ?@hh""5"66 	

2hh""5"66s   BBr"   N)r   r   r   r   r   r}   r   r   r<  r   r   r   s   @r   r:  r:    s&     E: 7 7r   r:  c                   F   a  ] tR tRt o Rt]R 4       tR tR tR t	Rt
V tR# )	ErrorFlightServeri  z9A Flight server that uses all the Flight-specific errors.c                     R \         P                  R\         P                  R\         P                  R\         P                  R\         P
                  R\        R\        P                  R\        /# )internaltimedoutcancelunauthenticatedunauthorizednotimplementedinvalidr3   )
r
   FlightInternalErrorFlightTimedOutErrorFlightCancelledErrorFlightUnauthenticatedErrorFlightUnauthorizedErrorr   r>   ArrowInvalidKeyErrorr"   r   r   error_casesErrorFlightServer.error_cases  sY     2222f11v@@F::1r8	
 		
r   c                    \         P                  4       pVP                  V9   d   W2P                  ,          ! R 4      hVP                  R8X  d   Rp\        P                  ! R V4      h\
        h)rE   protobuf   this is an error message)rF  rV  rG   r
   rS  r   )rg   rt   r   rV  err_msgs   &&&  r   r   ErrorFlightServer.do_action  sX    '335;;+%kk*511[[J&1G00@@!!r   c              #     "   \         P                  ! \        P                  ! . 4      \         P                  P                  R 4      . 4      x  \         P                  ! R4      h5i)rm   rE   )r
   ro   r>   rp   rq   rr   rO  rs   s   &&&r   rv   ErrorFlightServer.list_flights  sM     IIbM##,,V4
 	

 ((//s   A"A$c                   VP                   R 8X  d   \        P                  ! R4      hVP                   R8X  d   \        P                  ! R4      hVP                   R8X  d   \        P                  ! R4      hVP                   R8X  d   \        P
                  ! R4      hVP                   R8X  d   \        P                  ! R4      hVP                   R8X  d   Rp\        P                  ! RV4      hR# )	s   internalrE   s   timedouts   cancels   unauthenticateds   unauthorizeds   protobufrZ  N)commandr
   rO  rP  rQ  rR  rS  )rg   rt   r   r   r   r[  s   &&&&& r   r   ErrorFlightServer.do_put  s    ,,,U33;.,,U339,--e44#5533E::?20077;.1G00@@ /r   r"   N)r   r   r   r   r   r   rV  r   rv   r   r   r   r   s   @r   rF  rF    s0     C

 

"0A Ar   rF  c                   X   a a ] tR tRt oRtR
V 3R lltR tR tR tR t	R t
R	tVtV ;t# )ExchangeFlightServeri  z A server for testing DoExchange.c                4   < \         SV `  ! R/ VB  Wn        R # r   r   r   s   &&,r   rd   ExchangeFlightServer.__init__  r   r   c                   VP                   P                  ^ 8X  g   Q hVP                  \        P                  P
                  8w  d   \        P                  ! R4      hVP                  R8X  d   V P                  WV4      # VP                  R8X  d   V P                  WV4      # VP                  R8X  d   V P                  WV4      # VP                  R8X  d   V P                  WV4      # \        P                  ! RVP                   24      h)r   z!Must provide a command descriptor   echo   get   put	   transformzUnknown command: )r   r   descriptor_typer
   DescriptorTypeCMDr>   rT  r`  exchange_echoexchange_do_getexchange_do_putexchange_transformr   s   &&&&&r   r    ExchangeFlightServer.do_exchange  s    ||((A---%%)>)>)B)BB//"EFF7*%%gv>>6)''@@6)''@@</**7FCC//#J$6$6#78: :r   c                    \         P                  P                  \         P                  ! \	        ^ R4      4      .R.R7      pVP                  VP                  4       VP                  V4       R# )Emulate DoGet with DoExchange.rT   r9   N (  )r>   r@   rA   r?   r5  beginrp   write_table)rg   rt   r   r   rB   s   &&&& r   ro  $ExchangeFlightServer.exchange_do_get  sX    xx##HHU1i()%
 $  	T[[!4 r   c                D   ^ pV FQ  pVP                   '       g   \        P                  ! R4      hVP                  P                  ^ 8w  g   Q hV^,          pKS  	  VP                  P
                  V8X  g   Q hVP                  \        V4      P                  R4      4       R# )Emulate DoPut with DoExchange.zAll chunks must have data.r   N)	rB   r>   rT  r   r   r   write_metadatastrr   )rg   rt   r   r   num_batchesr   s   &&&&  r   rp  $ExchangeFlightServer.exchange_do_put  s    E:::oo&BCC<<,,1111K	 
 ||..+===c+.55g>?r   c                   VP                   P                  ^ 8X  g   Q hRpV EF  pV'       gF   VP                  '       d4   VP                  VP                  P                  V P
                  R7       RpVP                  '       d;   VP                  '       d)   VP                  VP                  VP                  4       K  VP                  '       d   VP                  VP                  4       K  VP                  '       d<   VP                   P                  ^ 8w  g   Q hVP                  VP                  4       EK  Q R4       h	  R# )zRun a simple echo server.Fry   TzShould not happenN)
r   r   rB   rv  rp   rf   app_metadatawrite_with_metadatar{  write_batch)rg   rt   r   r   startedr   s   &&&&  r   rn  "ExchangeFlightServer.exchange_echo  s    ||((A---EuzzzUZZ..E!!!ejjj**5::u7I7IJ###%%e&8&89||00A555""5::.111u r   c                   VP                   P                  ^ 8X  g   Q hVP                   FX  p\        P                  P                  VP                  4      '       d   K4  \        P                  ! R\        V4      ,           4      h	  VP                  4       pVP                   P                  ^ 8w  g   Q h^ .VP                  ,          pV F9  p\        V4       F'  w  rWh;;,          V	P                  4       ,          uu&   K)  	  K;  	  \        P                  P                  \        P                  ! V4      .R.R7      p
VP!                  V
P                  4       VP#                  V
4       R# )zSum rows in an uploaded table.zInvalid field: sumr9   N)r   r   rp   r>   types
is_integerrG   rT  reprr   num_rowsr   as_pyr@   rA   r?   rv  rw  )rg   rt   r   r   fieldr|   sumscolumnrowvalueresults   &&&&       r   rq  'ExchangeFlightServer.exchange_transform  s   ||((A---]]E88&&uzz22oo&7$u+&EFF # !||((A---sU^^#F'/
	U[[]*	 0  %%rxx~&6ug%FV]]#6"r   ry   r   )r   r   r   r   r   rd   r   ro  rp  rn  rq  r   r   r   r   s   @@r   rc  rc    s,     *: !	@2$# #r   rc  c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )HttpBasicServerAuthHandleri  7An example implementation of HTTP basic authentication.c                0   < \         SV `  4        Wn        R # r   rc   rd   credsrg   r  rj   s   &&r   rd   #HttpBasicServerAuthHandler.__init__      
r   c                   VP                  4       p\        P                  P                  V4      pVP                  V P
                  9  d   \        P                  ! R 4      hV P
                  VP                  ,          VP                  8w  d   \        P                  ! R4      hVP                  \        VP                  4      4       R# )unknown userzwrong passwordN)
r'   r
   	BasicAuthdeserializeusernamer  rR  passwordr   r   )rg   outgoingincomingr   auths   &&&  r   authenticate'HttpBasicServerAuthHandler.authenticate  s    mmo++C0==

*33NCC::dmm$5334DEEwt}}-.r   c                    V'       g   \         P                  ! R 4      hWP                  9  d   \         P                  ! R4      hV# )ztoken not providedr  )r
   rR  r  rg   tokens   &&r   is_valid#HttpBasicServerAuthHandler.is_valid&  s7    334HII

"33NCCr   r  r   r   r   r   r   rd   r  r  r   r   r   r   s   @@r   r  r    s     A/ r   r  c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )HttpBasicClientAuthHandleri.  r  c                h   < \         SV `  4        \        P                  ! W4      V n        R V n        R # r   )rc   rd   r
   r  
basic_authr  rg   r  r  rj   s   &&&r   rd   #HttpBasicClientAuthHandler.__init__1  s'     **8>
r   c                    V P                   P                  4       pVP                  V4       VP                  4       V n        R # r   )r  	serializer   r'   r  )rg   r  r  r  s   &&& r   r  'HttpBasicClientAuthHandler.authenticate6  s-    ((*t]]_
r   c                    V P                   # r   r  rg   s   &r   	get_token$HttpBasicClientAuthHandler.get_token;      zzr   )r  r  r   r   r   r   r   rd   r  r  r   r   r   r   s   @@r   r  r  .  s     A
%
 r   r  c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )TokenServerAuthHandleri?  :An example implementation of authentication via handshake.c                0   < \         SV `  4        Wn        R # r   r  r  s   &&r   rd   TokenServerAuthHandler.__init__B  r  r   c                   VP                  4       pVP                  4       pW0P                  9   dG   V P                  V,          V8X  d/   VP                  \        P                  ! R V,           4      4       R# \
        P                  ! R4      h)   secret:zinvalid username/passwordN)r'   r  r   base64	b64encoder
   rR  )rg   r  r  r  r  s   &&&  r   r  #TokenServerAuthHandler.authenticateF  sd    ==?==?zz!djj&:h&FNN6++J,ABC33+- -r   c                    \         P                  ! V4      pVP                  R 4      '       g   \        P                  ! R4      hVR,          # )r  zinvalid token:   NN)r  	b64decode
startswithr
   rR  r  s   &&r   r  TokenServerAuthHandler.is_validO  s>      '
++33ODDRyr   r  r  r   s   @@r   r  r  ?  s     D- r   r  c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )TokenClientAuthHandleriV  r  c                J   < \         SV `  4        Wn        W n        R V n        R# )r   N)rc   rd   r  r  r  r  s   &&&r   rd   TokenClientAuthHandler.__init__Y  s      
r   c                    VP                  V P                  4       VP                  V P                  4       VP                  4       V n        R # r   )r   r  r  r'   r  rg   r  r  s   &&&r   r  #TokenClientAuthHandler.authenticate_  s/    t}}%t}}%]]_
r   c                    V P                   # r   r  r  s   &r   r   TokenClientAuthHandler.get_tokend  r  r   )r  r  r  r  r   s   @@r   r  r  V  s     D%
 r   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )NoopAuthHandlerih  zA no-op auth handler.c                    R# )zDo nothing.Nr"   r  s   &&&r   r  NoopAuthHandler.authenticatek  s    r   c                    R# )z>
Returning an empty string.
Returning None causes Type error.
r  r"   r  s   &&r   r  NoopAuthHandler.is_validn  s    
 r   r"   N)	r   r   r   r   r   r  r  r   r   r   s   @r   r  r  h  s      r   r  c                    V  F9  pVP                  4       VP                  4       8X  g   K(  V P                  V4      u # 	  R# )zXLookup the value of given key in the given headers.
The key lookup is case-insensitive.
N)lowerr   )headers
lookup_keyr3   s   && r   case_insensitive_header_lookupr  v  s4     99;***,,;;s## r   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )!ClientHeaderAuthMiddlewareFactoryi  z@ClientMiddlewareFactory that creates ClientAuthHeaderMiddleware.c                    . V n         R # r   call_credentialr  s   &r   rd   *ClientHeaderAuthMiddlewareFactory.__init__  s
    !r   c                    \        V 4      # r   )ClientHeaderAuthMiddlewarerg   r  s   &&r   
start_call,ClientHeaderAuthMiddlewareFactory.start_call  s    )$//r   c                    Wn         R # r   r  )rg   r  s   &&r   set_call_credential5ClientHeaderAuthMiddlewareFactory.set_call_credential  s    .r   r  N)
r   r   r   r   r   rd   r  r  r   r   r   s   @r   r  r    s     J"0/ /r   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )r  i  a  
ClientMiddleware that extracts the authorization header
from the server.

This is an example of a ClientMiddleware that can extract
the bearer token authorization header from a HTTP header
authentication enabled server.

Parameters
----------
factory : ClientHeaderAuthMiddlewareFactory
    This factory is used to set call credentials if an
    authorization header is found in the headers from the server.
c                    Wn         R # r   factoryrg   r  s   &&r   rd   #ClientHeaderAuthMiddleware.__init__      r   c                    \        VR 4      pV'       d6   V P                  P                  RV^ ,          P                  R4      .4       R# R# )Authorization   authorizationr   N)r  r  r  r   )rg   r  auth_headers   && r   received_headers+ClientHeaderAuthMiddleware.received_headers  sB    4WoNLL,, A%%g..0 1 r   r  N)	r   r   r   r   r   rd   r  r   r   r   s   @r   r  r    s     1 1r   r  c                   *   a  ] tR tRt o RtR tRtV tR# )!HeaderAuthServerMiddlewareFactoryi  z)Validates incoming username and password.c                   \        VR 4      pV^ ,          P                  R4      pRpRpV^ ,          R8X  ds   \        P                  ! V^,          4      pVP	                  R4      P                  R4      pV^ ,          R8X  d   V^,          R8X  g   \
        P                  ! V4      hR	pMKV^ ,          R
8X  d(   V^,          pVR	8X  g   \
        P                  ! V4      hM\
        P                  ! V4      h\        V4      # )r   r  zInvalid credentialsBasicr   :testr  	token1234Bearer)r  splitr  r  decoder
   rR  HeaderAuthServerMiddleware)	rg   r  r  r  valuesr  error_messagedecodedpairs	   &&&      r   r  ,HeaderAuthServerMiddlewareFactory.start_call  s    4
 Q%%c*-!9&&vay1G>>'*005DGv%$q'Z*?77FFEAY("1IEK'77FF ( 33MBB)%00r   r"   Nr   r   r   r   r   r  r   r   r   s   @r   r  r    s     31 1r   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )r  i  zBA ServerMiddleware that transports incoming username and password.c                    Wn         R # r   r  r  s   &&r   rd   #HeaderAuthServerMiddleware.__init__  s    
r   c                ,    R RV P                   ,           /# )authorizationzBearer r  r  s   &r   sending_headers*HeaderAuthServerMiddleware.sending_headers  s    TZZ!788r   r  N	r   r   r   r   r   rd   r  r   r   r   s   @r   r  r    s     L9 9r   r  c                   *   a  ] tR tRt o RtR tRtV tR# )HeaderAuthFlightServeri  z<A Flight server that tests with basic token authentication. c                    VP                  R 4      pV'       dE   \        VP                  4       R4      pVP                  R4      pV^,          P	                  R4      .# \
        P                  ! R4      h)r  r  r  r   zNo token auth middleware found.)get_middlewarer  r  r  r   r
   rR  )rg   rt   r   
middlewarer  r  s   &&&   r   r    HeaderAuthFlightServer.do_action  sk    ++F3
8**,o?K &&s+F1I$$W-..//-/ 	/r   r"   Nr   r   r   r   r   r   r   r   r   s   @r   r  r    s     F/ /r   r  c                   *   a  ] tR tRt o RtR tRtV tR# )'ArbitraryHeadersServerMiddlewareFactoryi  z<A ServerMiddlewareFactory that transports arbitrary headers.c                    \        V4      # r   ) ArbitraryHeadersServerMiddlewarerg   r  r  s   &&&r   r  2ArbitraryHeadersServerMiddlewareFactory.start_call  s    /88r   r"   Nr  r   s   @r   r  r    s     F9 9r   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )r   i  z5A ServerMiddleware that transports arbitrary headers.c                    Wn         R # r   r  )rg   r  s   &&r   rd   )ArbitraryHeadersServerMiddleware.__init__  s     r   c                    V P                   # r   r%  r  s   &r   r  0ArbitraryHeadersServerMiddleware.sending_headers      }}r   r%  Nr  r   s   @r   r   r     s     ?! r   r   c                   *   a  ] tR tRt o RtR tRtV tR# )ArbitraryHeadersFlightServeri  z6A Flight server that tests multiple arbitrary headers.c                   VP                  R 4      pV'       d\   VP                  4       p\        VR4      p\        VR4      pV^ ,          P                  R4      pV^ ,          P                  R4      pWx.# \        P
                  ! R4      h)arbitrary-headersztest-header-1ztest-header-2r   zNo headers middleware found)r  r  r  r   r
   FlightServerError)	rg   rt   r   r  r  header_1header_2value1value2s	   &&&      r   r   &ArbitraryHeadersFlightServer.do_action  s    ++,?@
 002G5H 6H a[''0Fa[''0F##&&'DEEr   r"   Nr  r   s   @r   r+  r+    s     @F Fr   r+  c                   *   a  ] tR tRt o RtR tRtV tR# )HeaderServerMiddlewarei  z/Expose a per-call value to the RPC method body.c                    Wn         R # r   special_value)rg   r8  s   &&r   rd   HeaderServerMiddleware.__init__  s    *r   r7  N)r   r   r   r   r   rd   r   r   r   s   @r   r5  r5    s     9+ +r   r5  c                   *   a  ] tR tRt o RtR tRtV tR# )HeaderServerMiddlewareFactoryi  z:Expose a per-call hard-coded value to the RPC method body.c                    \        R 4      # )zright value)r5  r!  s   &&&r   r  (HeaderServerMiddlewareFactory.start_call  s    %m44r   r"   Nr  r   s   @r   r;  r;    s     D5 5r   r;  c                   *   a  ] tR tRt o RtR tRtV tR# )HeaderFlightServeri  z(Echo back the per-call hard-coded value.c                p    VP                  R 4      pV'       d   VP                  P                  4       .# R.# )r  r   )r  r8  r   )rg   rt   r   r  s   &&& r   r   HeaderFlightServer.do_action  s4    ++F3
,,33566ur   r"   Nr  r   s   @r   r?  r?    s     2 r   r?  c                   *   a  ] tR tRt o RtR tRtV tR# )MultiHeaderFlightServeri  8Test sending/receiving multiple (binary-valued) headers.c                r    VP                  R 4      p\        VP                  4      P                  R4      pV.# )r  r   )r  r  client_headersr   )rg   rt   r   r  r  s   &&&  r   r   !MultiHeaderFlightServer.do_action  s5    ++F3
z00188Ayr   r"   Nr  r   s   @r   rC  rC    s     B r   rC  c                   *   a  ] tR tRt o RtR tRtV tR# )$SelectiveAuthServerMiddlewareFactoryi"  z1Deny access to certain methods based on a header.c                   VP                   \        P                  P                  8X  d   R # VP	                  R4      pV'       g   \        P
                  ! R4      hV^ ,          pVR8w  d   \        P
                  ! R4      h\        V4      # )Nx-auth-tokenzNo tokenr  zInvalid token)methodr
   FlightMethodLIST_ACTIONSr   rR  r5  )rg   r  r  r  s   &&& r   r  /SelectiveAuthServerMiddlewareFactory.start_call%  sl    ;;&--:::N+33J??aJ33ODD%e,,r   r"   Nr  r   s   @r   rI  rI  "  s     ;- -r   rI  c                   &   a  ] tR tRt o R tRtV tR# )$SelectiveAuthClientMiddlewareFactoryi5  c                    \        4       # r   )SelectiveAuthClientMiddlewarer  s   &&r   r  /SelectiveAuthClientMiddlewareFactory.start_call6  s    ,..r   r"   N)r   r   r   r   r  r   r   r   s   @r   rQ  rQ  5  s     / /r   rQ  c                   &   a  ] tR tRt o R tRtV tR# )rS  i:  c                
    R R/# )rK  r  r"   r  s   &r   r  -SelectiveAuthClientMiddleware.sending_headers;  s    J
 	
r   r"   N)r   r   r   r   r  r   r   r   s   @r   rS  rS  :  s     
 
r   rS  c                   <   a a ] tR tRt oRtV 3R ltR tRtVtV ;t	# ) RecordingServerMiddlewareFactoryiA   Record what methods were called.c                2   < \         SV `  4        . V n        R # r   rc   rd   methodsrg   rj   s   &r   rd   )RecordingServerMiddlewareFactory.__init__D      r   c                P    V P                   P                  VP                  4       R # r   r]  appendrL  r!  s   &&&r   r  +RecordingServerMiddlewareFactory.start_callH      DKK(r   r]  
r   r   r   r   r   rd   r  r   r   r   r   s   @@r   rY  rY  A       * r   rY  c                   <   a a ] tR tRt oRtV 3R ltR tRtVtV ;t	# ) RecordingClientMiddlewareFactoryiM  rZ  c                2   < \         SV `  4        . V n        R # r   r\  r^  s   &r   rd   )RecordingClientMiddlewareFactory.__init__P  r`  r   c                P    V P                   P                  VP                  4       R # r   rb  r  s   &&r   r  +RecordingClientMiddlewareFactory.start_callT  re  r   rf  rg  r   s   @@r   rj  rj  M  rh  r   rj  c                   0   a  ] tR tRt o RtR tR tRtV tR# )"MultiHeaderClientMiddlewareFactoryiY  rD  c                    / V n         R # r   last_headersr  s   &r   rd   +MultiHeaderClientMiddlewareFactory.__init__\  s     r   c                    \        V 4      # r   )MultiHeaderClientMiddlewarer  s   &&r   r  -MultiHeaderClientMiddlewareFactory.start_calla  s    *400r   rr  N)	r   r   r   r   r   rd   r  r   r   r   s   @r   rp  rp  Y  s     B
1 1r   rp  c                   V   a  ] tR tRt o RtRRR.RRR.R	R
.RR
./tR tR tR tRt	V t
R# )rv  ie  rD  zx-textrE   rV   zx-binary-bin       zx-MIXED-caserI   s   x-other-MIXED-casec                    Wn         R # r   r  r  s   &&r   rd   $MultiHeaderClientMiddleware.__init__p  r  r   c                    V P                   # r   )EXPECTEDr  s   &r   r  +MultiHeaderClientMiddleware.sending_headerss  r)  r   c                P    V P                   P                  P                  V4       R # r   )r  rs  update)rg   r  s   &&r   r  ,MultiHeaderClientMiddleware.received_headersv  s     	!!((1r   r  N)r   r   r   r   r   r~  rd   r  r  r   r   r   s   @r   rv  rv  e  sF     B 	5%.'*wH2 2r   rv  c                   *   a  ] tR tRt o RtR tRtV tR# )"MultiHeaderServerMiddlewareFactoryi|  rD  c                    \        V4      # r   )MultiHeaderServerMiddlewarer!  s   &&&r   r  -MultiHeaderServerMiddlewareFactory.start_call  s    *733r   r"   Nr  r   s   @r   r  r  |  s     B4 4r   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )r  i  rD  c                    Wn         R # r   rF  )rg   rF  s   &&r   rd   $MultiHeaderServerMiddleware.__init__  s    ,r   c                "    \         P                  # r   )rv  r~  r  s   &r   r  +MultiHeaderServerMiddleware.sending_headers  s    *333r   r  Nr  r   s   @r   r  r    s     B-4 4r   r  c                   B   a a ] tR tRt oRtV 3R ltR tR tRtVt	V ;t
# )LargeMetadataFlightServeri  z Regression test for ARROW-13253.c                D   < \         SV `  ! V/ VB  R R,          V n        R# )    N       )rc   rd   	_metadata)rg   argsri   rj   s   &*,r   rd   "LargeMetadataFlightServer.__init__  s!    $)&)-r   c                    \         P                  ! R \         P                  ! 4       3.4      p\        P                  ! V\         P
                  ! ^..VR7      V P                  3.4      # )rT   r3  )r>   rp   int64r
   r   record_batchr  )rg   rt   rz   rp   s   &&& r   r}    LargeMetadataFlightServer.do_get  sS    S"((*-./%%f__qcU62DNNC/
  	r   c                <    VP                  V P                  4       R # r   )r{  r  r   s   &&&&&r   r   %LargeMetadataFlightServer.do_exchange  s    dnn-r   )r  )r   r   r   r   r   rd   r}   r   r   r   r   r   s   @@r   r  r    s     *.. .r   r  c                  ,
   R p RpRpRpRpRpRpRpRpR	p	\        \        P                  ! R
R4      4      V 8X  g   Q h\        \        P                  ! R
R4      4      V8X  g   Q h\        \        P                  ! RR4      4      V8X  g   Q h\        \        P
                  P                  R
4      4      V8X  g   Q h\        P                  ! R. \        P                  ! R4      P                  \        P                  ! R4      4      R4      p
\        V
4      V8X  g   Q h\        P                  ! \        P                  ! . 4      \        P
                  P                  4       . ^^*RR4      p\        V4      V8X  g   Q h\        \        P                  ! R4      4      V8X  g   Q h\        \        P                   ! R4      4      V8X  g   Q h\        \        P"                  ! \        P                  ! . 4      4      4      V8X  g   Q h\        \        P"                  ! \        P                  ! R.4      4      4      R8X  g   Q h\        \        P$                  ! R4      4      V	8X  g   Q hVP                  \        P                  ! . 4      8X  g   Q h\        P                  ! R\        P
                  P                  4       . ^^*RR4      pRp\        V4      V8X  g   Q hVP                  e   Q h\&        P(                  ! \*        4      ;_uu_ 4        \        P                  ! R
R4       RRR4       \&        P(                  ! \*        4      ;_uu_ 4        \        P                  ! \-        4       . 4       RRR4       \&        P(                  ! \*        4      ;_uu_ 4        \        P                  ! R
RR\-        4       .4       RRR4       \&        P(                  ! \*        4      ;_uu_ 4        \        P                  ! R
. RR7       RRR4       \&        P(                  ! \*        4      ;_uu_ 4        \        P                  ! R
. \/        R^^^^^4      R7       RRR4       \&        P(                  ! \*        4      ;_uu_ 4        \        P                  ! R
. \-        4       R7       RRR4       R#   + '       g   i     EL; i  + '       g   i     ELV; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i) z1<pyarrow.flight.Action type='foo' body=(0 bytes)>z)ActionType(type='foo', description='bar')z?<pyarrow.flight.BasicAuth username=b'user' password=(redacted)>z,<pyarrow.flight.FlightDescriptor cmd=b'foo'>z<pyarrow.flight.FlightEndpoint ticket=<pyarrow.flight.Ticket ticket=b'foo'> locations=[] expiration_time=2023-04-05 12:34:56+00:00 app_metadata=b'endpoint app metadata'>z<pyarrow.flight.FlightInfo schema= descriptor=<pyarrow.flight.FlightDescriptor path=[]> endpoints=[] total_records=1 total_bytes=42 ordered=True app_metadata=b'test app metadata'>z6<pyarrow.flight.Location b'grpc+tcp://localhost:1234'>z&<pyarrow.flight.Result body=(3 bytes)>z'<pyarrow.flight.SchemaResult schema=()>z%<pyarrow.flight.Ticket ticket=b'foo'>rE   r   rV   userpass   foo2023-04-05T12:34:56s   endpoint app metadataT   test app metadatagrpc+tcp://localhost:1234z1<pyarrow.flight.SchemaResult schema=(int: int64)>Nz<pyarrow.flight.FlightInfo schema=None descriptor=<pyarrow.flight.FlightDescriptor path=[]> endpoints=[] total_records=1 total_bytes=42 ordered=True app_metadata=b'test app metadata'>r   s   grpc://testz2023-04-05T01:02:03)expiration_timei  r  )intr  )r  r
   Actionr  r  rq   for_commandr   r>   r   r   r   ro   rp   rr   r   Resultr  Ticketpytestraises	TypeErrorobjectr   )action_repraction_type_reprbasic_auth_reprdescriptor_reprendpoint_repr	info_reprlocation_reprresult_reprschema_result_reprticket_reprendpointr  s               r   	test_reprr    s   EKBWODO>M	-  MM:KB9KeS)*k999!!%/04DDDD  01_DDD''33E:;NNN$$BII3499",,s:KL H >]***
		"v..7792	2t)D :""" ;<=NNNf%&+555##BIIbM237IIII##BII/?.@$ABC;< < <f%&+555;;"))B-'''f%%..0"	2t)D
	-  :""";;	y	!	!eT" 
" 
y	!	!fh+ 
"	y	!	!em^VX%NO 
"	y	!	!eR9NO 
"	y	!	!eR$1aQRTU9VW 
"	y	!	!eRfh? 
"	! 
"	!	! 
"	!	!	!	!	!	!	!	!	!	!	!	!sH   R  R4#SS"(S/4"T R1	4S	S	S,	/S?	T	c                     R  R R R R R R R R R	 R
 R R R R R R R R R R .p V  FM  pV! 4       w  r#V! 4       w  rEW"8X  g   Q hW$8X  g   Q hWB8X  g   Q hW38X  g   Q hW58X  g   Q hWS8X  g   Q hW#8w  d   KM  Q h	  R# )c                  ^    \         P                  ! R R4      \         P                  ! RR4      3# )rE   r   rV   r
   r  r"   r   r   <lambda>test_eq.<locals>.<lambda>  s    uc*FMM%,EFr   c                  ^    \         P                  ! R R4      \         P                  ! R R4      3# )rE   r      barr  r"   r   r   r  r    s    uc*FMM%,HIr   c                  ^    \         P                  ! R R4      \         P                  ! R R4      3# )rE   rV   rI   r  r"   r   r   r  r    s&    ""5%0""5%02r   c                  ^    \         P                  ! R R4      \         P                  ! RR4      3# )r  r  user2r
   r  r"   r   r   r  r    s&    !!&&1!!'624r   c                  ^    \         P                  ! R R4      \         P                  ! R R4      3# )r  r  pass2r  r"   r   r   r  r    s&    !!&&1!!&'24r   c                  ~    \         P                  P                  R 4      \         P                  P                  R 4      3# )rE   )r
   rq   r  rr   r"   r   r   r  r    s.    ((44U;((11%8:r   c                  ^    \         P                  ! R . 4      \         P                  ! R. 4      3# r  r  r
   r   r"   r   r   r  r    s&    &&vr2&&vr24r   c                      \         P                  ! R \         P                  ! R4      .4      \         P                  ! R \         P                  ! R4      .4      3# )r  r  grpc+tls://localhost:1234)r
   r   r   r"   r   r   r  r    sI    !!)DEFH!!)DEFH
r   c            
      >   \         P                  ! R . \        P                  ! R4      P	                  \        P
                  ! R4      4      4      \         P                  ! R . \        P                  ! R4      P	                  \        P
                  ! R4      4      4      3# )r  r  r  z2023-04-05T12:34:56.789ms)r
   r   r>   r   r   r   r"   r   r   r  r    sq    !!BII&;<AA",,sBSTV!!		3499",,t:LMOPr   c                  f    \         P                  ! R . RR7      \         P                  ! R . RR7      3# )r  r   r     metar  r"   r   r   r  r    s+    &&vrD&&vrHJr   c                  N   \         P                  ! \        P                  ! . 4      \         P                  P                  4       . 4      \         P                  ! \        P                  ! R \        P                  ! 4       3.4      \         P                  P                  4       . 4      3# ints)r
   ro   r>   rp   rq   rr   r  r"   r   r   r  r    sr    		"''002B8 		FBHHJ/01''002B8	9r   c                  $   \         P                  ! \        P                  ! . 4      \         P                  P                  4       . 4      \         P                  ! \        P                  ! . 4      \         P                  P                  R 4      . 4      3# )r  )r
   ro   r>   rp   rq   rr   r  r"   r   r   r  r    sg    		"''002B8 		"''33F;RA	Br   c            	      z   \         P                  ! \        P                  ! . 4      \         P                  P                  4       \         P                  ! R . 4      .4      \         P                  ! \        P                  ! . 4      \         P                  P                  4       \         P                  ! R. 4      .4      3# r  )r
   ro   r>   rp   rq   rr   r   r"   r   r   r  r    s    		"''002&&vr235 		"''002&&vr2356r   c                  *   \         P                  ! \        P                  ! . 4      \         P                  P                  4       . RR7      \         P                  ! \        P                  ! . 4      \         P                  P                  4       . ^R7      3# )rL   )total_recordsr
   ro   r>   rp   rq   rr   r"   r   r   r  r    sj    		"''002BbJ 		"''002BaI	Jr   c                  *   \         P                  ! \        P                  ! . 4      \         P                  P                  4       . RR7      \         P                  ! \        P                  ! . 4      \         P                  P                  4       . ^*R7      3# )rL   )total_bytesr  r  r"   r   r   r  r  %  sj    		"''002BBH 		"''002BBH	Ir   c                  *   \         P                  ! \        P                  ! . 4      \         P                  P                  4       . R R7      \         P                  ! \        P                  ! . 4      \         P                  P                  4       . RR7      3# )F)orderedTr  r"   r   r   r  r  ,  sj    		"''002BG 		"''002BF	Gr   c                  *   \         P                  ! \        P                  ! . 4      \         P                  P                  4       . R R7      \         P                  ! \        P                  ! . 4      \         P                  P                  4       . RR7      3# )r   r  r  r  r"   r   r   r  r  3  sj    		"''002BSJ 		"''002BWN	Or   c                  Z    \         P                  ! R 4      \         P                  ! R4      3# )r  r  )r
   r   r"   r   r   r  r  :  s     !<=!<=?r   c                  Z    \         P                  ! R 4      \         P                  ! R4      3# r  )r
   r  r"   r   r   r  r  <  s    v&f(=>r   c                      \         P                  ! \        P                  ! . 4      4      \         P                  ! \        P                  ! R \        P                  ! 4       3.4      4      3# r  )r
   r  r>   rp   r  r"   r   r   r  r  =  sB    $$RYYr]3$$RYY0D/E%FGIr   c                  Z    \         P                  ! R 4      \         P                  ! R4      3# )r   r  )r
   r  r"   r   r   r  r  ?  s    s#V]]6%:;r   Nr"   )itemsgenlhs1rhs1lhs2rhs2s         r   test_eqr    s    FI	2	4	4	:	4	
	P	J	9	B	6	J	I	G	O	?>	I;gTEl U
U
|||||||||||||| r   c                     \         P                  ! \        P                  ! . 4      \         P                  P                  4       . 4      p \         P                  ! \        P                  ! . 4      \         P                  P                  4       . RRR7      p\         P                  ! \        P                  ! . 4      \         P                  P                  4       . RRR7      pV P                  R8X  g   Q hVP                  R8X  g   Q hVP                  R8X  g   Q hV P                  R8X  g   Q hVP                  R8X  g   Q hVP                  R8X  g   Q hR# )rL   )r  r  Nr  )r
   ro   r>   rp   rq   rr   r  r  )fi1fi2fi3s      r   test_flight_info_defaultsr  N  s   


BIIbM6+B+B+K+K+Mr
RC



		"((*BbbRC 


		"((*BdPTVC """""""""??b   ??b   ??b   r   c                      R RR\        4       3.p V  F8  p\        V4      ;_uu_ 4       p\        V\        4      '       g   Q h R R R 4       K:  	  R #   + '       g   i     KO  ; i)Ngrpc://localhost:0r   )r   r   
isinstance)	locationsrh   servers      r   $test_flight_server_location_argumentr  `  sY    	n&'I
 h''6f&67777 (' '''s   AA!c            	          \         P                  ! \        4      ;_uu_ 4        \        4       ;_uu_ 4        \        4       h  + '       g   i     M; i R R R 4       R #   + '       g   i     R # ; ir   )r  r  
ValueErrorr   r"   r   r   #test_server_exit_reraises_exceptionr  k  s=    	z	"	",   
#	"	"	"s   AA	AAA0	c                  z  a R \        4       3oRp V3R lp\        S4      ;_uu_ 4       p\        P                  ! VRR7      pVP	                  4        \
        P
                  ! 4       pVP                  ^R7       \
        P
                  ! 4       V,
          pVR8  g   Q h RRR4       R#   + '       g   i     R# ; i)r   Nc                  r   < \         P                  ! R 4       \        S 4      s\        P	                  4        R# r?  N)r@  rA  r   r  serverh   s   r   r  -test_client_wait_for_available.<locals>.servew  s!    

3!(+r   Ttargetdaemontimeoutr?  )r   r   	threadingThreadstartr@  wait_for_available)r  r  clientthreadr  elapsedrh   s         @r   test_client_wait_for_availabler  q  s     ^-.HF 
h		6!!t<))+!!!!,))+'#~~ 
 			s   A5B))B:	c            	        \        4       ;_uu_ 4       p \        P                  ! RV P                  34      ;_uu_ 4       p\	        VP                  4       4      . 8X  g   Q hVP                  \         P                  4      p\        \	        V4      4      ^8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)zTry a simple list_flights call.r   N)r^   r
   connectportlistrv   rn   len)r  r	  flightss      r   test_flight_list_flightsr    s    			6NNK566&F'')*b000%%&:&C&CD4=!Q&&& 7 
 	66 
 		s#   +B?AB,	B?,B<7B??C	c                  2   \        4       ;_uu_ 4       p \        P                  ! R V P                  34      ;_uu_ 4       p\	        VP                  4       4      . 8X  g   Q hVP                  4        VP                  4        \        P                  ! \        P                  4      ;_uu_ 4        \	        VP                  4       4       RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)r   N)r^   r
   r  r  r  rv   closer  r  r>   rT  r  r	  s     r   test_flight_client_closer    s    			6NNK566&F'')*b000]]2??++$$&' ,	 7 
 	
 ,+	 76 
 		s;   +DA-C2	+CC2	DC/*C2	2D=DD	c                 H   \        4       p \        4       ;_uu_ 4       p\        P                  ! RVP                  34      ;_uu_ 4       pVP                  \        P                  ! R4      4      P                  4       pVP                  V 4      '       g   Q h RRR4       RRR4       \        P                  P                  \        P                  P                  P                  R7      p\        VR7      ;_uu_ 4       p\        P                  ! RVP                  34      ;_uu_ 4       pVP                  \        P                  ! R4      4      P                  4       pVP                  V 4      '       g   Q hVP                  \        P                  ! R4      4      P                  4       P                  4       pVP                  V 4      '       g   Q h RRR4       RRR4       \        P                   ! \        P"                  RR7      ;_uu_ 4        \        ^*R7      ;_uu_ 4       p\        P                  ! RVP                  34      ;_uu_ 4       pVP                  \        P                  ! R4      4      P                  4       pRRR4       RRR4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     EL; i  + '       g   i     Lq; i  + '       g   i     L|; i  + '       g   i     R# ; i)Try a simple do_get call.r   r`   Nmetadata_versionry   z+expected IpcWriteOptions, got <class 'int'>match)rC   r^   r
   r  r  r}   r  r   r   r>   ipcIpcWriteOptionsMetadataVersionV4r   r  r  r.  )r|   r  r	  rB   rf   s        r   test_flight_do_get_intsr"    s   E			6NNK566&}}V]]734==?{{5!!!! 7 
 
 ff$$//22 % 4G	g	.	.&NNK566&}}V]]734==?{{5!!!! }}V]]734>>@IIK{{5!!!! 7 
/ 
v//J
L 
L!"--V[[9::f==w!78AACD ; .
L 
L 766 
 		 76 
/	.	. ;: .-
L 
L 
Ls   +J/AJ	J/<+K'B$K	K	KL"+K=	4K*K=		LJ,&	J//K 	KKK'	*K:5K=	=LLL!	c            	        \        4       p \        4       ;_uu_ 4       p\        P                  ! RVP                  34      ;_uu_ 4       pVP                  \        P                  ! R4      4      P                  4       p\        VR,          4      V P                  ^ 4      P                  4       8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r  r   r`   r8   N)rC   r^   r
   r  r  r}   r  read_pandasr  r  	to_pylist)r|   r  r	  rB   s       r   test_do_get_ints_pandasr&    s     E			6NNK566&}}V]]734@@BD%&%,,q/*C*C*EEEE 7 
 	66 
 		s$   +CA*C	3CCCC)	c                     \        4       p \        4       ;_uu_ 4       p\        P                  ! R VP                  34      ;_uu_ 4       pVP                  \        P                  ! R4      4      pVP                  P                  ^8X  g   Q hVP                  4       pVP                  V 4      '       g   Q hVP                  \        ^^^^ ^R7      8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r   ra   r   r   num_dictionary_batchesnum_dictionary_deltasnum_replaced_dictionariesN)rR   r^   r
   r  r  r}   r  r   r   r   r   r   )r|   r  r	  r   rB   s        r   test_flight_do_get_dictsr,    s     E			6NNK566&v}}X67||((A--- {{5!!!!||y #$"#&' 
 
 	
 
 7 
 	66 
 		s*   +C;A)C(	2#C(	C;(C83C;;D	c            	     .   \         P                  ! . RO\         P                  ! 4       R7      .p \         P                  P	                  V R.R7      p\        RR7      ;_uu_ 4       p\        P                  ! RVP                  34      ;_uu_ 4       pVP                  \        P                  ! R4      4      P                  4       pVP                  V4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	z+Make sure Tickets get passed to the server.rF   rT   r9   s
   the-ticket)r  r   Nr;   )r>   r?   r   r@   rA   r  r
   r  r  r}   r  r   r   )r!  r|   r  r	  rB   s        r   test_flight_do_get_ticketr.    s    XX)
;<EHH  se 4E	 	?	?6NNK566&}}V]]=9:CCE{{5!!!! 7 
@	?66 
@	?	?s%   %+DAC0	D0D ;DD	c            	     0   \        4       ;_uu_ 4       p \        RV P                  34      pVP                  \        P
                  P                  R4      4      pVP                  ^8X  g   Q hVP                  ^*8X  g   Q hVP                  '       g   Q hVP                  R8X  g   Q hVP                  \        P                  ! R\        P                  ! 4       3.4      8X  g   Q h\        VP                  4      ^8X  g   Q h\        VP                  ^ ,          P                   4      ^8X  g   Q hVP                  ^ ,          P"                  e   Q hVP                  ^ ,          P                  R8X  g   Q hVP                  ^ ,          P                   ^ ,          \        P$                  ! R4      8X  g   Q hVP                  ^,          P"                  \        P&                  ! R4      P)                  \        P*                  ! RR	4      4      8X  g   Q hVP                  ^,          P                  R
8X  g   Q hVP                  ^,          P                   ^ ,          \        P$                  P-                  RR4      8X  g   Q h RRR4       R#   + '       g   i     R# ; i)z8Make sure FlightEndpoint accepts string and object URIs.r   r   s   info app metadatarT   Nr   z#2023-04-05T12:34:56.789012345+00:00r   UTCr  r   )r   r   r  r  r
   rq   r  r  r  r  r  rp   r>   r   r  	endpointsr  r  r   r   r   r   r   r  r	  r  s      r   test_flight_get_infor3    s   			&{FKK89%%f&=&=&I&I#&NO!!Q&&&2%%%||||  $8888{{bii#rxxz):(;<<<<4>>"a'''4>>!$../1444~~a 00888~~a --444~~a **1-1OOOO~~a 00II;<tBLLu-./ 	/ / ~~a --1IIII~~a **1-OO((d;< 	< <# 
			s   A=JG(JJ	c            
        \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       pVP                  \        P
                  P                  R4      4      pVP                  \        P                  ! R\        P                  ! 4       3.4      8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z+Make sure GetSchema returns correct schema.r   r   rT   N)
r   r   r  r  r
   rq   r  rp   r>   r   r2  s      r   test_flight_get_schemar5    s    			&+v{{344  !8!8!D!DS!IJ{{bii#rxxz):(;<<<< 5 
	44 
		s#    CA,B2	 C2C=CC	c                    \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P                  ! \
        P                  RR7      ;_uu_ 4        \        VP                  4       4       RRR4       RRR4       RRR4       \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        VP                  4       4      \        P                  4       8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     LS; i  + '       g   i     R# ; i)z6Make sure the return type of ListActions is validated.r   z3Results of list_actions must be ActionType or tupler  N)r  r   r  r  r  r
   r.  r  r   r	  r  r  s     r   test_list_actionsr7    s     
&	'	'6+v{{344]]((-
 

 $$&'
 5 
( 
!	"	"f+v{{344F'')*#4467 	7 7 5 
#	"
 
 54 
(	' 54 
#	"	"s^    D2/D	"D<D	D2& E3E	:EDD	D/*D22E	EEE)	c                   :   a  ] tR tRt o Rt]R 4       tR tRtV t	R# )ConvenienceServeri  zL
Server for testing various implementation conveniences (auto-boxing, etc.)
c                
    . RO# )r  )r  r  s   bazr"   r  s   &r   simple_action_results'ConvenienceServer.simple_action_results  s    ''r   c                .  a VP                   R 8X  d   V P                  # VP                   R8X  d   VP                  .# VP                   R8X  d   R.# VP                   R8X  d   \        P                  ! 4       hVP                   R8X  d   V3R lpV! 4       # R# )simple-actionecho
bad-actionrE   arrow-exceptionforeverc               3   H   <"   S P                  4       '       g   R x  K  R# 5i)r  N)is_cancelled)rt   s   r   r  (ConvenienceServer.do_action.<locals>.gen   s     !..00 L 1s   ""N)rG   r;  bodyr>   ArrowMemoryError)rg   rt   r   r  s   &f& r   r   ConvenienceServer.do_action  s    ;;/)---[[F"KK= [[L(7N[[--%%''[[I%! 5L	 &r   r"   N)
r   r   r   r   r   propertyr;  r   r   r   r   s   @r   r9  r9    s(      ( ( r   r9  c            	         \        4       ;_uu_ 4       p \        R V P                  34      ;_uu_ 4       pVP                  R4       Uu. uF  q"P                  NK  	  ppW0P
                  8X  g   Q hRpVP                  RV34       Uu. uF  q"P                  NK  	  ppW4.8X  g   Q h RRR4       RRR4       R# u upi u upi   + '       g   i     L$; i  + '       g   i     R# ; i)r   r>  s   the-bodyr?  N)r9  r   r  r   rF  r;  )r  r	  xresultsrF  s        r   !test_do_action_result_conveniencerM  &  s    			+v{{344 $*#3#3O#DE#Da66#DE66666 #)#3#3VTN#CD#Ca66#CD&    5 
	 F
 E 54 
		s@    CC	B8+C	B=C	&C8
C	CCC&	c                  j   \        4       ;_uu_ 4       p \        R V P                  34      ;_uu_ 4       p\        P                  ! \
        P                  RR7      ;_uu_ 4        \        VP                  R4      4       RRR4       \        P                  ! \
        P                  RR7      ;_uu_ 4        \        VP                  R4      4       RRR4       RRR4       RRR4       R#   + '       g   i     Ls; i  + '       g   i     L5; i  + '       g   i     L@; i  + '       g   i     R# ; i)r   za bytes-like object is requiredr  r@  NrG  rA  )	r9  r   r  r  r  r
   r.  r  r   r  s     r   test_nicer_server_exceptionsrO  4  s    			+v{{344]]633!BD D!!,/0D ]]633!35 5!!"3455 5 
	D D5 5 54 
		sR    D!/D	"C(=6D	3C;D	D!(C83D	;DD	DD!!D2	c                     \        R4      p  V P                  ^ 8  g   Q h V P                  4        R#   T P                  4        i ; i)zMake sure port() works.r  N)r   r  shutdown)r  s    r   test_get_portrR  C  s7     !56F{{Qs	   3 Antz'Unix sockets can't be tested on Windows)reasonc                    \         P                  ! 4       ;_uu_ 4       p V P                  4        \        P                  P                  V P                  4      p\        VR7      ;_uu_ 4        \        V4      ;_uu_ 4       pVP                  \        P                  ! R4      4      p\        4       pVP                  P                  VP                  4      '       g   Q hVP                  4       pVP                  V4      '       g   Q hVP                  \        P                  ! R4      4      p\        4       pVP                  P                  VP                  4      '       g   Q hVP                  4       pVP                  V4      '       g   Q h RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)z3Try a simple do_get call over a Unix domain socket.r  r`   ra   N)tempfileNamedTemporaryFiler  r
   r   for_grpc_unixnamer^   r   r}   r  rC   rp   r   r   rR   )sockrh   r	  r   r|   rB   s         r   test_flight_domain_socketr[  L  s<    
	$	$	&	&$

??00;!844X&&&]]6==#9:F%'E==''5555??$D;;u%%%%]]6==#:;F&(E==''5555??$D;;u%%%% ' 5 
'	& '& 54 
'	&	&sJ   AG,F9	 BF&BF&	F&F9	G&F61F9	9G	GG	c            	        \         P                  P                  \         P                  ! \	        ^ R4      4      .R.R7      p \        V P                  R7      ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  P                  R4      V P                  4      w  r4VP                  V R4       VP                  4        VP                  \        P                   ! R4      4      P#                  4       pVP%                  V 4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	zTry sending/receiving a large message via Flight.

See ARROW-4421: by default, gRPC won't allow us to send messages >
4MiB in size.
rT   r9   )r   r   r  r   Ni   )r>   r@   rA   r?   r5  r   rp   r   r  r   r
   rq   rr   rw  r  r}   r  r   r   rB   r  r	  r   _r  s         r   test_flight_large_messager_  c  s     88
q*+,!U   D 
$++	6	6&+v{{344MM&"9"9"B"B6"J"&++/	 	4!12v}}S12;;=}}T"""" 5 
7	644 
7	6	6s%     E B*D=	+E=EEE!	c            	        \         P                  P                  \         P                  ! \	        ^ R4      4      .R.R7      p \        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  P                  R4      V P                  4      w  r4VP                  V 4       VP                  4        VP                  \        P                   ! R4      4      P#                  4       pVP%                  V 4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z?Try downloading a flight of RecordBatches in a GeneratorStream.rT   r9   r   r  r   Nru  )r>   r@   rA   r?   r5  r   r   r  r   r
   rq   rr   rp   rw  r  r}   r  r   r   r]  s         r   'test_flight_generator_stream_of_batchesra  y  s    88
q)$%!U   D 
 	!	!V+v{{344MM&"9"9"B"B6"J"&++/	4 v}}S12;;=}}T"""" 5 
"	!44 
"	!	!%    E4B)D0	E0E ;EE	c            
     F   \         P                  P                  \         P                  ! . RO\         P                  ! \         P
                  ! 4       \         P                  ! 4       4      4      \         P                  ! . R	O4      .RR.R7      p \        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  P                  R4      V P                  4      w  r4VP                  V 4       VP!                  4        VP#                  \        P$                  ! R4      4      P'                  4       pVP)                  V 4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)
zS
Try downloading a flight of RecordBatches with dictionaries
in a GeneratorStream.
rT   rU   r9   r   r  r   NrE   rV   rI   rE   rE   {      iY  i  i7  r>   r@   rA   r?   
dictionaryr  rM   r   r   r  r   r
   rq   rr   rp   rw  r  r}   r  r   r   r]  s         r   1test_flight_generator_stream_of_batches_with_dictrj       
 88
4rxxz27795	7
*+! 3Z	   D 
1	2	2f+v{{344MM&"9"9"B"B6"J"&++/	4 v}}S12;;=}}T"""" 5 
3	244 
3	2	2%     F B)E<	*F<FFF 	c            	        \         P                  P                  \         P                  ! \	        ^ R4      4      .R.R7      p \        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  P                  R4      V P                  4      w  r4VP                  V 4       VP                  4        VP                  \        P                   ! R4      4      P#                  4       pVP%                  V 4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z7Try downloading a flight of Table in a GeneratorStream.rT   r9   r   r  r   Nru  )r>   r@   rA   r?   r5  r   r   r  r   r
   rq   rr   rp   rw  r  r}   r  r   r   r]  s         r   %test_flight_generator_stream_of_tablern    s    88
q)$%!U   D 
%	&	&&+v{{344MM&"9"9"B"B6"J"&++/	4 v}}S12;;=}}T"""" 5 
'	&44 
'	&	&rb  c            
     F   \         P                  P                  \         P                  ! . RO\         P                  ! \         P
                  ! 4       \         P                  ! 4       4      4      \         P                  ! . R	O4      .RR.R7      p \        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  P                  R4      V P                  4      w  r4VP                  V 4       VP!                  4        VP#                  \        P$                  ! R4      4      P'                  4       pVP)                  V 4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)
zK
Try downloading a flight of Table with dictionaries
in a GeneratorStream.
rT   rU   r9   r   r  r   Nrd  re  rh  r]  s         r   /test_flight_generator_stream_of_table_with_dictrp    rk  rl  c            	        \         P                  P                  \         P                  ! \	        ^ R4      4      .R.R7      p \        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  P                  R4      V P                  4      w  r4VP                  V 4       VP                  4        VP                  \        P                   ! R4      4      P#                  4       pVP%                  V 4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)zCTry downloading a flight of RecordBatchReader in a GeneratorStream.rT   r9   r   r  r   Nru  )r>   r@   rA   r?   r5  r   r   r  r   r
   rq   rr   rp   rw  r  r}   r  r   r   r]  s         r   3test_flight_generator_stream_of_record_batch_readerrr    s    88
q)$%!U   D 
1	2	2f+v{{344MM&"9"9"B"B6"J"&++/	4 v}}S12;;=}}T"""" 5 
3	244 
3	2	2rb  c            
     F   \         P                  P                  \         P                  ! . RO\         P                  ! \         P
                  ! 4       \         P                  ! 4       4      4      \         P                  ! . R	O4      .RR.R7      p \        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  P                  R4      V P                  4      w  r4VP                  V 4       VP!                  4        VP#                  \        P$                  ! R4      4      P'                  4       pVP)                  V 4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)
zW
Try downloading a flight of RecordBatchReader with dictionaries
in a GeneratorStream.
rT   rU   r9   r   r  r   Nrd  re  rh  r]  s         r   =test_flight_generator_stream_of_record_batch_reader_with_dictrt    rk  rl  c                    \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P                  ! \
        P                  4      ;_uu_ 4        VP                  \        P                  ! R4      4      P                  4        RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)z+Try streaming data with mismatched schemas.r   r   N)r&  r   r  r  r  r>   ArrowExceptionr}   r
   r  r   r  s     r   $test_flight_invalid_generator_streamrw    s    	"	$	$+v{{344]]2,,--MM&--,-668 . 5 
%	$-- 54 
%	$	$s:    C-C	 4B.C	C.B>9C	CCC%	c                    \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P                  ! RR4      p\        P
                  ! RR7      p\        P                  ! \        P                  4      ;_uu_ 4        \        VP                  W#R7      4       RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)z)Make sure timeouts fire on slow requests.r   r  r   g?r  ry   N)r:  r   r  r
   r  r   r  r  rP  r  r   )r  r	  r   rf   s       r   test_timeout_firesry    s     
		v+v{{344r3'**37 ]]65566!!&!:; 7 5 
	 76 54 
		s;    C*AC	C*C	2C*CC	C'"C**C;	c            	     r   \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P                  ! RR7      pVP                  \        P                  ! R4      VR7      P                  4        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z0Make sure timeouts do not fire on fast requests.r   r(  r  r`   ry   N)r^   r   r  r
   r   r}   r  r   )r  r	  rf   s      r   test_timeout_passesr{    su    			6+v{{344**37fmmG,g>GGI 5 
 	44 
 		s#    B%AB	 B%B"B%%B6	c            
        \         P                  P                  \         P                  ! . R	O4      .R.R7      p \	        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       p\        P                  ! \        ^.R7      R7      pVP                  \        P                  ! R4      VR7      P                  4       pVP                  \        P                  ! R4      4      P                  4       pVP                  ^8X  g   Q hVP                  ^8X  g   Q hW@8X  g   Q hV\        4       8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)
z"Make sure ReadOptions can be used.rU   r9   r   )included_fields)read_optionsrb   ry   NrX   )r>   r@   rA   r?   r^   r   r  r
   r   r   r}   r  r   num_columnsr\   )expectedr  r	  rf   	response1	response2s         r   test_read_optionsr    s   xx##RXXl%;$<SE#JH			6+v{{344**'<>MM&--#& " ((0
 	MM&--"9:CCE	$$)))$$)))$$$13333 5 
 	44 
 		s%    E,C
E		7E	EEE-	   tests   p4ssw0rdr  c                    \        \        R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P
                  ! RR4      p\        P                  ! \        P                  RR7      ;_uu_ 4        \        VP                  V4      4       RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)z,Test that auth fails when not authenticated.auth_handlerr   r   r   z.*unauthenticated.*r  N)r   basic_auth_handlerr   r  r
   r  r  r  rR  r  r   r  r	  r   s      r   test_http_basic_unauthr     s     
 -?	@	@F+v{{344z3/]]6<<!68 8!!&)*8 5 
A	@8 8 54 
A	@	@s;    CAC	?B4C	"C4C?C	CCC+	z,ARROW-10013: gRPC on Windows corrupts peer()c            
        \        \        R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P
                  ! RR4      pVP                  \        RR4      4       VP                  V4      p\        V4      pVP                  P                  4       R8X  g   Q h\        V4      pVP                  P                  4       R8w  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	z:Test a Python implementation of HTTP basic authentication.r  r   r   r   r  p4ssw0rdr  N)r   r  r   r  r
   r  r  r  r   nextrF  r   )r  r	  r   rL  identitypeer_addresss         r   test_http_basic_authr  +  s     
 -?	@	@F+v{{344z3/6vzJK""6*=}}'')W444G}  ++-444 5 
A	@44 
A	@	@s#    C;BC(	C;(C83C;;D	c                    \        \        R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P
                  ! RR4      p\        P                  ! \        P                  RR7      ;_uu_ 4        VP                  \        RR4      4       \        VP                  V4      4       R	R	R	4       R	R	R	4       R	R	R	4       R	#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R	# ; i)
z-Test that auth fails with the wrong password.r  r   r   r   z.*wrong password.*r  r  wrongN)r   r  r   r  r
   r  r  r  rR  r  r  r  r   r  s      r   %test_http_basic_auth_invalid_passwordr  :  s    	-?	@	@F+v{{344z3/]]6<<!57 7 :67 KL!!&)*7 5 
A	@7 7 54 
A	@	@s;    C5AC"	?6C5C"	=C5CC"	"C2-C55D	c            
        \        \        R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P
                  ! RR4      pVP                  \        RR4      4       \        VP                  V4      4      pVP                  P                  4       R8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	-Test an auth mechanism that uses a handshake.r  r   r   r   r  r  r  N)r   token_auth_handlerr   r  r
   r  r  r  r  r   rF  r   )r  r	  r   r  s       r   test_token_authr  E  s    	-?	@	@F+v{{344z3/26:FG((01}}'')W444	 5 
A	@44 
A	@	@s#    CA.B:	(C:C
CC	c                    \        \        R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P
                  ! \        P                  4      ;_uu_ 4        VP                  \        RR4      4       RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)r  r  r   r  r  N)
r   r  r   r  r  r  r
   rR  r  r  r  s     r   test_token_auth_invalidr  O  s    	-?	@	@F+v{{344]]6<<== 6vw GH > 5 
A	@== 54 
A	@	@s:    C-B/	&BB/	
CB,'B/	/B?:CC	c            	     b   \        \        R\        4       /R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       pVP                  RR4      pV^ ,          R8X  g   Q hV^,          R8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	zATest authenticate_basic_token with bearer token and auth headers.r  r  r  r   r     passwordr     Bearer token1234N)r  no_op_auth_handlerr  r   r  authenticate_basic_token)r  r	  
token_pairs      r   test_authenticate_basic_tokenr  [  s    	-?13M 
 

+v{{34444WkJ
!} 0000!} 3333 5
 
 54
 
 
s#    B3B
	8B
BBB.	c                    \        \        R\        4       /R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\
        P                  ! \        P                  4      ;_uu_ 4        VP                  RR4       RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)z7Test authenticate_basic_token with an invalid password.r  r  r   r  s   badpasswordN)
r  r  r  r   r  r  r  r
   rR  r  r  s     r   .test_authenticate_basic_token_invalid_passwordr  f  s    	-?13M 
 

+v{{344]]6<<==++G^D > 5
 
 >= 54
 
 
s;    C-B1	1BB1	CB.)B1	1C<CC	c                 D   \        \        R\        4       /R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       pVP                  RR4      pV^ ,          R8X  g   Q hV^,          R8X  g   Q h\        P                  ! V.R7      p\        VP                  \        P                  ! R	R
4      VR7      4      pV^ ,          P                  P                  4       R8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z@Test authenticate_basic_token and doAction after authentication.r  r  r   r  r  r  r  r  test-actionr   r   rf   	   token1234N)r  r  r  r   r  r  r
   r   r  r   r  rF  r   r  r	  r  rf   r  s        r   (test_authenticate_basic_token_and_actionr  p  s    	-?13M 
 

+v{{34444WkJ
!} 0000!} 3333**J<@f&&==4g ' G Hay~~((*l::: 5
 
 54
 
 
s$    DB$C;	)D;DDD	c            
        \        \        R\        4       /R7      ;_uu_ 4       p \        4       p\	        RV P
                  3V.R7      p\        P                  ! R4      p\        P                  ! RRV,           3.R7      p\        VP                  \        P                  ! R	R
4      VR7      4      pV^ ,          P                  P                  4       R8X  g   Q hVP                  ^ ,          R8X  g   Q hVP                  ^,          R8X  g   Q h\        VP                  \        P                  ! R	R
4      VR7      4      pV^ ,          P                  P                  4       R8X  g   Q hVP                  ^ ,          R8X  g   Q hVP                  ^,          R8X  g   Q hVP!                  4        RRR4       R#   + '       g   i     R# ; i)zTest authenticate_basic_token with client middleware
to intercept authorization header returned by the
HTTP header auth enabled server.
r  r  r   r  s   test:passwordr  s   Basic r  r  r   r  r  Nr  )r  r  r  r  r   r  r  r  r
   r   r  r   r  rF  r   r  r  )r  client_auth_middlewarer	  encoded_credentialsrf   r  result2s          r   4test_authenticate_basic_token_with_client_middlewarer    s   
 
 -?13M 
 

!B!D&++&./
 %../?@**y+>>?4
  f&&==4g ' G Hay~~((*l:::%55a8<LLLL%55a8%& 	& &v''==4g ( G Hqz))+|;;;%55a8<LLLL%55a8%& 	& &1
 
 
 
s   FF44G	c                    \        \        R\        4       R\        4       /R7      ;_uu_ 4       p \	        RV P
                  34      ;_uu_ 4       pVP                  RR4      pV^ ,          R8X  g   Q hV^,          R8X  g   Q h\        P                  ! VRR.R7      p\        VP                  \        P                  ! RR4      VR7      4      pV^ ,          P                  P                  4       R	8X  g   Q hV^,          P                  P                  4       R
8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z:Test passing multiple arbitrary headers to the middleware.r  r-  r  r   r  r  r  r     value1   value2r  r  r   ry   N)s   test-header-1r  )s   test-header-2r  )r+  r  r  r  r   r  r  r
   r   r  r   r  rF  r   r  s        r   -test_arbitrary_headers_in_flight_call_optionsr    s1   	%'57!H!J

 

 +v{{34444WkJ
!} 0000!} 3333**))4
 
 f&&v}}3( )0 ' 2 3ay~~((*i777ay~~((*i777 5
 
 54
 
 
s$    ECD/	E/D?:EE	c                 r   \         P                  ! \        P                  RR7      ;_uu_ 4        \        P
                  ! R4       RRR4       \         P                  ! \        P                  RR7      ;_uu_ 4        \        R4       RRR4       R#   + '       g   i     LT; i  + '       g   i     R# ; i)zTest constructing invalid URIs.z.*Cannot parse URI:.*r  %N)r  r  r>   rT  r
   r  r^   r"   r   r   test_location_invalidr    sj    	r.E	F	Fs 
G 
r.E	F	FS! 
G	F 
G	F 
G	F	Fs   B<B%B"	%B6	c                     \         P                  ! R4      P                  R8X  g   Q h\         P                  ! R4      P                  R8X  g   Q hR# )z,Test creating locations for unknown schemes.zs3://foos   s3://foozhttps://example.com/bar.parquets   https://example.com/bar.parquetN)r
   r   urir"   r   r   test_location_unknown_schemer    sD    ??:&**k999??<=AA*+ + +r   c                    \        4       p \        V R,          R7      ;_uu_ 4       p\        R\        VP                  4      ,           4      ;_uu_ 4       p\
        P                  ! \        P                  4      ;_uu_ 4        VP                  \        P                  ! R4      4      P                  4        RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)z>Make sure clients cannot connect when cert verification fails.r1   tls_certificateszgrpc+tls://localhost:r`   N)r5   r^   r   r|  r  r  r  r
   FlightUnavailableErrorr}   r  r   certsr  r	  s      r   test_tls_failsr    s     E 
u^/D	E	E03qvv;>??6 ]]68899MM&--01::< : @ 
F	E :9 @? 
F	E	Es;   .C5-C"	4C5C"	=C5CC"	"C2-C55D	c            	        \        4       p \        4       p\        VR,          R7      ;_uu_ 4       p\        RVP                  3VR,          R7      ;_uu_ 4       pVP                  \        P                  ! R4      4      P                  4       pVP                  V 4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z"Try a simple do_get call over TLS.r1   r  r   r0   )tls_root_certsr`   N)
rC   r5   r^   r   r  r}   r
   r  r   r   r|   r  r  r	  rB   s        r   test_tls_do_getr    s     EE	u^/D	E	Ek166*$)+$6	8 	8;A}}V]]734==?{{5!!!!	8 
F	E	8 	8 
F	E	Es$   )CAB9	'C9C	CC	c                    \        4       p \        4       p\        VR,          R7      ;_uu_ 4       p \        RVP                  3RR7      pXP                  \        P                  ! R4      4      P                  4       pVP                  V 4      '       g   Q hVP                  4        RRR4       R#   \
         d    \        P                  ! R4        Li ; i  + '       g   i     R# ; i)	zDTry a simple do_get call over TLS with server verification disabled.r1   r  r   Tdisable_server_verificationz4disable_server_verification feature is not availabler`   N)rC   r5   r^   r   r  r   r  skipr}   r
   r  r   r   r  r  s        r   $test_tls_disable_server_verificationr    s     EE	u^/D	E	E	P!;"7>BDF }}V]]734==?{{5!!!! 
F	E # 	PKKNO	P	 
F	E	Es5   CB1A	CC1!CCCCC)	c                    \        4       p \        V R,          R7      ;_uu_ 4       p\        P                  ! RVP                  3V R,          RR7      ;_uu_ 4       p\
        P                  ! \        P                  4      ;_uu_ 4        VP                  \        P                  ! R4      4       RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)	z5Check that incorrectly overriding the hostname fails.r1   r  r   r0   fakehostname)r  override_hostnamer`   N)
r5   r^   r
   r  r  r  r  r  r}   r  r  s      r   test_tls_override_hostnamer    s     E	u^/D	E	EQVV,&+K&8)7	9 	9<B]]68899MM&--01 :	9 
F	E :9	9 	9 
F	E	Es;   5C.-C	&C.C	6C.CC	C+&C..C?	c            
        \         P                  ! . RO4      .p \         P                  P                  V R.R7      p. p\	        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  ! R4      4      p^ pV FN  w  rxVP                  V4       \        P                  ! RVP                  4       4      w  p	Wi8X  g   Q hV^,          pKP  	  \         P                  P                  V4      p V P                  V4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z'Try a simple do_get call with metadata.rT   r9   r   r   r   Nr;   )r>   r?   r@   rA   r   r   r  r}   r
   r  rc  r   r   r   from_batchesr   )
rB   r|   batchesr  r	  r   r   r   metadata
server_idxs
             r   test_flight_do_get_metadatar    s
    	$%D HH  cU 3EG			6+v{{344v}}S12%OENN5! --h.A.A.CDKJ$$$1HC	  &
 xx$$W-{{5!!!! 5 
 	44 
 		s+    E
0B1D7	"D7	%E
7EE

E	c            
        . p . p\        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P
                  ! R4      4      p^ p  VP                  4       w  rgV P                  V4       \        P                  ! RVP                  4       4      w  pWX8X  g   Q hV^,          pK_    \         d     Mi ; iRRR4       M  + '       g   i     M; iRRR4       M  + '       g   i     M; i\        4       ;_uu_ 4       p\        RTP                  34      ;_uu_ 4       pTP                  \        P
                  ! R4      4      p^ pT FN  w  rgTP                  T4       \        P                  ! RTP                  4       4      w  pYX8X  g   Q hT^,          pKP  	  RRR4       M  + '       g   i     M; iRRR4       M  + '       g   i     M; iY8X  g   Q hR# )z0Verify the iterator interface works as expected.r   r   r   N)r   r   r  r}   r
   r  
read_chunkrc  r   r   r   StopIteration)	batches1batches2r  r	  r   r   r   r  r  s	            r   1test_flight_metadata_record_batch_reader_iteratorr    s   HH			6+v{{344v}}S12"("3"3"5&$mmD(2E2E2GH
(((q   5444 
 			 
		6+v{{344v}}S12%OEOOE" --h.A.A.CDKJ$$$1HC	  & 5444 
 			 sl    C4)C	!AB><C	>C	C	CC		C4C(#C44D	 G9A<F>	5	G>G	GG*	c            	     r   \         P                  P                  \         P                  ! . RO4      .R.R7      p \         P                  P                  \         P                  P                  P                  R7      p\        VR7      ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  ! R4      4      pVP                  4       pVP                  V 4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	z2Try a simple do_get call with V4 metadata version.rT   r9   r  ry   r   r   Nr;   )r>   r@   rA   r?   r  r  r   r!  r   r   r  r}   r
   r  r   r   )r|   rf   r  r	  r   rB   s         r   test_flight_do_get_metadata_v4r  6  s    HH  	%	&'u ! 6Eff$$//22 % 4G	g	.	.&+v{{344v}}S12 {{5!!!! 5 
/	.44 
/	.	.s%    D%0AD	 D%D"D%%D6	c                 4   \         P                  ! . RO4      .p \         P                  P                  V R.R7      p\	        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  P                  R4      VP                  4      w  rET;_uu_ 4        \        VP                  ^R7      4       Fr  w  rg\        P                  ! RV4      pVP!                  Wx4       VP#                  4       p	V	f   Q h\        P$                  ! RV	P'                  4       4      w  p
Wj8X  d   Kr  Q h	  RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)	z'Try a simple do_put call with metadata.rT   r9   r   r  r   r   Nr;   )r>   r?   r@   rA   r   r   r  r   r
   rq   rr   rp   r   r   r   r   r  r'   r   r   )rB   r|   r  r	  r   metadata_readerr   r   r  r   r  s              r   test_flight_do_put_metadatar  C  s3    	$%D HH  cU 3E			6+v{{344"(--##,,R0LL# V'(8(8q(8(IJ
!;;tS1**5;%**,&$mmD#..2BC
((( K 	 5 
 	
 V	 54 
 		sD    F.AE3	4B	E E E3	F E0+E3	3F>FF	c                    \         P                  P                  \         P                  ! \        P
                  ! R\        P                  ! 4       R7      4      .R.R7      p \        4       ;_uu_ 4       p\        RVP                  3RR7      ;_uu_ 4       pVP                  \        P                  P                  R4      V P                  4      w  r4T;_uu_ 4        \        P                   ! \        P"                  R	R
7      ;_uu_ 4       pVP%                  V 4       RRR4       XP&                  P(                  R8X  g   Q hV P+                  ^ R4      V P+                  R4      .pV F  pVP%                  V4       K  	  RRR4       \         P,                  P/                  V .4      pVP1                  \        P2                  ! R4      4      P5                  4       p	W8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L@; i  + '       g   i     R# ; i)z+Try a simple do_put call with a size limit.i   )dtyperT   r9   r   i   )write_size_limit_bytesr  zexceeded soft limitr  Ni  r   )r>   r   rA   r?   nponesr  r   r   r  r   r
   rq   rr   rp   r  r  FlightWriteSizeExceededErrorr  r  limitslicer@   r  r}   r  r   )
large_batchr  r	  r   r  excinfosmaller_batchesr   r  actuals
             r   test_flight_do_put_limitr  Y  s    ..,,
BHHJ/0.U - K 
		vk6;;/,0	2 	25;"(--##,,R0#  VvBB%:< <?F"";/< ==&&$...!!!S)!!#&O )""5) )  88((+7v}}S12;;=!!!%	2 
	< < V	2 	2 
		sW   3"H-AH	/H
G4A"H>A#H	"H-4H?HHH	H*%H--H>	c                    \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       pVP                  \        P
                  ! R4      4      pVP                  4        \        P                  ! \        P                  RR7      ;_uu_ 4        VP                  4        RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)z4Test canceling a DoGet operation on the client side.r   r`   z(?i).*cancel.*r  N)r^   r   r  r}   r
   r  rJ  r  r  rQ  r  )r  r	  r   s      r   test_cancel_do_getr  v  s     
		6+v{{344v}}W56]]666!13 33 5 
 	3 3 54 
 		s;    C(A$C	C(C	0C(CC	C% C((C9	c                 @  aaaaa \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       pVP                  \        P
                  ! R4      4      o\        P                  ! 4       o\        P                  ! 4       o\        P                  ! 4       o\        P                  ! 4       oVVVVV3R lp\        P                  ! VRR7      pVP                  4        SP                  ^R7       SP                  4        SP                  4        VP                  ^R7       S;_uu_ 4        SP                  4       '       g   Q h RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)z5Test canceling a DoGet operation from another thread.r   r`   c                  6  < SP                  4        SP                  4        SP                  ^R7        SP                  4        R#   \        P                   d=    S;_uu_ 4        S P                  4        RRR4        R#   + '       g   i      R# ; ii ; i)r=   r  N)r  setwaitr
   rQ  )raised_proper_exceptionread_first_messager   result_lockstream_canceleds   r   
block_read/test_cancel_do_get_threaded.<locals>.block_read  so    ""$   +2!!#.. 2 [+//1 ![[[2s)   A B&B7BBBBTr   r  N)r:  r   r  r}   r
   r  r  EventLockr  r  r  rJ  r  joinis_set)	r  r	  r  r
  r  r  r   r  r  s	       @@@@@r   test_cancel_do_get_threadedr    s    
		v+v{{344v}}W56&__.#//+nn&"+//"3	2 	2 !!DA*A[*113333 3 5 
	4 [3 54 
		s;    FC:E9	2E&E9	F&E61E9	9F	FF	c            
      `   \        4       ;_uu_ 4       p \        R V P                  34      ;_uu_ 4       pVP                  \        P
                  ! RR4      4      p\        V4      P                  R8X  g   Q h?RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r   rB  r   r  N)r9  r   r  r   r
   r  r  rF  )r  r	  rL  s      r   test_streaming_do_actionr    sy    			+v{{344""6==C#@AG}!!V+++	 5 
	44 
		s#    BAB		7B	BBB-	c                 `	   \         P                  ! RR4      p V \         P                  P                  V P                  4       4      8X  g   Q h\         P                  ! R4      pV\         P                  P                  VP                  4       4      8X  g   Q h\         P
                  ! R4      pV\         P
                  P                  VP                  4       4      8X  g   Q h\         P                  ! RR4      pV\         P                  P                  VP                  4       4      8X  g   Q h\         P                  ! \        P                  ! R\        P                  ! 4       3.4      4      pV\         P                  P                  VP                  4       4      8X  g   Q h\         P                  P                  R4      pV\         P                  P                  VP                  4       4      8X  g   Q h\         P                  P                  RR	R
4      pV\         P                  P                  VP                  4       4      8X  g   Q h\         P                  ! \        P                  ! R\        P                  ! 4       3.4      V\         P                  ! RR.4      \         P                  ! R\         P                   P#                  RR4      .\        P$                  ! R4      P'                  \        P(                  ! R4      4      R4      .^^*RR4      p\         P                  P                  VP                  4       4      pVP                  VP                  8X  g   Q hVP*                  VP*                  8X  g   Q hVP,                  VP,                  8X  g   Q hVP.                  VP.                  8X  g   Q hVP0                  VP0                  8X  g   Q hVP2                  VP2                  8X  g   Q hVP4                  VP4                  8X  g   Q h\         P                  ! VR\         P                   P#                  RR4      .\        P$                  ! R4      P'                  \        P(                  ! R4      4      R4      pV\         P                  P                  VP                  4       4      8X  g   Q hR# )z(Make sure serializable types round-trip.action1s   action1-bodyrE   s   result1	username1	password1rT   r  rU   z
test.arrowr   r   r   r   r   r   r  Tr  r  r  N)r
   r  r  r  r  r  r  r  r>   rp   r   rq   r  rr   ro   r   r   r   r   r   r   r   r  r  r  r  r1  )	r   rz   r  r  schema_resultdescr  info2r  s	            r   test_roundtrip_typesr    s   ]]9o6FV]]..v/?/?/ABBBB]]5!FV]]..v/?/?/ABBBB]]:&FV]]..v/?/?/ABBBB!!+{;J))55j6J6J6LMMMM''		C3D2E(FGMF//;;!# # # # ""..v6D6**66t~~7GHHHH""++ClCD6**66t~~7GHHHH
		C$%&!!#7!!--k4@A		9:??T@RS(		
 	

D" ))$..*:;E;;%,,&&&??e.....u00000!4!4444<<5==((( 2 2222>>U__,,,$$	44[$GH
		'(--bll3.?@ 	H v,,889K9K9MNNNNr   c                 b   \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\         P                  4       P	                  4        F]  w  r#\
        P                  ! VRR7      ;_uu_ 4        \        VP                  \        P                  ! VR4      4      4       RRR4       K_  	  \
        P                  ! \        P                  RR7      ;_uu_ 4        \        VP                  4       4       RRR4       \        P                  ! . RO4      .p\        P                  P!                  VR.R7      pR\        P                  R	\        P"                  R
\        P$                  R\        P&                  R\        P(                  /pVP	                  4        F  w  rx\
        P                  ! VRR7      ;_uu_ 4        VP+                  \        P,                  P/                  V4      VP0                  4      w  rV	P3                  V4       V	P5                  4        RRR4       \
        P                  ! VRR7      ;_uu_ 4        VP+                  \        P,                  P/                  V4      VP0                  4      w  rV	P5                  4        RRR4       EK  	  RRR4       RRR4       R#   + '       g   i     EKu  ; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     EKc  ; i  + '       g   i     Lk; i  + '       g   i     R# ; i)z:Ensure that Flight errors propagate from server to client.r   z.*foo.*r  r   NrT   r9   rH  rI  rJ  rK  rL  r;   )rF  r   r  rV  r  r  r  r  r   r
   r  rO  rv   r>   r?   r@   rA   rP  rQ  rR  rS  r   rq   r  rp   rw  r  )r  r	  argexc_typerB   r|   
exceptionsr`  	exceptionr   r   s              r   test_roundtrip_errorsr    s(   			+v{{344.::<BBDMCxy99V%%fmmC&=>? :9 E ]]655YGG$$&' H ,-.$$T#$7 2222f11v@@F::

 #-"2"2"4Gy	::!'++77@LL"" ""5) ; y	::!'++77@LL"" 	 ;: #5' 5 
	 :99GGG  ;: ;::9 54 
		s    LAL
	;0J9+:L
	%K?C
L
		AK"&(L
	AK5L
	'L9K
L
	K	L
	"K2-L
	5L 
L
	
LLL.	c                   aa \         P                  ! . R
O4      .p \         P                  P                  V R.R7      p\	        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  P                  R4      VP                  4      w  po^ .oVV3R lp\        P                  ! VR7      pVP                  4        VP                  ^R7      pT;_uu_ 4        \!        V4       F-  w  r\"        P$                  ! RV4      p
VP'                  W4       K/  	  VP)                  4        VP+                  4        R	R	R	4       S^ ,          \-        V4      8X  g   Q h R	R	R	4       R	R	R	4       R	#   + '       g   i     L<; i  + '       g   i     L-; i  + '       g   i     R	# ; i)z7Ensure that separate threads can read/write on a DoPut.rT   r9   r   r  c                  Z   < SP                  4       e   S ^ ;;,          ^,          uu&   K)  R # r   )r'   )countr  s   r   _reader_thread:test_do_put_independent_read_write.<locals>._reader_thread   s$    !&&(4aA 5r   r  r   r   Nr;   )r>   r?   r@   rA   r   r   r  r   r
   rq   rr   rp   r  r  r  r   r   r   r   r  done_writingr  r  )rB   r|   r  r	  r   r  r
  r  r   r   r  r  r  s              @@r   "test_do_put_independent_read_writer    sS    	$%D HH  cU 3E			6+v{{344"(--##,,R0LL# 	 !!8"""3V'0
!;;tS1**5; 1 !KKM  Qx3w<'''3 5 
 	  V 54 
 		s>    F10B
F	:AF!F	9F1FF	F.)F11G	c                    \        R\        4       /R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\	        VP                  \        P                  ! RR4      4      4      p\        V4      ^8X  g   Q hV^ ,          P                  P                  4       pRV8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z@Ensure that server middleware run on the same thread as the RPC.r  r  r   r  r   s   right valueN)r?  r;  r   r  r  r   r
   r  r  rF  r   )r  r	  rL  r  s       r   "test_server_middleware_same_threadr  5  s    	-/( 
 

+v{{344v''gs(CDE7|q   
**,&&&	 5
 
 54
 
 
s#    CA,B>	,C>C	CC"	c                    \        R\        4       /R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P
                  ! \        P                  4      ;_uu_ 4        \        VP                  4       4       RRR4       \        P
                  ! \        P                  4      ;_uu_ 4        \        VP                  \        P                  ! RR4      4      4       RRR4       \        RV P                  3\        4       .R7      p\        VP                  \        P                  ! RR4      4      4      pRVP                   P#                  4       8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L@; i  + '       g   i     R# ; i)z-Test rejecting an RPC with server middleware.r  r  r   Nr   r  )r?  rI  r   r  r  r  r>   ArrowNotImplementedErrorr  r   r
   rR  r   r  rQ  r  rF  r   )r  r	  responses      r   test_middleware_rejectr  A  s3   	46( 
 

+v{{344]]26677$$&' 8 ]]6<<==!!&--S"9:; > &++&<>?
 ((sC)@ABhmm668888 5
 

 87 >= 54
 
 
sS    F0-F	,E74F	:0F
*A:F	%F07FF	
FF	F-(F00G	c                 &	   \        4       p \        4       p\        RV /R7      ;_uu_ 4       p\        RVP                  3V.R7      ;_uu_ 4       p\
        P                  P                  R4      p\        P                  ! \        4      ;_uu_ 4        \        VP                  4       4       RRR4       \        P                  ! \        4      ;_uu_ 4        VP                  V4       RRR4       \        P                  ! \        4      ;_uu_ 4        VP                  V4       RRR4       \        P                  ! \        4      ;_uu_ 4        VP                  \
        P                   ! R4      4       RRR4       \        P                  ! \        4      ;_uu_ 4        VP#                  V\$        P&                  ! . 4      4      w  rVVP)                  4        RRR4       \        P                  ! \        4      ;_uu_ 4        \        VP+                  \
        P,                  ! RR4      4      4       RRR4       \        P                  ! \        4      ;_uu_ 4        \        VP/                  4       4       RRR4       \        P                  ! \        4      ;_uu_ 4        VP1                  V4      w  rVVP)                  4        RRR4       \
        P2                  P4                  \
        P2                  P6                  \
        P2                  P8                  \
        P2                  P:                  \
        P2                  P<                  \
        P2                  P>                  \
        P2                  P@                  \
        P2                  PB                  .pV PD                  V8X  g   Q hVPD                  V8X  g   Q h RRR4       RRR4       R#   + '       g   i     EL+; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELP; i  + '       g   i     EL
; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     R# ; i)z/Test that middleware records methods correctly.r  r  r   r   N)#rY  rj  r   r   r  r
   rq   r  r  r  r   r  rv   r  r  r}   r  r   r>   rp   r  r   r  r   r   rM  LIST_FLIGHTSGET_FLIGHT_INFO
GET_SCHEMADO_GETDO_PUT	DO_ACTIONrN  DO_EXCHANGEr]  )server_middlewareclient_middlewarer  r	  r   r   r^  r  s           r   test_middleware_mappingr&  W  s   8:8:	f.?%@	A	AV&++&)*	 	 
,,88=
]].//$$&' 0]].//"":. 0]].//j) 0]].//MM&--,- 0]].//j"))B-@IFLLN 0 ]].//!!&--S"9:; 0]].//$$&' 0]].//**:6IFLLN 0
 ,,//**&&&&)),,++	
 !((H444 ((H444I	 
B	A 0////////////// 0////////+	 	 
B	A	As   #Q?AQ,	O**Q,	O &*Q,	O4"*Q,	&P2*Q,	9P*Q,	?0P0/*Q,	Q3*Q,	$QC8Q,	:Q?O	Q,	 O1+	Q,	4P?	Q,	P	Q,	P-'	Q,	0Q;	Q,	Q	Q,	Q)#	Q,	,Q<7Q??R	c                     \        4       ;_uu_ 4       p \        R V P                  34      ;_uu_ 4       p \        VP	                  \
        P                  ! RR4      4      4       Q h  \
        P                   d0   pTP                  f   Q hTP                  pTR8X  g   Q h Rp?MRp?ii ; iRRR4       M  + '       g   i     M; iRRR4       R#   + '       g   i     R# ; i)r   rY  r   NrZ  )	rF  r   r  r  r   r
   r  rS  
extra_info)r  r	  eeis       r   test_extra_infor+    s    			+v{{344	5!!&--
C"@AB5-- 	5<<+++B4444	5	 5444 
			sE    CB6	1A&&B*;%B% B6	%B**B6	-	C6CCC$	c            	     F   \        4       p \        4       p\        V R,          ^ ,          .RV R,          R7      ;_uu_ 4       p\        RVP                  3V R,          V R,          ^ ,          P
                  V R,          ^ ,          P                  R7      ;_uu_ 4       pVP                  \        P                  ! R4      4      P                  4       pVP                  V4      '       g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	z!Test mutual TLS (mTLS) with gRPC.r1   Tr0   )r  verify_clientroot_certificatesr   )r  
cert_chainprivate_keyr`   N)r5   rC   r^   r   r  r2   r3   r}   r
   r  r   r   )r  r|   r  r	  rB   s        r   	test_mtlsr1    s     EE	#N3A67#K0
2 
2 67!&&! -^,Q/44n-a044		6 	6 :@}}V]]734==?{{5!!!!	6	
2 
2	6 	6	
2 
2 
2s&   ADAC<	*D<DDD 	c                 @   \         P                  P                  \         P                  ! \	        ^ R4      4      .R.R7      p \        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       p\        P                  P                  R4      pVP                  V4      w  rEV;_uu_ 4        VP                  4       pRRR4       V X8X  g   Q h RRR4       RRR4       R#   + '       g   i     L,; i  + '       g   i     L-; i  + '       g   i     R# ; i)rt  rT   r9   r   rh  Nru  )r>   r@   rA   r?   r5  rc  r   r  r
   rq   r  r   r   )r  r  r	  r   r   r   r|   s          r   test_doexchange_getr3    s    xx##
q)$%%U $ H 
		6+v{{344,,88@
++J7VOO%E 5    5 
 	 V 54 
 		s<    D4=C9	1C&C9	D&C61C9	9D	DD	c                    \         P                  P                  \         P                  ! \	        ^ R	4      4      .R.R7      p V P                  RR7      p\        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       p\        P                  P                  R4      pVP                  V4      w  rVT;_uu_ 4        VP                  V P                  4       V F  pVP                  V4       K  	  VP!                  4        VP#                  4       pVP$                  e   Q h\'        \)        V4      4      P+                  R4      p	VP,                  V	8X  g   Q hVP.                  P0                  ^ 8X  g   Q h RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)
rz  rT   r9      r   r   ri  Nr   ru  )r>   r@   rA   r?   r5  r   rc  r   r  r
   rq   r  r   rv  rp   r  r  r  rB   r|  r  r   r  r   r   )
rB   r  r  r	  r   r   r   r   r   expected_bufs
             r   test_doexchange_putr7    s^   88
q)$%!U   D ooCo0G			6+v{{344,,88@
++J7VLL% ""5) !!%%'E::%%%s7|,33G<L%%555<<,,111  5 
 	 V 54 
 		s=   & F==F*	B9F=F*	F=F'"F*	*F:5F==G	c                    \         P                  P                  \         P                  ! \	        ^ R	4      4      .R.R7      p V P                  RR7      p\        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       p\        P                  P                  R4      pVP                  V4      w  rVT;_uu_ 4        \	        ^
4       Fa  p\        V4      P                  R4      pVP                  V4       VP!                  4       p	V	P"                  e   Q hV	P$                  V8X  d   Ka  Q h	  VP'                  V P(                  4       ^ p
V F  pVP+                  V4       VP(                  V P(                  8X  g   Q hVP!                  4       p	V	P"                  V8X  g   Q hV	P$                  e   Q hV
^,          p
VP,                  P.                  V
8X  d   K  Q h	  \1        V4       F  w  r{\        V4      P                  R4      pVP3                  W4       VP!                  4       p	V	P"                  V8X  g   Q hV	P$                  V8X  g   Q hV
^,          p
VP,                  P.                  V
8X  d   K  Q h	  RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)
zTry a DoExchange echo server.rT   r9   r5  r   r   rg  r   Nru  )r>   r@   rA   r?   r5  r   rc  r   r  r
   rq   r  r   r|  r   r{  r  rB   r  rv  rp   r  r   r   r   r  )rB   r  r  r	  r   r   r   ir   r   r}  r   s               r   test_doexchange_echor:    sI   88
q)$%!U   D ooCo0G			6+v{{344,,88A
++J7V2Y!fmmG,%%c*))+zz)))))S000  LL%K ""5)}}333))+zzU***))111q ||66+EEE ! &g.!fmmG,**56))+zzU***))S000q ||66+EEE /-  5 
 	 V 54 
 		sQ   & J<=J)	A(J0B(JBJ8J<J)	J<J&!J)	)J94J<<K	c                    \         P                  P                  \         P                  ! \	        ^ R
4      4      .R.R7      p V P                  RR7      p\         P                  P                  \         P                  P                  P                  R7      p\        VR7      ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       p\        P                  P                  R4      pVP!                  V4      w  rgT;_uu_ 4        VP#                  V P$                  VR7       V Fd  pVP'                  V4       VP$                  V P$                  8X  g   Q hVP)                  4       p	V	P*                  V8X  g   Q hV	P,                  f   Kd  Q h	  R	R	R	4       R	R	R	4       R	R	R	4       R	#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R	# ; i)z;Try a DoExchange echo server using the V4 metadata version.rT   r9   r5  r   r  ry   r   rg  Nru  )r>   r@   rA   r?   r5  r   r  r  r   r!  rc  r   r  r
   rq   r  r   rv  rp   r  r  rB   r  )
rB   r  rf   r  r	  r   r   r   r   r   s
             r   test_doexchange_echo_v4r<    si   88
q)$%!U   D ooCo0Gff$$//22 % 4G	g	.	.&+v{{344,,88A
++J7VLLgL6 ""5)}}333))+zzU***))111 !  5 
/	. V 54 
/	.	.sC   * G
=F<	A?F)F)F<	G)F94F<	<GGG 	c                    \         P                  P                  \         P                  ! \	        ^ R4      4      \         P                  ! \	        ^R4      4      \         P                  ! \	        ^R4      4      .. R	OR7      p \         P                  P                  \         P                  ! \	        ^R
^4      4      .R.R7      p\        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       p\        P                  P                  R4      pVP                  V4      w  rVV;_uu_ 4        VP                  V P                  4       VP                  V 4       VP                  4        VP!                  4       pRRR4       VX8X  g   Q h RRR4       RRR4       R#   + '       g   i     L,; i  + '       g   i     L-; i  + '       g   i     R# ; i)z!Transform a table with a service.r   i  i  r9   r  r   rj  N)rT   rU   ci  )r>   r@   rA   r?   r5  rc  r   r  r
   rq   r  r   rv  rp   rw  r  r   )rB   r  r  r	  r   r   r   r|   s           r   test_doexchange_transformr?  	  sZ   88
q$ 
q$ 
q$ ! 	   D
 xx##
q,*+%W $ H 
		6+v{{344,,88F
++J7VLL%t$!OO%E	 
 5    5 
 	 V 54 
 		s=    G	5=F6	2AF#?F6	G	#F3.F6	6GG		G	c                    \        R\        4       /R7      ;_uu_ 4       p \        4       p\        RV P                  3V.R7      ;_uu_ 4       p\        VP                  \        P                  ! RR4      4      4      pVP                  P                  4       P                  R4      p\        P                  ! V4      p\        P                  P!                  4        Fv  w  rgVP#                  4       p\%        V\&        4      '       d   VP                  R4      pVP)                  V4      V8X  g   Q hVP*                  P)                  V4      V8X  d   Kv  Q h	  RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)rD  r  r  r   r   r   asciiN)rC  r  rp  r   r  r  r   r
   r  rF  r   r  astliteral_evalrv  r~  r  r  r  bytesr   rs  )r  r  r	  r  raw_headersrF  headerr  s           r   test_middleware_multi_headerrG  #	  s:   	 24- 
 

46fkk*#9& &)/F,,V]]3-DEFH"--224;;GDK --k:N"="F"F"L"L"Nfe,,#]]73F%))&1V;;;++//76AAA #O&	
 
& &	
 
 
s*   -E8C>E%	E%	E8%E50E88F		c            	     Z   \        4       p \        V R,          R7      ;_uu_ 4       pR.p\        P                  ! RVP                  3V R,          VR7      p\
        P                  ! \        P                  4      ;_uu_ 4        VP                  \        P                  ! R4      4       RRR4       VP                  4        R	.p\        P                  ! RVP                  3V R,          VR7      p\
        P                  ! \        P                  \        P                  34      ;_uu_ 4        VP                  \        P                  ! R4      4       RRR4       VP                  4        RRR4       R#   + '       g   i     L; i  + '       g   i     L=; i  + '       g   i     R# ; i)
z$Test setting generic client options.r1   r  r   r0   )r  generic_optionsr`   N)zgrpc.ssl_target_name_overrider  )zgrpc.max_receive_message_length    )r5   r^   r
   r  r  r  r  r  r}   r  r  r>   rT  rQ  )r  r  rf   r	  s       r   test_generic_optionsrK  9	  s    E	u^/D	E	EDEaff 5/4[/A079 ]]68899MM&--01 ::;aff 5/4[/A079 ]]BOOV-H-HIJJMM&--01 K! 
F	E :9 KJ 
F	E	Es=   AF&E3	(BF+&F	F3F>FFFF*	c                   0   a  ] tR tRt o RtR tR tRtV tR# )CancelFlightServeriQ	  zA server for testing StopToken.c                    \         P                  ! . 4      p\         P                  P                  . VR 7      p\        P
                  ! V\        P                  ! V4      4      # )r3  )r>   rp   r   rA   r
   r   r6  r7  )rg   rt   rz   rp   r%   s   &&&  r   r}   CancelFlightServer.do_getT	  sF    2^^''6':%%fi.>.>r.BCCr   c                   \         P                  ! . 4      p\         P                  P                  . VR 7      pVP	                  V4       VP                  4       '       g*   VP                  V4       \        P                  ! R4       K?  R# )r3  r?  N)	r>   rp   r   rA   rv  rD  r  r@  rA  )rg   rt   r   r   r   rp   r%   s   &&&&&  r   r   CancelFlightServer.do_exchangeY	  sa    2^^''6':V&&((r"JJsO )r   r"   N)	r   r   r   r   r   r}   r   r   r   r   s   @r   rM  rM  Q	  s     )D
 r   rM  c            	      &  aa \         P                  ! 4       P                  \         P                  ! 4       P                  8w  d   \        P
                  ! R 4       R o\        \        P                  3oVV3R lp \        4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  \        P                  ! R4      4      pV ! VP                  4       \        P                   P#                  R4      pVP%                  V4      w  rSV ! VP                  4        VP'                  4        RRR4       RRR4       R#   \        \        P(                  3 d     L/i ; i  + '       g   i     L;; i  + '       g   i     R# ; i)z'test only works from main Python threadc                  z    \         P                  ! R 4       \        P                  ! \        P                  4       R# r  )r@  rA  signalraise_signalSIGINTr"   r   r   signal_from_thread*test_interrupt.<locals>.signal_from_threadg	  s    

3FMM*r   c                 @  <   \         P                  ! SR 7      p\        P                  ! S4      ;_uu_ 4       pVP	                  4        V ! 4        RRR4       VP                  4        XP                  p\        T\        P                  \        34      '       g5   \        TP                  \        P                  \        34      '       g   Q hR# R#   + '       g   i     L; i  XP                  4        i ; i  \         d    \        P                  ! R4        Li ; i)r  Nz2KeyboardInterrupt didn't interrupt Flight read_all)r  r  r  r  r  r  KeyboardInterruptfailr  r  r>   ArrowCancelled__context__)r   texc_infor)  	exc_typesrW  s   &   r   r  test_interrupt.<locals>.testm	  s    	N$$,>?]]9--GGIJ .  NN!b//1BCDDq}}r'8'8:K&LMM	N NM E .-   	N KKLM	Ns:   5C$ CC$ C9 C!	C$ $C66C9 9!DDr   r   rg  N)r  current_threadidentmain_threadr  r  rZ  r>   r\  rM  r   r  r}   r
   r  r   rq   r  r   r  rQ  )r  r  r	  r   r   r   r`  rW  s         @@r   test_interruptre  b	  s   !''9+@+@+B+H+HH=>+ #B$5$56IN$ 
		+v{{344v}}S12V__,,88A
++J7V__	LLN 5 
	 "6#>#>? 		 54 
		sC    E?,A<E,	)E9E?E)&E,	(E))E,	,E<7E??F	c                  |   R p \        4       ;_uu_ 4       p\        P                  ! RVP                  34      ;_uu_ 4       p\        P
                  ! \        P                  V R7      ;_uu_ 4        VP                  \        P                  ! R4      4      P                  4        RRR4       VP                  \        P                  ! R4      4      P                  4       pVP                  ^8X  g   Q h RRR4       RRR4       R#   + '       g   i     Li; i  + '       g   i     L-; i  + '       g   i     R# ; i)z'application server implementation errorr   r  r   Nr2  )r0  r
   r  r  r  r  r.  r}   r  r   r  )r  r  r	  r|   s       r   test_never_sends_datarg  	  s    5E	#	%	%NNK566&]]6335AAMM&--,-668 B
 fmmM:;DDF~~""" 7 
&	%AA 76 
&	%	%s<   +D* /D	/4D#AD	2D*DD	D'"D**D;	c                     \         P                  P                  R R,          4      p \        4       ;_uu_ 4       p\         P                  ! RVP
                  34      ;_uu_ 4       p\        P                  ! \        RR7      ;_uu_ 4        VP                  V \        P                  ! . 4      4      w  r4VP                  4        RRR4       \        P                  ! \        P                  RR7      ;_uu_ 4        VP                  V 4       RRR4       RRR4       RRR4       R#   + '       g   i     Lj; i  + '       g   i     L5; i  + '       g   i     L@; i  + '       g   i     R# ; i)r  r   z%Failed to serialize Flight descriptorr  Nr  )r
   rq   r  r   r  r  r  r  OSErrorr   r>   rp   r  rv  r   )large_descriptorr  r	  r   r^  s        r   test_large_descriptorrk  	  s    
 ..::			vNNK566&]]7!HJ J&6		"FIFLLNJ ]]2,,!HJ J/0J 7 
	J JJ J 76 
		sS   +E$%E
		9D$6E
	8D7
E
	E$D4/E
	7EE
	
EEE.	c                     \         P                  P                  R 4      p RR,          p\        4       ;_uu_ 4       p\         P                  ! RVP
                  34      ;_uu_ 4       p\        P                  ! \        P                  RR7      ;_uu_ 4        VP                  V \        P                  ! . 4      4      w  rEV;_uu_ 4        VP                  V4       VP                  4        RRR4       RRR4       \        P                  ! \        P                  RR7      ;_uu_ 4        VP                  V 4      w  rFV;_uu_ 4        VP                  V4       RRR4       RRR4       RRR4       RRR4       ?\        4       ;_uu_ 4       p\         P                  ! RVP
                  34      ;_uu_ 4       p\        P                  ! \         P                   RR7      ;_uu_ 4        VP#                  \         P$                  ! R 4      4      pVP'                  4        RRR4       \        P                  ! \        P(                  RR7      ;_uu_ 4        VP                  V 4      w  rFV;_uu_ 4        VP'                  4        RRR4       RRR4       RRR4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL{; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)r   r  r   zapp_metadata size overflowr  Nr  )r
   rq   r  r   r  r  r  r  r>   ArrowCapacityErrorr   rp   r{  r  r   r  r.  r}   r  r   rv  )r   r  r  r	  r   r^  r   s          r   test_large_metadata_clientrn  	  sB    ((44S9J{#H			vNNK566&]]200!=? ?j"))B-@IF%%h/ ? ]]200!=? ?#//
;NF%%h/ ? 7 
 		"	$	$NNK566&]]633!=? ?]]6==#56FOO? ]]2,,!=? ?#//
;NF! ? 7 
%	$ ? ? ? ? ? ? 766 
		"? ? ? ? ? 76 
%	$	$s   +L&/K2	3J6"J"*J626K2	(KK
K K2	(L+M'6/M	%6L6M	M/L. MM	M'"J3-	J66K	K2	
K	KK/)	K2	2L=	LL	L+%	M	.L>9MMM	M$M''M8	c                   .   a  ] tR tRt o Rt. tR tRtV tR# )ActionNoneFlightServeri	  z@A server that implements a side effect to a non iterable action.c                    VP                   R 8X  d1   \        P                  ! V P                  4      P	                  R4      .# VP                   R8X  d   V P                  P                  R4       R# \        h)	get_valuer   rc  TN)rG   jsondumpsVALUESr   rc  r   r   s   &&&r   r    ActionNoneFlightServer.do_action	  sV    ;;+%JJt{{+227;<<[[H$KKt$!!r   r"   N)	r   r   r   r   r   ru  r   r   r   r   s   @r   rp  rp  	  s     JF" "r   rp  c            
        \        4       ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       pVP                  \        P
                  ! RR4      4       VP                  \        P
                  ! RR4      4      p\        P                  ! \        V4      P                  P                  4       4      R.8X  g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z}Ensure that actions are executed even when we don't consume iterator.

See https://issues.apache.org/jira/browse/ARROW-14255
r   rc  r   rr  TN)rp  r   r  r   r
   r  rs  loadsr  rF  r   )r  r	  rs      r   test_none_action_side_effectrz  	  s     
 	!	!V+v{{344x56V]];<=zz$q',,1134>>> 5 
"	!44 
"	!	!s#    C%BC	 C%C"C%%C6	c                   aa Rp Rp\         P                  ! WR7      o\         P                  P                  R4      p\        P
                  ! R\        P                  ! 4       3.4      p ! V3R lR\         P                  4      pV! 4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       pVP                  W#4      w  poV3R	 lp\        P                  ! VR
R7      p	V	P                  4        \        P                  ! \         P                  4      ;_uu_ 4       p
 VP!                  \        P"                  ! ^..VR7      4       K,    + '       g   i     M; iX
P$                  P&                  T8X  g   Q h\        P                  ! \         P                  4      ;_uu_ 4       p
TP)                  4        RRR4       M  + '       g   i     M; iT
P$                  P&                  T8X  g   Q hT	P+                  4        TP-                  T4      w  poT3R lp\        P                  ! TR
R7      p	T	P                  4        \        P                  ! \         P                  4      ;_uu_ 4       p
 TP/                  R4       K    + '       g   i     M; iT
P$                  P&                  T8X  g   Q h\        P                  ! \         P                  4      ;_uu_ 4       p
TP)                  4        RRR4       M  + '       g   i     M; iT
P$                  P&                  T8X  g   Q hT	P+                  4        RRR4       M  + '       g   i     M; iRRR4       R#   + '       g   i     R# ; i)zw
Ensure that exceptions during writing preserve error context.

See https://issues.apache.org/jira/browse/ARROW-16592.
rE   r  )r(  r   r  c                   :   <a  ] tR tRt o V3R ltV3R ltRtV tR# )0test_write_error_propagation.<locals>.FailServeri	  c                   < Shr   r"   rg   rt   r   r   r   excs   &&&&&r   r   7test_write_error_propagation.<locals>.FailServer.do_put	      Ir   c                   < Shr   r"   r  s   &&&&&r   r   <test_write_error_propagation.<locals>.FailServer.do_exchange	  r  r   r"   N)r   r   r   r   r   r   r   r   )r   r  s   @r   
FailServerr}  	  s     		 	r   r  r   c                  d   <   S P                  4        K    \        P                   d     R# i ; iTN)r'   r
   FlightErrorr   s   r   _reader-test_write_error_propagation.<locals>._reader
  s,    KKM%%     //Tr   r3  Nc                  d   <   S P                  4        K    \        P                   d     R# i ; ir  )r  r
   r  r  s   r   r  r  
  s/    %%'%% r  r  )r
   rQ  rq   r  r>   rp   r  r   r   r  r   r  r  r  r  r  r  r  r  r(  r  r  r   r{  )expected_messageexpected_infor   rp   r  r  r	  r   r  r
  r_  r  r   s              @@r   test_write_error_propagationr  	  sU    M

%
%4C((44S9JYY"((*-./FV,,  
+v{{344z:	 !!>]]666778""2??QC5#HI 87 ~~((M999]]666778LLN 8777~~((M999  ++J7	 !!>]]666778%%d+ 87 ~~((M999]]666778LLN 8777~~((M999] 5444 
s|    M%4A/M	#-EE AM	,G=	M	GB#M	4J		JAM	%K?6	M	?L
5M	?	M%MM%%M6	c                 2    \         P                  ! R4       R# )zy
Ensure that the gRPC server is stopped at interpreter shutdown.

See https://issues.apache.org/jira/browse/ARROW-16597.
zarrow_16597.pyN)r	   invoke_scriptr"   r   r   test_interpreter_shutdownr  2
  s     	'(r   c                   *   a  ] tR tRt o RtR tRtV tR# )TracingFlightServeri;
  z/A server that echoes back trace context values.c                f    VP                  R 4      P                  pR VP                  4        4       # )tracingc              3   R   "   T F  w  rV R V 2P                  R4      x  K  	  R# 5i)z: r   N)r   ).0r3   r  s   &  r   	<genexpr>0TracingFlightServer.do_action.<locals>.<genexpr>C
  s2      ;$9LS 55'"**733$9s   %')r  trace_contextr  )rg   rt   r   r  s   &&& r   r   TracingFlightServer.do_action>
  s3    ..y9GG;$1$7$7$9; 	;r   r"   Nr  r   s   @r   r  r  ;
  s     9; ;r   r  c            	      n   \        R \        P                  ! 4       /R7      ;_uu_ 4       p \        RV P                  34      ;_uu_ 4       p\        P
                  ! RR.R7      pVP                  RVR7       F  pK  	  RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	r  r  r   r  ry   N)s   traceparents7   00-000ff00f00f0ff000f0f00ff0f00fff0-000f0000f0f00000-00)s
   tracestater   )r   r   )r  r
   TracingServerMiddlewareFactoryr   r  r   r   )r  r	  rf   r  s       r   test_tracingr  G
  s    	v<<>) 
 

+v{{344 **5 	4
  %%j'%BE C 5
 
 54
 
 
s#    B#
4B	>B#B B##B4	win32z6Opentelemetry traces don't appear on stdout on Windowsc                  r   \        4       '       g   \        P                  ! R 4       Rp \        P                  P                  4       pRVR&   RVR&   \        P                  ! \        P                  RV .VRR7      pVP                  ^ 8X  g   Q VP                  4       hR	pR
VP                  9   g   Q V4       hR# )z"Arrow not built with OpenTelemetrya  if 1:
        import pyarrow.flight as flight
        from pyarrow.flight import FlightServerBase, FlightClient

        class SimpleServer(FlightServerBase):
            def do_action(self, context, action):
                return []

        with SimpleServer(
            middleware={"otel": flight.TracingServerMiddlewareFactory()}
        ) as server:
            with FlightClient(('localhost', server.port)) as client:
                list(client.do_action((b"", b"")))
        ostreamARROW_TRACING_BACKENDzpyarrow-testing-serviceOTEL_SERVICE_NAMEz-cT)envcapture_outputz%Expected service name in trace outputs%   service.name: pyarrow-testing-serviceN)r   r  r  r   r   copy
subprocessrunsys
executable
returncodestderrstdout)coder  resmsgs       r   +test_tracing_server_middleware_emits_tracesr  Z
  s    
 $%%89D **//
C#,C 8C
..#..$53(,.C>>Q*

*
1C3szzAF3FAr   c                     \        R RR7      p Rp\        P                  ! \        VR7      ;_uu_ 4        V P	                  \
        P                  P                  R4      RR7       RRR4       R#   + '       g   i     R# ; i)zgrpc+tls://localhost:9643Tr  zRArgument 'schema' has incorrect type \(expected pyarrow.lib.Schema, got NoneType\)r  rE   Nr3  )r   r  r  r  r   r
   rq   r  )r	  r  s     r   .test_do_put_does_not_crash_when_schema_is_noner  y
  s`    56:<F<C	y	,	,f--99%@! 	 	# 
-	,	,	,s   1A//B 	c            	     @  a  ! R R\         4      p  ! V3R lR\        4      p ! R R\        4      oV! 4       pV ! 4       ;_uu_ 4       p\        RVP                  3V.R7      ;_uu_ 4       pVP                  \        P                  P                  R	4      4       RVP                  9   g   Q hRVP                  9   g   Q hRVP                  9   g   Q hRVP                  9   g   Q h R
R
R
4       R
R
R
4       R
#   + '       g   i     L; i  + '       g   i     R
# ; i)z9Ensure that server-sent headers/trailers make it through.c                   &   a  ] tR tRt o R tRtV tR# ):test_headers_trailers.<locals>.HeadersTrailersFlightServeri
  c                    VP                  R R4       VP                  RR4       VP                  RR4       VP                  RR4       \        P                  ! \        P
                  ! . 4      V. 4      # )x-headerheader-valuex-header-binzheadervalue	x-trailertrailer-valuex-trailer-binztrailervalue)
add_headeradd_trailerr
   ro   r>   rp   r   s   &&&r   r  Jtest_headers_trailers.<locals>.HeadersTrailersFlightServer.get_flight_info
  sh    z>:~/@A_=1CD$$		" r   r"   N)r   r   r   r   r  r   r   r   s   @r   HeadersTrailersFlightServerr  
  s     		 		r   r  c                   4   <a  ] tR tRt o R tV3R ltRtV tR# )?test_headers_trailers.<locals>.HeadersTrailersMiddlewareFactoryi
  c                    . V n         R # r   r  r  s   &r   rd   Htest_headers_trailers.<locals>.HeadersTrailersMiddlewareFactory.__init__
  s	    DLr   c                   < S! V 4      # r   r"   )rg   r  HeadersTrailersMiddlewares   &&r   r  Jtest_headers_trailers.<locals>.HeadersTrailersMiddlewareFactory.start_call
  s    ,T22r   r  N)r   r   r   r   rd   r  r   r   )r   r  s   @r    HeadersTrailersMiddlewareFactoryr  
  s     		3 	3r   r  c                   ,   a  ] tR tRt o R tR tRtV tR# )8test_headers_trailers.<locals>.HeadersTrailersMiddlewarei
  c                    Wn         R # r   r  r  s   &&r   rd   Atest_headers_trailers.<locals>.HeadersTrailersMiddleware.__init__
  s    "Lr   c                    VP                  4        F4  w  r#V F)  pV P                  P                  P                  W$34       K+  	  K6  	  R # r   )r  r  r  rc  )rg   r  r3   r  r  s   &&   r   r  Itest_headers_trailers.<locals>.HeadersTrailersMiddleware.received_headers
  s8    &}}#ELL((//= $  /r   r  N)r   r   r   r   rd   r  r   r   r   s   @r   r  r  
  s     	#	> 	>r   r  r   r  r  N)r  r  )r  s   headervalue)r  r  )r  s   trailervalue)
r   r   r   r   r  r  r
   rq   rr   r  )r  r  r  r  r	  r  s        @r   test_headers_trailersr  
  s    
&6 
3+B 3>$4 > /0G	$	&	&&+v{{3	JJfv66??CD+w>>>3wFFF-@@@5HHH K 
'	&JJ 
'	&	&s%   #D+A;C9	'D9D	DD	c                    a	 R \        ^^^^^ R7      R\        ^^^^ ^R7      /o	 ! V	3R lR\        4      p V ! 4       ;_uu_ 4       p\        RVP                  34      ;_uu_ 4       p\	        4       pR EF   p\
        P                  P                  V4      pVP                  V\
        P                  ! \        P                  P                  RR7      R7      R	7      w  rgV;_uu_ 4        VP                  VP                  \        P                  P                  VR 8H  R7      R	7       VP                  V4       VP!                  4        VP#                  4       pR
R
R
4       XP%                  V4      '       g   Q hVP&                  S	V,          8X  d   EK!  Q h	  R
R
R
4       R
R
R
4       R
#   + '       g   i     LZ; i  + '       g   i     L-; i  + '       g   i     R
# ; i)dict_deltasr(  dict_replacementc                   .   <a  ] tR tRt o V3R ltRtV tR# )Dtest_flight_dictionary_deltas_do_exchange.<locals>.DeltaFlightServeri
  c                  < \        4       pVP                  4       pVP                  V4      '       g   Q hVP                  SVP                  P                  4       ,          8X  g   Q hVP                  R 8X  dO   \        P                  P                  RR7      pVP                  VP                  VR7       VP                  V4       VP                  R8X  d/   VP                  VP                  4       VP                  V4       R# R# )s   dict_deltasTemit_dictionary_deltasry   s   dict_replacementN)rR   r   r   r   r`  r  r>   r  r  rv  rp   rw  )	rg   rt   r   r   r   expected_tablereceived_tablerf   expected_statss	   &&&&&   r   r   Ptest_flight_dictionary_deltas_do_exchange.<locals>.DeltaFlightServer.do_exchange
  s    /1N#__.N!((8888<<>*2D2D2K2K2M#NNNN!!^3&&000M^22GD"">2!!%88^223"">2 9r   r"   N)r   r   r   r   r   r   r   )r   r  s   @r   DeltaFlightServerr  
  s     	3 	3r   r  r   Tr  )write_optionsry   N)r  r  )r   r^   r   r  rR   r
   rq   r  r   r   r>   r  r  rv  rp   rw  r  r   r   r   )
r  r  r	  r  r`  r   r   r   r  r  s
            @r   )test_flight_dictionary_deltas_do_exchanger  
  s   y #$"#&'
 	I #$"#&'
N"30 3 
		+v{{344+-:G00<<WEJ#//00"$&&"8"8/3 #9 #5 0 NF ^22BFF<R<R,3},D =S =G H"">2##%!'!2  "((8888<<>'#::::% ; 5 
	  54 
		sJ    G%BF<	'A0F)F<	6F<	F<	G)F94F<	<GGG 	c                 2   V P                   R 8X  d   R^RRRRRR/# V P                   R8X  dk   R^RR.R\        P                  P                  RR7      R\        P                  P	                  R	\        P                  P
                  P                  R
7      /# / # )defaultr  r  Nr  r~  allzstd)compressionF)use_threadsensure_alignment)s   abcs   def)paramr>   r  r  r   	AlignmentDataTypeSpecific)requests   &r   call_options_argsr  
  s    }}	!qtTD	
 	
 
%	q()RVV333GBFF11!!#!1!1!B!B 2 	
 	
 	r   r  r  r  T)indirectc                     \        R/ V B pVP                  4       pV P                  4        F!  w  r4Vf   W29   g   Q hK  V RV 2V9   d   K!  Q h	  R # )N=r"   )r   __repr__r  )r  call_optionsr  r	  vals   &    r   test_call_options_reprr  
  s_     %9'89L  "D%++-;;;au~%%% .r   )rB  r  r6  r   r    rT  r   r  r  rV  r  r@  r)   rs  r   numpyr  ImportErrorr  r   r>   pyarrow.libr   r   r   r   pyarrow.utilr   pyarrow.testsr	   r
   r   r   r   r   r   r   r   r   r   r   r  mark
pytestmarkr   r#   r.   r5   rC   rR   r\   r^   r   r   r   r   r   r   r	  r  r  r&  r0  r:  rF  rc  r  r  r  r  r  r  r  r  r  r  r  r  r   r+  r5  r;  r?  rC  rI  rQ  rS  rY  rj  rp  rv  r  r  r  r  r  r  r  r  slowr  r  r  r"  pandasr&  r,  r.  r3  r5  r7  r9  rM  rO  rR  skipifrY  r[  r_  ra  rj  rn  rp  rr  rt  rw  ry  r{  r  r  r  r  r  r  r  r  %header_auth_server_middleware_factoryr  r  r  r  r  r  r  r  requires_testing_datar  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r&  r+  r1  r3  r7  r:  r<  r?  rG  rK  rM  re  rg  large_memoryrk  rn  rp  rz  r  r  r  r  platformr  r  r  r  fixturer  parametrizer  r"   r   r   <module>r     sO  $    	     
         T T '   " [[

B
";
<2E+ ED&+ &R' *"- """"2 """.> ""0* 06+. +#3 .. ."E 0 E F!1 F&7' 7*.A( .AbJ#+ J#Z!2 0!2 ". .. $' $
/(? 
/1!1 161(? 189!1 9/- /9.E 9'7 F#3 F*+- +5$; 5) . -+B -&/+B /

$4 
	'> 		'> 		1)@ 	12"2 2.4)@ 44"2 4. 0 ."J@Z`F!$8   ('(D6 F F
$"<.=7$( 2!6 BGGtOD  F&F&* # #*# #*# #*# #*9<J4" 0[7   ,[3  
 + + BGGtOI  K
5K
5+5I )J(K %$& 4E;@8."+ ""= # = ""	" #	" "" #  ""	2 #	2"* @
"), " "8     4  4@8Ov#L$(N	'9,)5X	5 """ #"$!20(FV20!.B, "" #.) " ) )X# 1  1  "  "@
"- 
"
? C CL)	;* 	;& CLLG+S  UGUG:#&IR5;p  , )U+d  <
&<
&sV  	B$  F%+V"L"+16((06--06--s$    Z2 %[ 2	Z?>Z?[%$[%