From b4e864214f14ac2ea691971ed21ec7c72e18769c Mon Sep 17 00:00:00 2001 From: Guanghao Zhang Date: Sat, 23 Dec 2017 21:04:27 +0800 Subject: [PATCH] HBASE-19579 Add peer lock test for shell command list_locks --- .../src/main/protobuf/LockService.proto | 1 + hbase-shell/src/test/ruby/shell/list_locks_test.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/hbase-protocol-shaded/src/main/protobuf/LockService.proto b/hbase-protocol-shaded/src/main/protobuf/LockService.proto index b8d180c..0675070 100644 --- a/hbase-protocol-shaded/src/main/protobuf/LockService.proto +++ b/hbase-protocol-shaded/src/main/protobuf/LockService.proto @@ -77,6 +77,7 @@ enum LockedResourceType { NAMESPACE = 2; TABLE = 3; REGION = 4; + PEER = 5; } message LockedResource { diff --git a/hbase-shell/src/test/ruby/shell/list_locks_test.rb b/hbase-shell/src/test/ruby/shell/list_locks_test.rb index f465a6b..2bb94fb 100644 --- a/hbase-shell/src/test/ruby/shell/list_locks_test.rb +++ b/hbase-shell/src/test/ruby/shell/list_locks_test.rb @@ -154,6 +154,25 @@ module Hbase output) end + define_test 'list peer locks' do + lock = create_exclusive_lock(5) + peer_id = '1' + + @scheduler.waitPeerExclusiveLock(lock, peer_id) + output = capture_stdout { @list_locks.command } + @scheduler.wakePeerExclusiveLock(lock, peer_id) + + assert_equal( + "PEER(1)\n" \ + "Lock type: EXCLUSIVE, procedure: {" \ + "\"className\"=>\"org.apache.hadoop.hbase.master.locking.LockProcedure\", " \ + "\"procId\"=>\"0\", \"submittedTime\"=>\"0\", \"state\"=>\"RUNNABLE\", " \ + "\"lastUpdate\"=>\"0\", " \ + "\"stateMessage\"=>[{\"lockType\"=>\"EXCLUSIVE\", \"description\"=>\"description\"}]" \ + "}\n\n", + output) + end + define_test 'list waiting locks' do table_name = org.apache.hadoop.hbase.TableName.valueOf('ns4', 'table4') -- 2.7.4