Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ce19675

Browse files
committed
Fix formatting of partitioning_test.py
1 parent 5e65cef commit ce19675

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

tests/python/partitioning_test.py

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ def wrapper(*args, **kwargs):
4646

4747

4848
class Tests(unittest.TestCase):
49-
def start_new_pathman_cluster(self, name='test',
50-
allow_streaming=False, test_data=False):
49+
def start_new_pathman_cluster(self,
50+
name='test',
51+
allow_streaming=False,
52+
test_data=False):
5153
node = get_new_node(name)
5254
node.init(allow_streaming=allow_streaming)
5355
node.append_conf("postgresql.conf", "shared_preload_libraries='pg_pathman'\n")
@@ -79,8 +81,7 @@ def catchup_replica(self, master, replica):
7981
WHERE application_name = '{0}'
8082
"""
8183

82-
master.poll_query_until('postgres',
83-
wait_lsn_query.format(replica.name))
84+
master.poll_query_until('postgres', wait_lsn_query.format(replica.name))
8485

8586
def test_concurrent(self):
8687
""" Test concurrent partitioning """
@@ -126,7 +127,7 @@ def test_replication(self):
126127
replica.psql('postgres', 'explain (costs off) select * from abc'))
127128

128129
# enable parent and see if it is enabled in replica
129-
node.psql('postgres', 'select enable_parent(\'abc\'')
130+
node.psql('postgres', "select enable_parent('abc')")
130131

131132
self.catchup_replica(node, replica)
132133
self.assertEqual(
@@ -139,15 +140,17 @@ def test_replication(self):
139140
node.execute('postgres', 'select count(*) from abc')[0][0], 300000)
140141

141142
# check that UPDATE in pathman_config_params invalidates cache
142-
node.psql('postgres', 'update pathman_config_params set enable_parent = false')
143+
node.psql('postgres',
144+
'update pathman_config_params set enable_parent = false')
143145
self.catchup_replica(node, replica)
144146
self.assertEqual(
145147
node.psql('postgres', 'explain (costs off) select * from abc'),
146148
replica.psql('postgres', 'explain (costs off) select * from abc'))
147149
self.assertEqual(
148150
node.psql('postgres', 'select * from abc'),
149151
replica.psql('postgres', 'select * from abc'))
150-
self.assertEqual(node.execute('postgres', 'select count(*) from abc')[0][0], 0)
152+
self.assertEqual(
153+
node.execute('postgres', 'select count(*) from abc')[0][0], 0)
151154

152155
def test_locks(self):
153156
"""
@@ -197,15 +200,14 @@ def add_partition(node, flag, query):
197200
# Start transaction that will create partition
198201
with node.connect() as con:
199202
con.begin()
200-
con.execute('select append_range_partition(\'abc\')')
203+
con.execute("select append_range_partition('abc')")
201204

202205
# Start threads that suppose to add new partitions and wait some
203206
# time
204207
query = (
205208
"select prepend_range_partition('abc')",
206209
"select append_range_partition('abc')",
207-
"select add_range_partition('abc', 500000, 550000)",
208-
)
210+
"select add_range_partition('abc', 500000, 550000)", )
209211
threads = []
210212
for i in range(3):
211213
thread = threading.Thread(
@@ -245,65 +247,71 @@ def test_tablespace(self):
245247

246248
def check_tablespace(node, tablename, tablespace):
247249
res = node.execute('postgres',
248-
'select get_tablespace(\'{}\')'.format(tablename))
250+
"select get_tablespace('{}')".format(tablename))
249251
if len(res) == 0:
250252
return False
251253

252254
return res[0][0] == tablespace
253255

254256
with get_new_node('master') as node:
255257
node.init()
256-
node.append_conf('postgresql.conf', 'shared_preload_libraries=\'pg_pathman\'\n')
258+
node.append_conf('postgresql.conf',
259+
"shared_preload_libraries='pg_pathman'\n")
257260
node.start()
258261
node.psql('postgres', 'create extension pg_pathman')
259262

260263
# create tablespace
261264
path = os.path.join(node.data_dir, 'test_space_location')
262265
os.mkdir(path)
263-
node.psql('postgres', 'create tablespace test_space location \'{}\''.format(path))
266+
node.psql('postgres',
267+
"create tablespace test_space location '{}'".format(path))
264268

265269
# create table in this tablespace
266-
node.psql('postgres', 'create table abc(a serial, b int) tablespace test_space')
270+
node.psql('postgres',
271+
'create table abc(a serial, b int) tablespace test_space')
267272

268273
# create three partitions. Excpect that they will be created in the
269274
# same tablespace as the parent table
270-
node.psql('postgres', 'select create_range_partitions(\'abc\', \'a\', 1, 10, 3)')
275+
node.psql('postgres',
276+
"select create_range_partitions('abc', 'a', 1, 10, 3)")
271277
self.assertTrue(check_tablespace(node, 'abc', 'test_space'))
272278

273279
# check tablespace for appended partition
274-
node.psql('postgres', 'select append_range_partition(\'abc\', \'abc_appended\')')
280+
node.psql('postgres',
281+
"select append_range_partition('abc', 'abc_appended')")
275282
self.assertTrue(check_tablespace(node, 'abc_appended', 'test_space'))
276283

