Skip to content

Create a new constructor for StoreScanner to avoid flaky tests - #4785

Open
miyamura-miyako wants to merge 9 commits into
apache:masterfrom
miyamura-miyako:master
Open

Create a new constructor for StoreScanner to avoid flaky tests#4785
miyamura-miyako wants to merge 9 commits into
apache:masterfrom
miyamura-miyako:master

Conversation

@miyamura-miyako

Copy link
Copy Markdown

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
miyamura-miyako marked this pull request as ready for review September 14, 2022 13:06
@Apache-HBase

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 6sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚hbaseanti0m 0sPatch does not have any anti-patterns.
+1 💚@author0m 0sThe patch does not contain any @author tags.
_ master Compile Tests _
+1 💚mvninstall2m 28smaster passed
+1 💚compile2m 20smaster passed
+1 💚checkstyle0m 30smaster passed
+1 💚spotless0m 42sbranch has no errors when running spotless:check.
-1 ❌spotbugs1m 19shbase-server in master has 1 extant spotbugs warnings.
_ Patch Compile Tests _
+1 💚mvninstall2m 9sthe patch passed
+1 💚compile2m 16sthe patch passed
+1 💚javac2m 16sthe patch passed
+1 💚checkstyle0m 31sthe patch passed
-0 ⚠️whitespace0m 0sThe 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 💚hadoopcheck7m 58sPatch does not cause any errors with Hadoop 3.2.4 3.3.4.
-1 ❌spotless0m 34spatch has 33 errors when running spotless:check, run spotless:apply to fix.
+1 💚spotbugs1m 23shbase-server generated 0 new + 0 unchanged - 1 fixed = 0 total (was 1)
_ Other Tests _
+1 💚asflicense0m 12sThe patch does not generate ASF License warnings.
28m 23s
SubsystemReport/Notes
DockerClientAPI=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#4785
Optional Testsdupname asflicense javac spotbugs hadoopcheck hbaseanti spotless checkstyle compile
unameLinux 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 toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / efc7575
Default JavaAdoptOpenJDK-1.8.0_282-b08
spotbugshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/artifact/yetus-general-check/output/branch-spotbugs-hbase-server-warnings.html
whitespacehttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/artifact/yetus-general-check/output/whitespace-eol.txt
spotlesshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/artifact/yetus-general-check/output/patch-spotless.txt
Max. process+thread count69 (vs. ulimit of 30000)
modulesC: hbase-server U: hbase-server
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/console
versionsgit=2.17.1 maven=3.6.3 spotbugs=4.2.2
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 1sDocker mode activated.
-0 ⚠️yetus0m 3sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚mvninstall2m 56smaster passed
+1 💚compile0m 47smaster passed
+1 💚shadedjars3m 51sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 30smaster passed
_ Patch Compile Tests _
+1 💚mvninstall2m 34sthe patch passed
+1 💚compile0m 47sthe patch passed
+1 💚javac0m 47sthe patch passed
+1 💚shadedjars3m 48spatch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 25sthe patch passed
_ Other Tests _
+1 💚unit203m 55shbase-server in the patch passed.
222m 15s
SubsystemReport/Notes
DockerClientAPI=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#4785
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 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 toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / efc7575
Default JavaAdoptOpenJDK-11.0.10+9
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/testReport/
Max. process+thread count3230 (vs. ulimit of 30000)
modulesC: hbase-server U: hbase-server
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/console
versionsgit=2.17.1 maven=3.6.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec1m 13sDocker mode activated.
-0 ⚠️yetus0m 2sUnprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --whitespace-eol-ignore-list --whitespace-tabs-ignore-list --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚mvninstall2m 27smaster passed
+1 💚compile0m 41smaster passed
+1 💚shadedjars3m 48sbranch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 27smaster passed
_ Patch Compile Tests _
+1 💚mvninstall2m 11sthe patch passed
+1 💚compile0m 41sthe patch passed
+1 💚javac0m 41sthe patch passed
+1 💚shadedjars3m 49spatch has no errors when building our shaded downstream artifacts.
+1 💚javadoc0m 26sthe patch passed
_ Other Tests _
+1 💚unit211m 26shbase-server in the patch passed.
228m 32s
SubsystemReport/Notes
DockerClientAPI=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#4785
Optional Testsjavac javadoc unit shadedjars compile
unameLinux 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 toolmaven
Personalitydev-support/hbase-personality.sh
git revisionmaster / efc7575
Default JavaAdoptOpenJDK-1.8.0_282-b08
Test Resultshttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/testReport/
Max. process+thread count2885 (vs. ulimit of 30000)
modulesC: hbase-server U: hbase-server
Console outputhttps://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-4785/1/console
versionsgit=2.17.1 maven=3.6.3
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@miyamura-miyako@Apache-HBase@amamiya-yuuko-1225