[ 
https://issues.apache.org/jira/browse/HIVE-29231?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated HIVE-29231:
----------------------------------
    Labels: pull-request-available  (was: )

> Fix flaky TestEmbeddedHiveMetaStore.testDatabase by enforcing deterministic 
> database lookup
> -------------------------------------------------------------------------------------------
>
>                 Key: HIVE-29231
>                 URL: https://issues.apache.org/jira/browse/HIVE-29231
>             Project: Hive
>          Issue Type: Improvement
>          Components: Test
>         Environment: {code:java}
> Maven home: /home/anicaazhu/.sdkman/candidates/maven/current
> Java version: 21.0.7, vendor: Oracle Corporation, runtime: 
> /home/anicaazhu/.sdkman/candidates/java/21.0.7-oracle
> Default locale: en_US, platform encoding: UTF-8
> OS name: "linux", version: "6.16.8-arch3-1", arch: "amd64", family: 
> "unix"{code}
>            Reporter: Kangwei Zhu
>            Priority: Minor
>              Labels: pull-request-available
>   Original Estimate: 0.25h
>  Remaining Estimate: 0.25h
>
> The test 
> org.apache.hadoop.hive.metastore.TestEmbeddedHiveMetaStore.testDatabase(standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java)
>  passed using normal maven-test, but showed Non-deterministic behavior under 
> NonDex(https://github.com/TestingResearchIllinois/NonDex) and thus failed. 
> NonDex is a tool for detecting hidden assumptions in code by exploring 
> non-deterministic behaviors of specifications that allow multiple valid 
> implementations.
>  
> Some of the error messages are:
> {code:java}
> Build Failure observed:
> java.lang.AssertionError: first database is not testdb1 in list: []{code}
>  
> Steps to reproduce:
> {code:java}
> mvn -pl standalone-metastore/metastore-server 
> edu.illinois:nondex-maven-plugin:2.2.1:nondex 
> -Dtest=org.apache.hadoop.hive.metastore.TestEmbeddedHiveMetaStore#testDatabase
>  {code}
>  
> Root cause:
> The test asserted database existence using getDatabases(".*") which relies on 
> cached database lists that may return stale results when nondex randomizes 
> test execution. This led to nondeterministic test outcomes where databases 
> existed but were not found in the cached list.
>  
> Fix:
> Replace getDatabases(".*") with direct getDatabase(name) calls in 
> TestHiveMetaStore class's testDatabase method. This ensures consistent 
> behavior regardless of test shuffling. Additionally, I believe this improve 
> the harness of tests without altering and damaging the core database 
> operations being tested(add, find, drop).
> Confirm Fixed:
> re-run
> {code:java}
> mvn -pl standalone-metastore/metastore-server 
> edu.illinois:nondex-maven-plugin:2.2.1:nondex 
> -Dtest=org.apache.hadoop.hive.metastore.TestEmbeddedHiveMetaStore#testDatabase
>  {code}
> And the result is Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, BUILD 
> SUCCESS



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to