277284
# check tablespace for prepended partition
278285
node.psql('postgres',
279-
'select prepend_range_partition(\'abc\', \'abc_prepended\')')
286+
"select prepend_range_partition('abc', 'abc_prepended')")
280287
self.assertTrue(check_tablespace(node, 'abc_prepended', 'test_space'))
281288

282289
# check tablespace for prepended partition
283290
node.psql('postgres',
284-
'select add_range_partition(\'abc\', 41, 51, \'abc_added\')')
291+
"select add_range_partition('abc', 41, 51, 'abc_added')")
285292
self.assertTrue(check_tablespace(node, 'abc_added', 'test_space'))
286293

287294
# check tablespace for split
288295
node.psql('postgres',
289-
'select split_range_partition(\'abc_added\', 45, \'abc_splitted\')')
296+
"select split_range_partition('abc_added', 45, 'abc_splitted')")
290297
self.assertTrue(check_tablespace(node, 'abc_splitted', 'test_space'))
291298

292299
# now let's specify tablespace explicitly
293300
node.psql(
294301
'postgres',
295-
'select append_range_partition(\'abc\', \'abc_appended_2\', \'pg_default\')')
302+
"select append_range_partition('abc', 'abc_appended_2', 'pg_default')"
303+
)
296304
node.psql(
297305
'postgres',
298-
'select prepend_range_partition(\'abc\', \'abc_prepended_2\', \'pg_default\')'
306+
"select prepend_range_partition('abc', 'abc_prepended_2', 'pg_default')"
299307
)
300308
node.psql(
301309
'postgres',
302-
'select add_range_partition(\'abc\', 61, 71, \'abc_added_2\', \'pg_default\')'
310+
"select add_range_partition('abc', 61, 71, 'abc_added_2', 'pg_default')"
303311
)
304312
node.psql(
305313
'postgres',
306-
'select split_range_partition(\'abc_added_2\', 65, \'abc_splitted_2\', \'pg_default\')'
314+
"select split_range_partition('abc_added_2', 65, 'abc_splitted_2', 'pg_default')"
307315
)
308316

309317
# yapf: disable
@@ -372,13 +380,13 @@ def test_foreign_table(self):
372380
b'25|foreign\n')
373381

374382
# Check that we can successfully insert new data into foreign partition
375-
master.safe_psql('postgres', 'insert into abc values (26, \'part\')')
383+
master.safe_psql('postgres', "insert into abc values (26, 'part')")
376384
self.assertEqual(
377385
master.safe_psql('postgres', 'select * from ftable order by id'),
378386
b'25|foreign\n26|part\n')
379387

380388
# Testing drop partitions (including foreign partitions)
381-
master.safe_psql('postgres', 'select drop_partitions(\'abc\')')
389+
master.safe_psql('postgres', "select drop_partitions('abc')")
382390

383391
# HASH partitioning with FDW:
384392
# - create hash partitioned table in master
@@ -417,7 +425,7 @@ def test_parallel_nodes(self):
417425
node.init()
418426
node.append_conf(
419427
'postgresql.conf',
420-
'shared_preload_libraries=\'pg_pathman, postgres_fdw\'\n')
428+
"shared_preload_libraries='pg_pathman, postgres_fdw'\n")
421429
node.start()
422430

423431
# Check version of postgres server
@@ -468,7 +476,7 @@ def test_parallel_nodes(self):
468476

469477
# Check parallel aggregate plan
470478
test_query = 'select count(*) from range_partitioned where i < 1500'
471-
plan = con.execute('select query_plan(\'%s\')' % test_query)[0][0]
479+
plan = con.execute("select query_plan('%s')" % test_query)[0][0]
472480
expected = json.loads("""
473481
[
474482
{
@@ -532,7 +540,7 @@ def test_parallel_nodes(self):
532540

533541
# Check simple parallel seq scan plan with limit
534542
test_query = 'select * from range_partitioned where i < 1500 limit 5'
535-
plan = con.execute('select query_plan(\'%s\')' % test_query)[0][0]
543+
plan = con.execute("select query_plan('%s')" % test_query)[0][0]
536544
expected = json.loads("""
537545
[
538546
{
@@ -587,7 +595,7 @@ def test_parallel_nodes(self):
587595

588596
# Check the case when none partition is selected in result plan
589597
test_query = 'select * from range_partitioned where i < 1'
590-
plan = con.execute('select query_plan(\'%s\')' % test_query)[0][0]
598+
plan = con.execute("select query_plan('%s')" % test_query)[0][0]
591599
expected = json.loads("""
592600
[
593601
{
@@ -869,7 +877,7 @@ def test_pg_dump(self):
869877
with get_new_node('test') as node:
870878
node.init()
871879
node.append_conf('postgresql.conf', """
872-
shared_preload_libraries=\'pg_pathman\'
880+
shared_preload_libraries='pg_pathman'
873881
pg_pathman.override_copy=false
874882
""")
875883
node.start()

0 commit comments

Comments
 (0)