mirror of https://github.com/citusdata/citus.git
Some debugging of the test
parent
54a007d6a1
commit
ab543c00d0
|
|
@ -545,6 +545,21 @@ class QueryRunner(ABC):
|
|||
with self.cur(**kwargs) as cur:
|
||||
cur.execute(query, params=params)
|
||||
|
||||
def sql_row(self, query, params=None, allow_empty_result=False, **kwargs):
|
||||
"""Run an SQL query that returns a single row and returns this row
|
||||
|
||||
This opens a new connection and closes it once the query is done
|
||||
"""
|
||||
with self.cur(**kwargs) as cur:
|
||||
cur.execute(query, params=params)
|
||||
result = cur.fetchall()
|
||||
|
||||
if allow_empty_result and len(result) == 0:
|
||||
return None
|
||||
|
||||
assert len(result) == 1
|
||||
return result[0]
|
||||
|
||||
def sql_value(self, query, params=None, allow_empty_result=False, **kwargs):
|
||||
"""Run an SQL query that returns a single cell and return this value
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
import psycopg
|
||||
import pytest
|
||||
from pprint import pprint
|
||||
|
||||
def test_isolate(cluster):
|
||||
|
||||
cluster.coordinator.restart()
|
||||
cluster.coordinator.sql("SET citus.split_shard_group_size_threshold to 100")
|
||||
cluster.coordinator.configure("citus.split_shard_group_size_threshold to 100")
|
||||
cluster.coordinator.reload()
|
||||
cluster.coordinator.sql("CREATE TABLE test_row(i integer)")
|
||||
cluster.coordinator.sql("SELECT create_distributed_table('test_row','i',shard_count:=1)")
|
||||
cluster.coordinator.sql("ANALYZE test_row")
|
||||
cluster.coordinator.sql("INSERT INTO test_row SELECT 1 from generate_series(1,20000) ")
|
||||
print(cluster.coordinator.sql_row("select count(*), avg(i) from test_row"))
|
||||
|
||||
row_count1 = cluster.coordinator.sql_value("SELECT count(*) FROM pg_dist_shard")
|
||||
|
||||
query = "SELECT citus_auto_shard_split_start('block_writes')"
|
||||
jobId = cluster.coordinator.sql_value(query)
|
||||
print(cluster.coordinator.sql_value("select command from pg_dist_background_task where status = 'runnable'"))
|
||||
|
||||
cluster.coordinator.sql("SELECT citus_job_wait({})".format(jobId))
|
||||
|
||||
|
|
@ -23,8 +27,8 @@ def test_isolate(cluster):
|
|||
|
||||
def test_split(cluster):
|
||||
|
||||
cluster.coordinator.restart()
|
||||
cluster.coordinator.sql("SET citus.split_shard_group_size_threshold to 100")
|
||||
cluster.coordinator.configure("citus.split_shard_group_size_threshold to 100")
|
||||
cluster.coordinator.reload()
|
||||
cluster.coordinator.sql("CREATE TABLE test_row(i integer)")
|
||||
cluster.coordinator.sql("SELECT create_distributed_table('test_row','i',shard_count:=1)")
|
||||
cluster.coordinator.sql("INSERT INTO test_row SELECT generate_series(1,20000) ")
|
||||
|
|
@ -33,6 +37,7 @@ def test_split(cluster):
|
|||
|
||||
query = "SELECT citus_auto_shard_split_start('block_writes')"
|
||||
jobId = cluster.coordinator.sql_value(query)
|
||||
print(cluster.coordinator.sql_value("select command from pg_dist_background_task where status = 'runnable'"))
|
||||
|
||||
cluster.coordinator.sql("SELECT citus_job_wait({})".format(jobId))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue