2020
2121
2222import async_gaussdb
23- from async_gaussdb import cluster as pg_cluster
24- from async_gaussdb import connection as pg_connection
25- from async_gaussdb import pool as pg_pool
23+ from async_gaussdb import cluster as gaussdb_cluster
24+ from async_gaussdb import connection as gaussdb_connection
25+ from async_gaussdb import pool as gaussdb_pool
2626
2727from . import fuzzer
2828
@@ -234,7 +234,7 @@ def _get_initdb_options(initdb_options=None):
234234
235235 # Make the default superuser name stable.
236236 if 'username' not in initdb_options :
237- initdb_options ['username' ] = 'postgres '
237+ initdb_options ['username' ] = 'root '
238238
239239 return initdb_options
240240
@@ -243,13 +243,13 @@ def _init_default_cluster(initdb_options=None):
243243 global _default_cluster
244244
245245 if _default_cluster is None :
246- pg_host = os .environ .get ('PGHOST ' )
247- if pg_host :
246+ gaussdb_host = os .environ .get ('GAUSSDBHOST ' )
247+ if gaussdb_host :
248248 # Using existing cluster, assuming it is initialized and running
249- _default_cluster = pg_cluster .RunningCluster ()
249+ _default_cluster = gaussdb_cluster .RunningCluster ()
250250 else :
251251 _default_cluster = _init_cluster (
252- pg_cluster .TempCluster ,
252+ gaussdb_cluster .TempCluster ,
253253 cluster_kwargs = {
254254 "data_dir_suffix" : ".apgtest" ,
255255 },
@@ -275,8 +275,8 @@ def create_pool(dsn=None, *,
275275 setup = None ,
276276 init = None ,
277277 loop = None ,
278- pool_class = pg_pool .Pool ,
279- connection_class = pg_connection .Connection ,
278+ pool_class = gaussdb_pool .Pool ,
279+ connection_class = gaussdb_connection .Connection ,
280280 record_class = async_gaussdb .Record ,
281281 ** connect_kwargs ):
282282 return pool_class (
@@ -302,7 +302,7 @@ def get_server_settings(cls):
302302 'log_connections' : 'on'
303303 }
304304
305- if cls .cluster .get_pg_version () >= (11 , 0 ):
305+ if cls .cluster .get_gaussdb_version () >= (11 , 0 ):
306306 # JITting messes up timing tests, and
307307 # is not essential for testing.
308308 settings ['jit' ] = 'off'
@@ -349,17 +349,17 @@ def get_connection_spec(cls, kwargs={}):
349349 if kwargs .get ('dsn' ):
350350 conn_spec .pop ('host' )
351351 conn_spec .update (kwargs )
352- if not os .environ .get ('PGHOST ' ) and not kwargs .get ('dsn' ):
352+ if not os .environ .get ('GAUSSDBHOST ' ) and not kwargs .get ('dsn' ):
353353 if 'database' not in conn_spec :
354354 conn_spec ['database' ] = 'postgres'
355355 if 'user' not in conn_spec :
356- conn_spec ['user' ] = 'postgres '
356+ conn_spec ['user' ] = 'root '
357357 return conn_spec
358358
359359 @classmethod
360360 def connect (cls , ** kwargs ):
361361 conn_spec = cls .get_connection_spec (kwargs )
362- return pg_connection .connect (** conn_spec , loop = cls .loop )
362+ return gaussdb_connection .connect (** conn_spec , loop = cls .loop )
363363
364364 def setUp (self ):
365365 super ().setUp ()
@@ -371,8 +371,8 @@ def tearDown(self):
371371 pool .terminate ()
372372 self ._pools = []
373373
374- def create_pool (self , pool_class = pg_pool .Pool ,
375- connection_class = pg_connection .Connection , ** kwargs ):
374+ def create_pool (self , pool_class = gaussdb_pool .Pool ,
375+ connection_class = gaussdb_connection .Connection , ** kwargs ):
376376 conn_spec = self .get_connection_spec (kwargs )
377377 pool = create_pool (loop = self .loop , pool_class = pool_class ,
378378 connection_class = connection_class , ** conn_spec )
@@ -457,7 +457,7 @@ class HotStandbyTestCase(ClusterTestCase):
457457
458458 @classmethod
459459 def setup_cluster (cls ):
460- cls .master_cluster = cls .new_cluster (pg_cluster .TempCluster )
460+ cls .master_cluster = cls .new_cluster (gaussdb_cluster .TempCluster )
461461 cls .start_cluster (
462462 cls .master_cluster ,
463463 server_settings = {
@@ -471,7 +471,7 @@ def setup_cluster(cls):
471471 try :
472472 con = cls .loop .run_until_complete (
473473 cls .master_cluster .connect (
474- database = 'postgres' , user = 'postgres ' , loop = cls .loop ))
474+ database = 'postgres' , user = 'root ' , loop = cls .loop ))
475475
476476 cls .loop .run_until_complete (
477477 con .execute ('''
@@ -483,7 +483,7 @@ def setup_cluster(cls):
483483 conn_spec = cls .master_cluster .get_connection_spec ()
484484
485485 cls .standby_cluster = cls .new_cluster (
486- pg_cluster .HotStandbyCluster ,
486+ gaussdb_cluster .HotStandbyCluster ,
487487 cluster_kwargs = {
488488 'master' : conn_spec ,
489489 'replication_user' : 'replication'
@@ -506,11 +506,11 @@ def get_cluster_connection_spec(cls, cluster, kwargs={}):
506506 if kwargs .get ('dsn' ):
507507 conn_spec .pop ('host' )
508508 conn_spec .update (kwargs )
509- if not os .environ .get ('PGHOST ' ) and not kwargs .get ('dsn' ):
509+ if not os .environ .get ('GAUSSDBHOST ' ) and not kwargs .get ('dsn' ):
510510 if 'database' not in conn_spec :
511511 conn_spec ['database' ] = 'postgres'
512512 if 'user' not in conn_spec :
513- conn_spec ['user' ] = 'postgres '
513+ conn_spec ['user' ] = 'root '
514514 return conn_spec
515515
516516 @classmethod
@@ -532,12 +532,12 @@ def get_connection_spec(cls, kwargs={}):
532532 @classmethod
533533 def connect_primary (cls , ** kwargs ):
534534 conn_spec = cls .get_cluster_connection_spec (cls .master_cluster , kwargs )
535- return pg_connection .connect (** conn_spec , loop = cls .loop )
535+ return gaussdb_connection .connect (** conn_spec , loop = cls .loop )
536536
537537 @classmethod
538538 def connect_standby (cls , ** kwargs ):
539539 conn_spec = cls .get_cluster_connection_spec (
540540 cls .standby_cluster ,
541541 kwargs
542542 )
543- return pg_connection .connect (** conn_spec , loop = cls .loop )
543+ return gaussdb_connection .connect (** conn_spec , loop = cls .loop )
0 commit comments