Skip to content

Commit

Permalink
Add test for data node validation
Browse files Browse the repository at this point in the history
Add a test that checks that a data node cannot be re-added after
deleting it on the access node, irrespective of whether one bootstraps
the data node or not when adding it.
  • Loading branch information
erimatnor committed Dec 22, 2020
1 parent fdce7c0 commit 43ad486
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
14 changes: 12 additions & 2 deletions tsl/test/expected/data_node_bootstrap.out
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ SELECT PG_ENCODING_TO_CHAR(encoding) = :enc
(1 row)

\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
-- After delete database and extension should still be there
-- After delete_data_node, the database and extension should still
-- exist on the data node
SELECT * FROM delete_data_node('bootstrap_test');
delete_data_node
------------------
Expand All @@ -70,6 +71,16 @@ AND e.extname = 'timescaledb';
(1 row)

\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
\set ON_ERROR_STOP 0
-- Trying to add the data node again should fail, with or without
-- bootstrapping.
SELECT * FROM add_data_node('bootstrap_test', host => 'localhost', database => 'bootstrap_test', bootstrap=>false);
ERROR: cannot add "bootstrap_test" as a data node
SELECT * FROM add_data_node('bootstrap_test', host => 'localhost', database => 'bootstrap_test');
NOTICE: database "bootstrap_test" already exists on data node, skipping
NOTICE: extension "timescaledb" already exists on data node, skipping
ERROR: cannot add "bootstrap_test" as a data node
\set ON_ERROR_STOP 0
DROP DATABASE bootstrap_test;
----------------------------------------------------------------------
-- Bootstrap the database and check that calling it without
Expand All @@ -88,7 +99,6 @@ SELECT * FROM show_data_nodes();
bootstrap_test | localhost | 55432 | bootstrap_test
(1 row)

\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
SELECT * FROM delete_data_node('bootstrap_test');
delete_data_node
------------------
Expand Down
11 changes: 9 additions & 2 deletions tsl/test/sql/data_node_bootstrap.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ SELECT PG_ENCODING_TO_CHAR(encoding) = :enc
WHERE datname = current_database();

\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
-- After delete database and extension should still be there
-- After delete_data_node, the database and extension should still
-- exist on the data node
SELECT * FROM delete_data_node('bootstrap_test');
SELECT * FROM show_data_nodes();

Expand All @@ -51,6 +52,13 @@ WHERE e.extnamespace = n.oid
AND e.extname = 'timescaledb';

\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
\set ON_ERROR_STOP 0
-- Trying to add the data node again should fail, with or without
-- bootstrapping.
SELECT * FROM add_data_node('bootstrap_test', host => 'localhost', database => 'bootstrap_test', bootstrap=>false);
SELECT * FROM add_data_node('bootstrap_test', host => 'localhost', database => 'bootstrap_test');
\set ON_ERROR_STOP 0

DROP DATABASE bootstrap_test;

----------------------------------------------------------------------
Expand All @@ -61,7 +69,6 @@ SELECT * FROM add_data_node('bootstrap_test', host => 'localhost',
database => 'bootstrap_test', bootstrap => true);
SELECT * FROM show_data_nodes();

\c :TEST_DBNAME :ROLE_CLUSTER_SUPERUSER;
SELECT * FROM delete_data_node('bootstrap_test');

\c bootstrap_test :ROLE_CLUSTER_SUPERUSER;
Expand Down

0 comments on commit 43ad486

Please sign in to comment.