Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-24722 Address hbase-shell commands with unintentional return values #2058

Merged
merged 1 commit into from
Jul 17, 2020

Conversation

bitoffdev
Copy link
Contributor

Resolves https://issues.apache.org/jira/browse/HBASE-24722

Changelog

  • Prior to this commit, there were 13 commands that unintentionally return the
    number of lines they print (usually one). This commit ensures that they
    return the value documented by the help text, or nil if there is not a simple
    logical value to return.
  • Fixes 6 hbase-shell commands that return String rather than TrueClass or
    FalseClass
  • Use double-bang to cast truthy values to TrueClass and FalseClass so that
    ruby's to_s can reliably print true or false without using ternary operators
  • Updates tests for is_disabled, is_enabled, disable_rpc_throttle,
    enable_rpc_throttle, disable_exceed_throttle_quota,
    enable_exceed_throttle_quota, clear_deadservers, snapshot_cleanup_switch,
    snapshot_cleanup_enabled, and balancer to check return values
  • Adds new tests for balance_switch, balancer_enabled, normalizer_switch,
    normalizer_enabled, catalog_janitor_switch, catalogjanitor_enabled,
    cleaner_chore_switch, cleaner_chore_enabled, splitormerge_switch, and
    splitormerge_enabled

Note that the many assertions with explicit comparisons to booleans are intentional (ie. assert(return_value == false)). In ruby, this test makes sure that return value is actually an instance of TrueClass or FalseClass, which makes these tests much more potent. Since every ruby object can be cast to a boolean, we don't want to just assert(return_value).

Testing

  • Of the 19 commands updated, 17 are covered by unit testing (a number of the unit tests are introduced by this PR).
  • I manually tested my changes to the 2 commands not covered by unit tests: normalize and clear_block_cache. I'd love to get these commands covered as well, but I believe that is out of scope for this ticket since testing those commands should be a little more extensive.

- Prior to this commit, there were 13 commands that unintentionally return the
  number of lines they print (usually one). This commit ensures that they
  return the value documented by the help text, or nil if there is not a simple
  logical value to return.
- Fixes 6 hbase-shell commands that return String rather than TrueClass or
  FalseClass
- Use double-bang to cast truthy values to TrueClass and FalseClass so that
  ruby's to_s can reliably print true or false without using ternary operators
- Updates tests for is_disabled, is_enabled, disable_rpc_throttle,
  enable_rpc_throttle, disable_exceed_throttle_quota,
  enable_exceed_throttle_quota, clear_deadservers, snapshot_cleanup_switch,
  snapshot_cleanup_enabled, and balancer to check return values
- Adds new tests for balance_switch, balancer_enabled, normalizer_switch,
  normalizer_enabled, catalog_janitor_switch, catalogjanitor_enabled,
  cleaner_chore_switch, cleaner_chore_enabled, splitormerge_switch, and
  splitormerge_enabled
@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 0m 30s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
_ master Compile Tests _
_ Patch Compile Tests _
-0 ⚠️ rubocop 0m 57s The patch generated 25 new + 300 unchanged - 6 fixed = 325 total (was 306)
+1 💚 whitespace 0m 0s The patch has no whitespace issues.
_ Other Tests _
+1 💚 asflicense 0m 12s The patch does not generate ASF License warnings.
2m 58s
Subsystem Report/Notes
Docker Client=19.03.12 Server=19.03.12 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-2058/1/artifact/yetus-general-check/output/Dockerfile
GITHUB PR #2058
Optional Tests dupname asflicense rubocop
uname Linux 262dd5130c9e 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 3bd5421
rubocop https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-2058/1/artifact/yetus-general-check/output/diff-patch-rubocop.txt
Max. process+thread count 51 (vs. ulimit of 12500)
modules C: hbase-shell U: hbase-shell
Console output https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-2058/1/console
versions git=2.17.1 maven=(cecedd343002696d0abb50b32b541b8a6ba2883f) rubocop=0.80.0
Powered by Apache Yetus 0.11.1 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 0m 24s Docker mode activated.
-0 ⚠️ yetus 0m 2s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚 mvninstall 4m 1s master passed
+1 💚 javadoc 0m 14s master passed
_ Patch Compile Tests _
+1 💚 mvninstall 3m 43s the patch passed
+1 💚 javadoc 0m 12s the patch passed
_ Other Tests _
+1 💚 unit 6m 52s hbase-shell in the patch passed.
16m 29s
Subsystem Report/Notes
Docker Client=19.03.12 Server=19.03.12 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-2058/1/artifact/yetus-jdk8-hadoop3-check/output/Dockerfile
GITHUB PR #2058
Optional Tests javac javadoc unit
uname Linux 0bf0ae7cf57d 4.15.0-101-generic #102-Ubuntu SMP Mon May 11 10:07:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 3bd5421
Default Java 1.8.0_232
Test Results https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-2058/1/testReport/
Max. process+thread count 1528 (vs. ulimit of 12500)
modules C: hbase-shell U: hbase-shell
Console output https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-2058/1/console
versions git=2.17.1 maven=(cecedd343002696d0abb50b32b541b8a6ba2883f)
Powered by Apache Yetus 0.11.1 https://yetus.apache.org

