hbase icon indicating copy to clipboard operation
hbase copied to clipboard

Create a new constructor for StoreScanner to avoid flaky tests

Open miyamura-miyako opened this issue 3 years ago • 3 comments

What is the purpose of this PR

  • This PR fixes a flaky test caused by the non-determinism of the amount of time that the unit test testWildCardTtlScan() takes to run.
  • In other words, the test may randomly fail or pass when run on a slow enough machine.

Reproduce the test failure

  • Run test testWildCardTtlScan() for many times in a slow enough machine.
  • To reproduce the failure more often, we can add Thread.sleep(1000); after getting the current time (line 862) and before creating the object of StoreScanner(line 877) in the TestStoreScanner.java file to simulate a slow machine.

Expected result:

  • The test should run successfully regardless of the amount of time between getting current time (line 862) and creating the object of StoreScanner (line 877), regardless of the speed of running tests.

Actual result:

  • We can get the stack trace of test failure as below
 java.lang.AssertionError: expected:<2> but was:<0>
    at org.junit.Assert.fail(Assert.java:89)
    at org.junit.Assert.failNotEquals(Assert.java:835)
    at org.junit.Assert.assertEquals(Assert.java:647)
    at org.junit.Assert.assertEquals(Assert.java:633)
    at org.apache.hadoop.hbase.regionserver.TestStoreScanner.testWildCardTtlScan(TestStoreScanner.java:856)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Why the test fails

  • The time to create the keyValue array is different from that of creating the StoreScanner object.

    i.e., for line 175 in file StoreScanner.java:

    this.oldestUnexpiredTS = scan.isRaw() ? 0L : now - scanInfo.getTtl();

    the variable "now" is different from the variable "now" that line 836 gets in the TestStoreScanner.java file:

    long now = System.currentTimeMillis();

Fix

Create a new constructor for StoreScanner and modify the internal constructor to receive a new parameter, which enables us to set the start time of finding kvs.

miyamura-miyako avatar Sep 14 '22 13:09 miyamura-miyako

:broken_heart: -1 overall

Vote Subsystem Runtime Comment
+0 :ok: reexec 1m 6s Docker mode activated.
_ Prechecks _
+1 :green_heart: dupname 0m 0s No case conflicting files found.
+1 :green_heart: hbaseanti 0m 0s Patch does not have any anti-patterns.
+1 :green_heart: @author 0m 0s The patch does not contain any @author tags.
_ master Compile Tests _
+1 :green_heart: mvninstall 2m 28s master passed
+1 :green_heart: compile 2m 20s master passed
+1 :green_heart: checkstyle 0m 30s master passed
+1 :green_heart: spotless 0m 42s branch has no errors when running spotless:check.
-1 :x: spotbugs 1m 19s hbase-server in master has 1 extant spotbugs warnings.
_ Patch Compile Tests _
+1 :green_heart: mvninstall 2m 9s the patch passed
+1 :green_heart: compile 2m 16s the patch passed
+1 :green_heart: javac 2m 16s the patch passed
+1 :green_heart: checkstyle 0m 31s the patch passed
-0 :warning: whitespace 0m 0s The patch has 1 line(s) that end in whitespace. Use git apply --whitespace=fix <<patch_file>>. Refer https://git-scm.com/docs/git-apply
+1 :green_heart: hadoopcheck 7m 58s Patch does not cause any errors with Hadoop 3.2.4 3.3.4.
-1 :x: spotless 0m 34s patch has 33 errors when running spotless:check, run spotless:apply to fix.
+1 :green_heart: spotbugs 1m 23s hbase-server generated 0 new + 0 unchanged - 1 fixed = 0 total (was 1)
_ Other Tests _
+1 :green_heart: asflicense 0m 12s The patch does not generate ASF License warnings.
28m 23s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/artifact/yetus-general-check/output/Dockerfile
GITHUB PR https://github.com/apache/hbase/pull/4785
Optional Tests dupname asflicense javac spotbugs hadoopcheck hbaseanti spotless checkstyle compile
uname Linux 3d015054ab02 5.4.0-124-generic #140-Ubuntu SMP Thu Aug 4 02:23:37 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / efc757577a
Default Java AdoptOpenJDK-1.8.0_282-b08
spotbugs https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/artifact/yetus-general-check/output/branch-spotbugs-hbase-server-warnings.html
whitespace https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/artifact/yetus-general-check/output/whitespace-eol.txt
spotless https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/artifact/yetus-general-check/output/patch-spotless.txt
Max. process+thread count 69 (vs. ulimit of 30000)
modules C: hbase-server U: hbase-server
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/console
versions git=2.17.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

