id~ddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZejddZejddZdZe jddZejddZejddZeZe jddZe jddZe jddZejddZdS)) create_engine)exc)url)configure_follower) create_db)drop_db)follower_url_from_main)log)post_configure_engine) run_reap_dbs)stop_test_class)temp_table_keyword_args)update_db_optsoraclec|5}|d|z|d|z|d|z|d||d|z|d|z|d|zddddS#1swxYwYdS)Nzcreate user %s identified by xez#create user %s_ts1 identified by xez#create user %s_ts2 identified by xez grant dba to z grant unlimited tablespace to %sz$grant unlimited tablespace to %s_ts1z$grant unlimited tablespace to %s_ts2)connectexecutecfgengidentconns Y/opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/dialects/oracle/provision.py_oracle_create_dbrs/ E$ 6>??? :UBCCC :UBCCC %%1222 7%?@@@ ;eCDDD ;eCDDDEEEEEEEEEEEEEEEEEEsB)C  CCc.d|z|_d|z|_dSN%s_ts1%s_ts2) test_schema test_schema_2)configrs r_oracle_configure_followerr"s"!E)F#e+Fc |d|ztjd|dS#tj$r }tjd|Yd}~dSd}~wwxYw)Nzdrop user %s cascadez Reaped db: %sTzcouldn't drop db: %sF)rr infor DatabaseErrorwarning)rdbnameerrs r_ora_drop_ignorer*%sx +f4555 &)))t   *C000uuuuus-1A AA c|5}t||t|d|zt|d|zddddS#1swxYwYdSr)rr*rs r_oracle_drop_dbr,/s 1$ u%%%x%/000x%/000111111111111111111s7AA AcdSN)db_urldb_optss r_oracle_update_db_optsr2<sDr#c.|5}|ddddn #1swxYwYtD]2} |j}d|_||_#|jjj$rY/wxYwtdS)zrun magic command to get rid of identity sequences # https://floo.bar/2019/11/29/drop-the-underlying-sequence-of-an-identity-column/ zpurge recyclebinN)beginr _all_conns stmtcachesizedialectdbapiInterfaceErrorclear)r!dbclsrcx_oracle_connscs rr r As )t '((())))))))))))))) %.. .-B ,-N (+-N ( ( z.    D  s7;; A""A98A9cPddlm}||dd}dS)Nr4)eventcheckoutc:t|dSr.)r6add) dbapi_con con_record con_proxys rrBz/_oracle_post_configure_engine..checkoutbsy!!!!!r#) sqlalchemyrA listens_for)renginefollower_identrArBs r_oracle_post_configure_enginerL^sH       vz**""+*"""r#ctjd|t|}|5}tjdd||d}d|D}t }|D]}|ds|dr-||vrS||d|z|vr|d|zd |z|vr|d |zd x}} t|d D]\} } t|| r|d z }tjd || ddddS#1swxYwYdS) Nzdb reaper connecting to %rzidentifiers in file: %sz, zselect u.username from all_users u where username like 'TEST_%' and not exists (select username from v$session where username=u.username)c:h|]\}|Sr/)lower).0usernames r z#_reap_oracle_dbs..ts$AAA+8X^^%%AAAr#_ts1_ts2rrr4z-Dropped %d out of %d stale databases detected) r r%rrjoinrsetendswithrD enumerater*) ridentsrrto_reap all_namesto_dropnamedroppedtotalrQs r_reap_oracle_dbsragsH )3///   C  $ *DIIf,=,=>>>,, 8   BAAAA %% 1 1D}}V$$ 1 f(=(= 1 D!!!d?i//KK4000d?i//KK4000%(!44  OE8h// 1   ;We   3                  sD$E**E.1E.cJtj|}||_d|_|S)Nxe)sa_urlmake_urlrQpassword)rrs r_oracle_follower_url_from_mainrgs$ /#  CCLCL Jr#cdgddS)NzGLOBAL TEMPORARYz PRESERVE ROWS)prefixesoracle_on_commitr/)rrs r_oracle_temp_table_keyword_argsrks((+  r#N)rrrJrrdtesting.provisionrrrr r r r r rrfor_dbrr"r*r,r2rWr6rLrargrkr/r#rros######333333******((((((777777$$$$$$666666------000000888888//////( E E E8$$,,%$,  1 1 1x    !  !!"!2SUU h''""('"X   Bx(()( ))*)r#