Skip to content

Commit bc73fd3

Browse files
authored
Merge pull request #18 from zhanghaitao3/master
Code refactoring
2 parents 97c4632 + 53d19d2 commit bc73fd3

22 files changed

+337
-416
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Thank you!
1111
-->
1212

1313
* **async_gaussdb version**:
14-
* **PostgreSQL version**:
15-
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
16-
the issue with a local PostgreSQL install?**:
14+
* **GaussDB version**:
15+
* **Do you use a GaussDB SaaS? If so, which? Can you reproduce
16+
the issue with a local GaussDB install?**:
1717
* **Python version**:
1818
* **Platform**:
1919
* **Do you use pgbouncer?**:

.github/workflows/install-postgres.sh

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ on:
1212
jobs:
1313
test-platforms:
1414
# NOTE: this matrix is for testing various combinations of Python and OS
15-
# versions on the system-installed PostgreSQL version (which is usually
16-
# fairly recent). For a PostgreSQL version matrix see the test-postgres
15+
# versions on the system-installed GaussDB version (which is usually
16+
# fairly recent). For a GaussDB version matrix see the test-gaussdb
1717
# job.
1818
strategy:
1919
matrix:
@@ -100,11 +100,11 @@ jobs:
100100
if: "!steps.release.outputs.is_release"
101101
env:
102102
LOOP_IMPL: ${{ matrix.loop }}
103-
PGHOST: "127.0.0.1"
104-
PGPORT: 5432
105-
PGUSER: "testuser"
106-
PGPASSWORD: "Test@123"
107-
PGDATABASE: "test"
103+
GAUSSDBHOST: "127.0.0.1"
104+
GAUSSDBPORT: 5432
105+
GAUSSDBUSER: "testuser"
106+
GAUSSDBPASSWORD: "Test@123"
107+
GAUSSDBDATABASE: "test"
108108
run: |
109109
if [ "${LOOP_IMPL}" = "uvloop" ]; then
110110
env USE_UVLOOP=1 python -m unittest -v tests.suite

async_gaussdb/_testbase/__init__.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121

2222
import 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

2727
from . 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)

async_gaussdb/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
import typing
1616

17-
__version__: typing.Final = '0.30.2'
17+
__version__: typing.Final = '0.30.3'

0 commit comments

Comments
 (0)