mirror of https://github.com/citusdata/citus.git
Remove functions created just for unit testing
These functions are holdovers from pg_shard and were created for unit testing c-level functions (like InsertShardPlacementRow) which our regression tests already test quite effectively. Removing because it makes refactoring the signatures of those c-level functions unnecessarily difficult. - create_healthy_local_shard_placement_row - update_shard_placement_row_state - delete_shard_placement_rowpull/1453/head
parent
0b64bb1092
commit
fe53fd4a8e
|
@ -48,9 +48,6 @@ PG_FUNCTION_INFO_V1(partition_column_id);
|
||||||
PG_FUNCTION_INFO_V1(partition_type);
|
PG_FUNCTION_INFO_V1(partition_type);
|
||||||
PG_FUNCTION_INFO_V1(is_distributed_table);
|
PG_FUNCTION_INFO_V1(is_distributed_table);
|
||||||
PG_FUNCTION_INFO_V1(create_monolithic_shard_row);
|
PG_FUNCTION_INFO_V1(create_monolithic_shard_row);
|
||||||
PG_FUNCTION_INFO_V1(create_healthy_local_shard_placement_row);
|
|
||||||
PG_FUNCTION_INFO_V1(delete_shard_placement_row);
|
|
||||||
PG_FUNCTION_INFO_V1(update_shard_placement_row_state);
|
|
||||||
PG_FUNCTION_INFO_V1(acquire_shared_shard_lock);
|
PG_FUNCTION_INFO_V1(acquire_shared_shard_lock);
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,66 +238,6 @@ create_monolithic_shard_row(PG_FUNCTION_ARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* create_healthy_local_shard_placement_row inserts a row representing a
|
|
||||||
* finalized placement for localhost (on the default port) into the backing
|
|
||||||
* store.
|
|
||||||
*/
|
|
||||||
Datum
|
|
||||||
create_healthy_local_shard_placement_row(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
int64 shardId = PG_GETARG_INT64(0);
|
|
||||||
int64 shardLength = 0;
|
|
||||||
|
|
||||||
InsertShardPlacementRow(shardId, INVALID_PLACEMENT_ID, FILE_FINALIZED, shardLength,
|
|
||||||
"localhost", 5432);
|
|
||||||
|
|
||||||
PG_RETURN_VOID();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* delete_shard_placement_row removes a shard placement with the specified ID.
|
|
||||||
*/
|
|
||||||
Datum
|
|
||||||
delete_shard_placement_row(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
int64 shardId = PG_GETARG_INT64(0);
|
|
||||||
text *hostName = PG_GETARG_TEXT_P(1);
|
|
||||||
int64 hostPort = PG_GETARG_INT64(2);
|
|
||||||
bool successful = true;
|
|
||||||
char *hostNameString = text_to_cstring(hostName);
|
|
||||||
|
|
||||||
DeleteShardPlacementRow(shardId, hostNameString, hostPort);
|
|
||||||
|
|
||||||
PG_RETURN_BOOL(successful);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* update_shard_placement_row_state sets the state of the placement with the
|
|
||||||
* specified ID.
|
|
||||||
*/
|
|
||||||
Datum
|
|
||||||
update_shard_placement_row_state(PG_FUNCTION_ARGS)
|
|
||||||
{
|
|
||||||
int64 shardId = PG_GETARG_INT64(0);
|
|
||||||
text *hostName = PG_GETARG_TEXT_P(1);
|
|
||||||
int64 hostPort = PG_GETARG_INT64(2);
|
|
||||||
RelayFileState shardState = (RelayFileState) PG_GETARG_INT32(3);
|
|
||||||
bool successful = true;
|
|
||||||
char *hostNameString = text_to_cstring(hostName);
|
|
||||||
uint64 shardLength = 0;
|
|
||||||
uint64 placementId = INVALID_PLACEMENT_ID;
|
|
||||||
|
|
||||||
placementId = DeleteShardPlacementRow(shardId, hostNameString, hostPort);
|
|
||||||
InsertShardPlacementRow(shardId, placementId, shardState, shardLength,
|
|
||||||
hostNameString, hostPort);
|
|
||||||
|
|
||||||
PG_RETURN_BOOL(successful);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* acquire_shared_shard_lock grabs a shared lock for the specified shard.
|
* acquire_shared_shard_lock grabs a shared lock for the specified shard.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -53,9 +53,6 @@ extern Datum distributed_tables_exist(PG_FUNCTION_ARGS);
|
||||||
extern Datum column_name_to_column(PG_FUNCTION_ARGS);
|
extern Datum column_name_to_column(PG_FUNCTION_ARGS);
|
||||||
extern Datum column_name_to_column_id(PG_FUNCTION_ARGS);
|
extern Datum column_name_to_column_id(PG_FUNCTION_ARGS);
|
||||||
extern Datum create_monolithic_shard_row(PG_FUNCTION_ARGS);
|
extern Datum create_monolithic_shard_row(PG_FUNCTION_ARGS);
|
||||||
extern Datum create_healthy_local_shard_placement_row(PG_FUNCTION_ARGS);
|
|
||||||
extern Datum delete_shard_placement_row(PG_FUNCTION_ARGS);
|
|
||||||
extern Datum update_shard_placement_row_state(PG_FUNCTION_ARGS);
|
|
||||||
extern Datum next_shard_id(PG_FUNCTION_ARGS);
|
extern Datum next_shard_id(PG_FUNCTION_ARGS);
|
||||||
extern Datum acquire_shared_shard_lock(PG_FUNCTION_ARGS);
|
extern Datum acquire_shared_shard_lock(PG_FUNCTION_ARGS);
|
||||||
|
|
||||||
|
|
|
@ -34,18 +34,6 @@ CREATE FUNCTION create_monolithic_shard_row(regclass)
|
||||||
RETURNS bigint
|
RETURNS bigint
|
||||||
AS 'citus'
|
AS 'citus'
|
||||||
LANGUAGE C STRICT;
|
LANGUAGE C STRICT;
|
||||||
CREATE FUNCTION create_healthy_local_shard_placement_row(bigint)
|
|
||||||
RETURNS void
|
|
||||||
AS 'citus'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
CREATE FUNCTION delete_shard_placement_row(bigint, text, bigint)
|
|
||||||
RETURNS bool
|
|
||||||
AS 'citus'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
CREATE FUNCTION update_shard_placement_row_state(bigint, text, bigint, int)
|
|
||||||
RETURNS bool
|
|
||||||
AS 'citus'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
CREATE FUNCTION acquire_shared_shard_lock(bigint)
|
CREATE FUNCTION acquire_shared_shard_lock(bigint)
|
||||||
RETURNS void
|
RETURNS void
|
||||||
AS 'citus'
|
AS 'citus'
|
||||||
|
@ -227,53 +215,6 @@ WHERE shardid = :new_shard_id;
|
||||||
t | -2147483648 | 2147483647
|
t | -2147483648 | 2147483647
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
-- add a placement and manually inspect row
|
|
||||||
SELECT create_healthy_local_shard_placement_row(:new_shard_id);
|
|
||||||
create_healthy_local_shard_placement_row
|
|
||||||
------------------------------------------
|
|
||||||
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT shardstate, nodename, nodeport FROM pg_dist_shard_placement
|
|
||||||
WHERE shardid = :new_shard_id AND nodename = 'localhost' and nodeport = 5432;
|
|
||||||
shardstate | nodename | nodeport
|
|
||||||
------------+-----------+----------
|
|
||||||
1 | localhost | 5432
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- mark it as unhealthy and inspect
|
|
||||||
SELECT update_shard_placement_row_state(:new_shard_id, 'localhost', 5432, 3);
|
|
||||||
update_shard_placement_row_state
|
|
||||||
----------------------------------
|
|
||||||
t
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT shardstate FROM pg_dist_shard_placement
|
|
||||||
WHERE shardid = :new_shard_id AND nodename = 'localhost' and nodeport = 5432;
|
|
||||||
shardstate
|
|
||||||
------------
|
|
||||||
3
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- remove it and verify it is gone
|
|
||||||
SELECT delete_shard_placement_row(:new_shard_id, 'localhost', 5432);
|
|
||||||
delete_shard_placement_row
|
|
||||||
----------------------------
|
|
||||||
t
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT COUNT(*) FROM pg_dist_shard_placement
|
|
||||||
WHERE shardid = :new_shard_id AND nodename = 'localhost' and nodeport = 5432;
|
|
||||||
count
|
|
||||||
-------
|
|
||||||
0
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- deleting or updating a non-existent row should fail
|
|
||||||
SELECT delete_shard_placement_row(:new_shard_id, 'wrong_localhost', 5432);
|
|
||||||
ERROR: could not find valid entry for shard placement 540005 on node "wrong_localhost:5432"
|
|
||||||
SELECT update_shard_placement_row_state(:new_shard_id, 'localhost', 5432, 3);
|
|
||||||
ERROR: could not find valid entry for shard placement 540005 on node "localhost:5432"
|
|
||||||
-- now we'll even test our lock methods...
|
-- now we'll even test our lock methods...
|
||||||
-- use transaction to bound how long we hold the lock
|
-- use transaction to bound how long we hold the lock
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
|
@ -46,21 +46,6 @@ CREATE FUNCTION create_monolithic_shard_row(regclass)
|
||||||
AS 'citus'
|
AS 'citus'
|
||||||
LANGUAGE C STRICT;
|
LANGUAGE C STRICT;
|
||||||
|
|
||||||
CREATE FUNCTION create_healthy_local_shard_placement_row(bigint)
|
|
||||||
RETURNS void
|
|
||||||
AS 'citus'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION delete_shard_placement_row(bigint, text, bigint)
|
|
||||||
RETURNS bool
|
|
||||||
AS 'citus'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION update_shard_placement_row_state(bigint, text, bigint, int)
|
|
||||||
RETURNS bool
|
|
||||||
AS 'citus'
|
|
||||||
LANGUAGE C STRICT;
|
|
||||||
|
|
||||||
CREATE FUNCTION acquire_shared_shard_lock(bigint)
|
CREATE FUNCTION acquire_shared_shard_lock(bigint)
|
||||||
RETURNS void
|
RETURNS void
|
||||||
AS 'citus'
|
AS 'citus'
|
||||||
|
@ -168,25 +153,6 @@ SELECT create_monolithic_shard_row('customers') AS new_shard_id
|
||||||
SELECT shardstorage, shardminvalue, shardmaxvalue FROM pg_dist_shard
|
SELECT shardstorage, shardminvalue, shardmaxvalue FROM pg_dist_shard
|
||||||
WHERE shardid = :new_shard_id;
|
WHERE shardid = :new_shard_id;
|
||||||
|
|
||||||
-- add a placement and manually inspect row
|
|
||||||
SELECT create_healthy_local_shard_placement_row(:new_shard_id);
|
|
||||||
SELECT shardstate, nodename, nodeport FROM pg_dist_shard_placement
|
|
||||||
WHERE shardid = :new_shard_id AND nodename = 'localhost' and nodeport = 5432;
|
|
||||||
|
|
||||||
-- mark it as unhealthy and inspect
|
|
||||||
SELECT update_shard_placement_row_state(:new_shard_id, 'localhost', 5432, 3);
|
|
||||||
SELECT shardstate FROM pg_dist_shard_placement
|
|
||||||
WHERE shardid = :new_shard_id AND nodename = 'localhost' and nodeport = 5432;
|
|
||||||
|
|
||||||
-- remove it and verify it is gone
|
|
||||||
SELECT delete_shard_placement_row(:new_shard_id, 'localhost', 5432);
|
|
||||||
SELECT COUNT(*) FROM pg_dist_shard_placement
|
|
||||||
WHERE shardid = :new_shard_id AND nodename = 'localhost' and nodeport = 5432;
|
|
||||||
|
|
||||||
-- deleting or updating a non-existent row should fail
|
|
||||||
SELECT delete_shard_placement_row(:new_shard_id, 'wrong_localhost', 5432);
|
|
||||||
SELECT update_shard_placement_row_state(:new_shard_id, 'localhost', 5432, 3);
|
|
||||||
|
|
||||||
-- now we'll even test our lock methods...
|
-- now we'll even test our lock methods...
|
||||||
|
|
||||||
-- use transaction to bound how long we hold the lock
|
-- use transaction to bound how long we hold the lock
|
||||||
|
|
Loading…
Reference in New Issue