This message was automatically generated.

@bitoffdev bitoffdev changed the title HBASE-24722 Update commands with unintentional return values HBASE-24722 Address hbase-shell commands with unintentional return values Jul 13, 2020
@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Comment
+0 🆗 reexec 1m 43s Docker mode activated.
-0 ⚠️ yetus 0m 3s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚 mvninstall 6m 3s master passed
+1 💚 javadoc 0m 18s master passed
_ Patch Compile Tests _
+1 💚 mvninstall 5m 56s the patch passed
+1 💚 javadoc 0m 15s the patch passed
_ Other Tests _
+1 💚 unit 8m 27s hbase-shell in the patch passed.
24m 5s
Subsystem Report/Notes
Docker Client=19.03.12 Server=19.03.12 base: https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-2058/1/artifact/yetus-jdk11-hadoop3-check/output/Dockerfile
GITHUB PR #2058
Optional Tests javac javadoc unit
uname Linux 0c0286776f12 4.15.0-101-generic #102-Ubuntu SMP Mon May 11 10:07:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 3bd5421
Default Java 2020-01-14
Test Results https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-2058/1/testReport/
Max. process+thread count 1603 (vs. ulimit of 12500)
modules C: hbase-shell U: hbase-shell
Console output https://builds.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-2058/1/console
versions git=2.17.1 maven=(cecedd343002696d0abb50b32b541b8a6ba2883f)
Powered by Apache Yetus 0.11.1 https://yetus.apache.org

This message was automatically generated.

@@ -31,7 +31,7 @@ def help
end

def command(enableDisable)
prev_state = admin.balance_switch(enableDisable) ? 'true' : 'false'
prev_state = !!admin.balance_switch(enableDisable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idiom convertion (java to ruby)


output = capture_stdout { result = command(:splitormerge_enabled, 'MERGE') }
assert(output.include?('true'))
assert(result == true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet

@saintstack saintstack merged commit 4b3ef81 into apache:master Jul 17, 2020
saintstack pushed a commit to saintstack/hbase that referenced this pull request Jul 17, 2020
…2058)

- Prior to this commit, there were 13 commands that unintentionally return the
  number of lines they print (usually one). This commit ensures that they
  return the value documented by the help text, or nil if there is not a simple
  logical value to return.
- Fixes 6 hbase-shell commands that return String rather than TrueClass or
  FalseClass
- Use double-bang to cast truthy values to TrueClass and FalseClass so that
  ruby's to_s can reliably print true or false without using ternary operators
- Updates tests for is_disabled, is_enabled, disable_rpc_throttle,
  enable_rpc_throttle, disable_exceed_throttle_quota,
  enable_exceed_throttle_quota, clear_deadservers, snapshot_cleanup_switch,
  snapshot_cleanup_enabled, and balancer to check return values
- Adds new tests for balance_switch, balancer_enabled, normalizer_switch,
  normalizer_enabled, catalog_janitor_switch, catalogjanitor_enabled,
  cleaner_chore_switch, cleaner_chore_enabled, splitormerge_switch, and
  splitormerge_enabled

signed-off-by: stack <stack@apache.org>
clarax pushed a commit to clarax/hbase that referenced this pull request Nov 15, 2020
…2058)

- Prior to this commit, there were 13 commands that unintentionally return the
  number of lines they print (usually one). This commit ensures that they
  return the value documented by the help text, or nil if there is not a simple
  logical value to return.
- Fixes 6 hbase-shell commands that return String rather than TrueClass or
  FalseClass
- Use double-bang to cast truthy values to TrueClass and FalseClass so that
  ruby's to_s can reliably print true or false without using ternary operators
- Updates tests for is_disabled, is_enabled, disable_rpc_throttle,
  enable_rpc_throttle, disable_exceed_throttle_quota,
  enable_exceed_throttle_quota, clear_deadservers, snapshot_cleanup_switch,
  snapshot_cleanup_enabled, and balancer to check return values
- Adds new tests for balance_switch, balancer_enabled, normalizer_switch,
  normalizer_enabled, catalog_janitor_switch, catalogjanitor_enabled,
  cleaner_chore_switch, cleaner_chore_enabled, splitormerge_switch, and
  splitormerge_enabled

signed-off-by: stack <stack@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants