Skip to content

ATLAS-5068: Improve Unit Test Coverage for Hive-bridge Module - #425

Merged
mandarambawane merged 1 commit into
apache:masterfrom
aditya-gupta36:ATLAS-5068
Aug 30, 2025
Merged

ATLAS-5068: Improve Unit Test Coverage for Hive-bridge Module#425
mandarambawane merged 1 commit into
apache:masterfrom
aditya-gupta36:ATLAS-5068

Conversation

@aditya-gupta36

@aditya-gupta36 aditya-gupta36 commented Aug 12, 2025

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Added Unit TCs for Hive module

How was this patch tested?

@mneethiraj
mneethiraj requested a review from Copilot August 12, 2025 15:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds comprehensive unit test coverage for the Hive-bridge module, implementing test classes for core event handling functionality. The goal is to improve test coverage by adding unit tests for the most critical classes in the hive-bridge module.

  • Added unit tests for 6 core Hive event classes including DropTable, DropDatabase, CreateTable, CreateHiveProcess, CreateDatabase, and BaseHiveEvent
  • Implemented comprehensive test scenarios covering constructor validation, notification message generation, entity processing, and edge cases
  • Added helper methods and mock setups to support complex testing scenarios with proper isolation

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
DropTableTest.java Tests for table deletion events including metastore and non-metastore hook scenarios, entity qualification, and integration workflows
DropDatabaseTest.java Tests for database deletion events covering both metastore and hive entity processing paths with various edge cases
CreateTableTest.java Comprehensive tests for table creation events including DDL operations, external tables, HBase integration, and reflection-based private method testing
CreateHiveProcessTest.java Tests for Hive process creation covering lineage processing, column lineage, DDL operations, and complex workflow scenarios
CreateDatabaseTest.java Tests for database creation events including metastore hook scenarios and entity generation
BaseHiveEventTest.java Extensive tests for the base event class covering utility methods, entity processing, qualified name generation, and constant validation

verify(context, times(1)).removeFromKnownTable(any(String.class));
}

/* @Test

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

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

Remove commented-out test method or uncomment and implement it properly. Commented code reduces maintainability.

Suggested change
/* @Test
@Test

Copilot uses AI. Check for mistakes.
assertEquals(1, notifications.size());
assertTrue(notifications.get(0) instanceof EntityDeleteRequestV2);

// verify(context).removeFromKnownDatabase(anyString());

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

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

Remove commented-out verification code or uncomment it if the verification is needed for the test.

Suggested change
// verify(context).removeFromKnownDatabase(anyString());
verify(context).removeFromKnownDatabase(anyString());

Copilot uses AI. Check for mistakes.
}

// =================== getHiveMetastoreEntities Tests ===================
/* @Test

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

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

Multiple commented-out test methods should be removed or properly implemented. This reduces code maintainability and can cause confusion.

Copilot uses AI. Check for mistakes.
// So we should get null result due to skipProcess logic
AssertJUnit.assertNull("Entities should be null for self lineage scenario", entities);
}*/

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

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

Large block of commented-out test code should be removed to improve maintainability.

Suggested change

Copilot uses AI. Check for mistakes.
import org.apache.atlas.type.AtlasTypeUtil;
import org.apache.hadoop.hive.metastore.IHMSHandler;
import org.apache.hadoop.hive.metastore.api.Database;
//import org.apache.hadoop.hive.metastore.api.DatabaseType;

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

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

Remove unused commented import statement.

Suggested change
//import org.apache.hadoop.hive.metastore.api.DatabaseType;

Copilot uses AI. Check for mistakes.
import java.util.*;

import static org.mockito.Mockito.*;
import static org.junit.Assert.assertNotNull;

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Mixed usage of TestNG and JUnit assertions. The file primarily uses TestNG's AssertJUnit but also imports JUnit's Assert. Consider standardizing on one assertion library for consistency.

Suggested change
import static org.junit.Assert.assertNotNull;

Copilot uses AI. Check for mistakes.
when(database.getOwnerType()).thenReturn(PrincipalType.USER);

when(database.getCatalogName()).thenReturn("hive");
// when(database.getCreateTime()).thenReturn(1753349206);

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

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

Remove commented-out mock setup code or uncomment it if needed for the test.

Suggested change
// when(database.getCreateTime()).thenReturn(1753349206);

Copilot uses AI. Check for mistakes.



/* @Test

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

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

Multiple large blocks of commented-out test methods should be removed to improve code maintainability.

Copilot uses AI. Check for mistakes.
@mneethiraj

Copy link
Copy Markdown
Contributor

@aditya-gupta36 - the build fails with the following error. Please review and update.

atlas-build  | [ERROR] Failed to execute goal org.apache.rat:apache-rat-plugin:0.13:check (rat-check) on project hive-bridge: Too many files with unapproved license: 10 See RAT report in: /home/atlas/src/addons/hive-bridge/target/rat.txt -> [Help 1]
atlas-build  | [ERROR] 
atlas-build  | [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
atlas-build  | [ERROR] Re-run Maven using the -X switch to enable full debug logging.
atlas-build  | [ERROR] 
atlas-build  | [ERROR] For more information about the errors and possible solutions, please read the following articles:
atlas-build  | [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
atlas-build  | [ERROR] 
atlas-build  | [ERROR] After correcting the problems, you can resume the build with the command
atlas-build  | [ERROR]   mvn <args> -rf :hive-bridge

@aditya-gupta36

Copy link
Copy Markdown
Contributor Author

@mneethiraj Sir, Thanks for Feedback and update. Will look into it.

Comment thread addons/hive-bridge/pom.xml
@mandarambawane
mandarambawane merged commit 0e87796 into apache:master Aug 30, 2025
1 check passed
mandarambawane pushed a commit that referenced this pull request Feb 25, 2026
Sign up for free to 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.

5 participants