diff --git a/coordinator/provider/coordinator.go b/coordinator/provider/coordinator.go index 7162bc50e..9d1897e17 100644 --- a/coordinator/provider/coordinator.go +++ b/coordinator/provider/coordinator.go @@ -330,9 +330,9 @@ func (qc *qdbCoordinator) lockCoordinator(ctx context.Context, initialRouter boo return registerRouter() } -// TODO : unit tests // RunCoordinator side effect: it runs an asynchronous goroutine // that checks the availability of the SPQR router +// TODO : unit tests func (qc *qdbCoordinator) RunCoordinator(ctx context.Context, initialRouter bool) { if !qc.lockCoordinator(ctx, initialRouter) { return @@ -342,7 +342,7 @@ func (qc *qdbCoordinator) RunCoordinator(ctx context.Context, initialRouter bool if err != nil { spqrlog.Zero.Error(). Err(err). - Msg("faild to list key ranges") + Msg("failed to list key ranges") } for _, r := range ranges { diff --git a/test/feature/features/move.feature b/test/feature/features/move.feature index 6a42c825f..814e9ea46 100644 --- a/test/feature/features/move.feature +++ b/test/feature/features/move.feature @@ -71,6 +71,28 @@ Feature: Move test """ 001 """ + When I run SQL on host "coordinator" + """ + SHOW key_ranges + """ + Then command return code should be "0" + And SQL result should match json_exactly + """ + [ + { + "Key range ID":"krid1", + "Distribution ID":"ds1", + "Lower bound":"1", + "Shard ID":"sh2" + }, + { + "Key range ID":"krid2", + "Distribution ID":"ds1", + "Lower bound":"11", + "Shard ID":"sh2" + } + ] + """ Scenario: MOVE KEY RANGE works with many rows When I run SQL on host "shard1" @@ -111,6 +133,28 @@ Feature: Move test """ .*001(.|\n)*002(.|\n)*003(.|\n)*004(.|\n)*005 """ + When I run SQL on host "coordinator" + """ + SHOW key_ranges + """ + Then command return code should be "0" + And SQL result should match json_exactly + """ + [ + { + "Key range ID":"krid1", + "Distribution ID":"ds1", + "Lower bound":"1", + "Shard ID":"sh2" + }, + { + "Key range ID":"krid2", + "Distribution ID":"ds1", + "Lower bound":"11", + "Shard ID":"sh2" + } + ] + """ Scenario: MOVE KEY RANGE works with many tables When I run SQL on host "shard1" @@ -168,6 +212,28 @@ Feature: Move test """ 002 """ + When I run SQL on host "coordinator" + """ + SHOW key_ranges + """ + Then command return code should be "0" + And SQL result should match json_exactly + """ + [ + { + "Key range ID":"krid1", + "Distribution ID":"ds1", + "Lower bound":"1", + "Shard ID":"sh2" + }, + { + "Key range ID":"krid2", + "Distribution ID":"ds1", + "Lower bound":"11", + "Shard ID":"sh2" + } + ] + """ Scenario: Move to non-existent shard fails When I run SQL on host "coordinator" diff --git a/test/feature/features/move_recover.feature b/test/feature/features/move_recover.feature index d032d84ac..5bf06c63c 100644 --- a/test/feature/features/move_recover.feature +++ b/test/feature/features/move_recover.feature @@ -13,15 +13,13 @@ Feature: Move recover test """ Then command return code should be "0" - Scenario: Interrapted transaction continues + Scenario: Planned transaction continues When I record in qdb data transfer transaction with name "krid2" """ - {"to_shard": "sh1", + { + "to_shard": "sh1", "from_shard": "sh2", - "from_transaction": "tx2", - "to_transaction": "tx1", - "from_tx_status": "process", - "to_tx_status": "commit" + "status": "planned" } """ Then command return code should be "0" @@ -29,23 +27,14 @@ Feature: Move recover test """ CREATE TABLE xMove(w_id INT, s TEXT); insert into xMove(w_id, s) values(1, '001'); - insert into xMove(w_id, s) values(11, '002'); """ Then command return code should be "0" When I run SQL on host "shard2" """ CREATE TABLE xMove(w_id INT, s TEXT); insert into xMove(w_id, s) values(11, '002'); - BEGIN; - DELETE FROM xMove WHERE w_id = 11; - PREPARE TRANSACTION 'tx2'; - SELECT * FROM xMove """ Then command return code should be "0" - And SQL result should match regexp - """ - 002 - """ Given host "coordinator" is stopped When I execute SQL on host "coordinator2" """ @@ -71,46 +60,28 @@ Feature: Move recover test 002 """ - Scenario: Interrapted transaction rollbacks + Scenario: DataCopied transaction continues When I record in qdb data transfer transaction with name "krid2" """ - {"to_shard": "sh1", + { + "to_shard": "sh1", "from_shard": "sh2", - "from_transaction": "tx2", - "to_transaction": "tx1", - "from_tx_status": "process", - "to_tx_status": "process" + "status": "data_copied" } """ Then command return code should be "0" When I run SQL on host "shard1" """ CREATE TABLE xMove(w_id INT, s TEXT); - insert into xMove(w_id, s) values(1, '001'); - BEGIN; - insert into xMove(w_id, s) values(11, '002'); - PREPARE TRANSACTION 'tx2'; - SELECT * FROM xMove + insert into xMove(w_id, s) values (1, '001'), (11, '002'); """ Then command return code should be "0" - And SQL result should not match regexp - """ - 002 - """ When I run SQL on host "shard2" """ CREATE TABLE xMove(w_id INT, s TEXT); insert into xMove(w_id, s) values(11, '002'); - BEGIN; - DELETE FROM xMove WHERE w_id = 11; - PREPARE TRANSACTION 'tx2'; - SELECT * FROM xMove """ Then command return code should be "0" - And SQL result should match regexp - """ - 002 - """ Given host "coordinator" is stopped When I execute SQL on host "coordinator2" """ @@ -124,46 +95,14 @@ Feature: Move recover test Then command return code should be "0" And SQL result should match regexp """ - 001 - """ - And SQL result should not match regexp - """ - 002 + 001(.|\n)*002 """ When I run SQL on host "shard2" """ SELECT * FROM xMove """ Then command return code should be "0" - And SQL result should match regexp + And SQL result should not match regexp """ 002 """ - - Scenario: coordinator saves transaction to QDB and processes it on restart - When I run SQL on host "shard1" - """ - CREATE TABLE xMove(w_id INT, s TEXT); - insert into xMove(w_id, s) values(1, '001'); - """ - Then command return code should be "0" - When I run SQL on host "shard2" - """ - CREATE TABLE xMove(w_id INT, s TEXT); - insert into xMove(w_id, s) values(11, '002'); - """ - Then command return code should be "0" - When I execute SQL on host "coordinator" - """ - MOVE KEY RANGE krid1 to sh2 - """ - Then command return code should be "0" - And qdb should contain transaction "krid1" - Given host "coordinator" is stopped - When I execute SQL on host "coordinator2" - """ - SHOW routers - """ - Then command return code should be "0" - And qdb should not contain transaction "krid1" -