Apache-HBase avatar Sep 14 '22 13:09 Apache-HBase

:confetti_ball: +1 overall

Vote Subsystem Runtime Comment
+0 :ok: reexec 1m 1s Docker mode activated.
-0 :warning: 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 :green_heart: mvninstall 2m 56s master passed
+1 :green_heart: compile 0m 47s master passed
+1 :green_heart: shadedjars 3m 51s branch has no errors when building our shaded downstream artifacts.
+1 :green_heart: javadoc 0m 30s master passed
_ Patch Compile Tests _
+1 :green_heart: mvninstall 2m 34s the patch passed
+1 :green_heart: compile 0m 47s the patch passed
+1 :green_heart: javac 0m 47s the patch passed
+1 :green_heart: shadedjars 3m 48s patch has no errors when building our shaded downstream artifacts.
+1 :green_heart: javadoc 0m 25s the patch passed
_ Other Tests _
+1 :green_heart: unit 203m 55s hbase-server in the patch passed.
222m 15s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/artifact/yetus-jdk11-hadoop3-check/output/Dockerfile
GITHUB PR https://github.com/apache/hbase/pull/4785
Optional Tests javac javadoc unit shadedjars compile
uname Linux 37c4da9bf207 5.4.0-124-generic #140-Ubuntu SMP Thu Aug 4 02:23:37 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / efc757577a
Default Java AdoptOpenJDK-11.0.10+9
Test Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/testReport/
Max. process+thread count 3230 (vs. ulimit of 30000)
modules C: hbase-server U: hbase-server
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/console
versions git=2.17.1 maven=3.6.3
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

Apache-HBase avatar Sep 14 '22 17:09 Apache-HBase

:confetti_ball: +1 overall

Vote Subsystem Runtime Comment
+0 :ok: reexec 1m 13s Docker mode activated.
-0 :warning: 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 :green_heart: mvninstall 2m 27s master passed
+1 :green_heart: compile 0m 41s master passed
+1 :green_heart: shadedjars 3m 48s branch has no errors when building our shaded downstream artifacts.
+1 :green_heart: javadoc 0m 27s master passed
_ Patch Compile Tests _
+1 :green_heart: mvninstall 2m 11s the patch passed
+1 :green_heart: compile 0m 41s the patch passed
+1 :green_heart: javac 0m 41s the patch passed
+1 :green_heart: shadedjars 3m 49s patch has no errors when building our shaded downstream artifacts.
+1 :green_heart: javadoc 0m 26s the patch passed
_ Other Tests _
+1 :green_heart: unit 211m 26s hbase-server in the patch passed.
228m 32s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/artifact/yetus-jdk8-hadoop3-check/output/Dockerfile
GITHUB PR https://github.com/apache/hbase/pull/4785
Optional Tests javac javadoc unit shadedjars compile
uname Linux 8dd1bda2505e 5.4.0-122-generic #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / efc757577a
Default Java AdoptOpenJDK-1.8.0_282-b08
Test Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/testReport/
Max. process+thread count 2885 (vs. ulimit of 30000)
modules C: hbase-server U: hbase-server
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/console
versions git=2.17.1 maven=3.6.3
Powered by Apache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

Apache-HBase avatar Sep 14 '22 17:09 Apache-HBase