Repository: sentry Updated Branches: refs/heads/master b2107fc16 -> 7bac9f4f9
SENTRY-1803: HMSFollower should handle the case of multiple notifications with the same ID (Sergio Pena via Vamsee Yarlagadda) Project: http://git-wip-us.apache.org/repos/asf/sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/7bac9f4f Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/7bac9f4f Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/7bac9f4f Branch: refs/heads/master Commit: 7bac9f4f979e7d5e06f55dc6a7c0714ee3655ee7 Parents: b2107fc Author: Vamsee Yarlagadda <[email protected]> Authored: Wed Aug 16 14:32:57 2017 -0700 Committer: Vamsee Yarlagadda <[email protected]> Committed: Wed Aug 16 14:32:57 2017 -0700 ---------------------------------------------------------------------- .../provider/db/service/model/package.jdo | 5 +- .../main/resources/008-SENTRY-1569.derby.sql | 5 -- .../main/resources/008-SENTRY-1569.mysql.sql | 6 +-- .../main/resources/008-SENTRY-1569.oracle.sql | 6 +-- .../main/resources/008-SENTRY-1569.postgres.sql | 6 +-- .../src/main/resources/sentry-db2-2.0.0.sql | 6 +-- .../src/main/resources/sentry-derby-2.0.0.sql | 4 -- .../src/main/resources/sentry-mysql-2.0.0.sql | 6 +-- .../src/main/resources/sentry-oracle-2.0.0.sql | 6 +-- .../main/resources/sentry-postgres-2.0.0.sql | 6 +-- .../sentry-upgrade-db2-1.7.0-to-2.0.0.sql | 4 -- .../db/service/persistent/TestSentryStore.java | 56 ++++++++++++++++++++ 12 files changed, 65 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo index e8982f6..77ec491 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/model/package.jdo @@ -297,7 +297,6 @@ </field> <field name="notificationID"> <column name="NOTIFICATION_ID" jdbc-type="BIGINT" allows-null="false"/> - <index name="NOTIFICATIONID" unique="true"/> </field> <field name ="pathChange"> <column name="PATH_CHANGE" length="4000" jdbc-type="VARCHAR" allows-null="false"/> @@ -306,8 +305,8 @@ <column name="CREATE_TIME_MS" jdbc-type="BIGINT"/> </field> </class> - <class name="MSentryHmsNotification" table="SENTRY_HMS_NOTIFICATION_ID" identity-type="application" detachable="true"> - <field name="notificationId" primary-key="true"> + <class name="MSentryHmsNotification" table="SENTRY_HMS_NOTIFICATION_ID" identity-type="nondurable" detachable="true"> + <field name="notificationId"> <column name="NOTIFICATION_ID" jdbc-type="BIGINT" allows-null="false"/> </field> </class> http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.derby.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.derby.sql b/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.derby.sql index 2a017ff..4afa2e0 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.derby.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.derby.sql @@ -20,14 +20,9 @@ CREATE TABLE SENTRY_PATH_CHANGE -- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] ALTER TABLE SENTRY_PATH_CHANGE ADD CONSTRAINT SENTRY_PATH_CHANGE_PK PRIMARY KEY (CHANGE_ID); -CREATE UNIQUE INDEX NOTIFICATIONID ON SENTRY_PATH_CHANGE (NOTIFICATION_ID); - -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] CREATE TABLE SENTRY_HMS_NOTIFICATION_ID ( NOTIFICATION_ID BIGINT NOT NULL ); - --- Constraints for table SENTRY_HMS_NOTIFICATION_ID for class [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] -ALTER TABLE SENTRY_HMS_NOTIFICATION_ID ADD CONSTRAINT SENTRY_NOTIFICATION_PK PRIMARY KEY (NOTIFICATION_ID); http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.mysql.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.mysql.sql b/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.mysql.sql index b587e40..8636fec 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.mysql.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.mysql.sql @@ -17,12 +17,8 @@ CREATE TABLE `SENTRY_PATH_CHANGE` CONSTRAINT `SENTRY_PATH_CHANGE_PK` PRIMARY KEY (`CHANGE_ID`) ) ENGINE=INNODB; --- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] -CREATE UNIQUE INDEX `NOTIFICATIONID` ON `SENTRY_PATH_CHANGE` (`NOTIFICATION_ID`); - -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] CREATE TABLE `SENTRY_HMS_NOTIFICATION_ID` ( - `NOTIFICATION_ID` BIGINT NOT NULL, - CONSTRAINT `SENTRY_NOTIFICATION_PK` PRIMARY KEY (`NOTIFICATION_ID`) + `NOTIFICATION_ID` BIGINT NOT NULL )ENGINE=INNODB; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.oracle.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.oracle.sql b/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.oracle.sql index 860f992..c3c374b 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.oracle.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.oracle.sql @@ -18,14 +18,10 @@ CREATE TABLE "SENTRY_PATH_CHANGE" ); -- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] -CREATE UNIQUE INDEX "NOTIFICATIONID" ON "SENTRY_PATH_CHANGE" ("NOTIFICATION_ID"); ALTER TABLE "SENTRY_PATH_CHANGE" ADD CONSTRAINT SENTRY_PATH_CHANGE_PK PRIMARY KEY ("CHANGE_ID"); -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] CREATE TABLE "SENTRY_HMS_NOTIFICATION_ID" ( "NOTIFICATION_ID" NUMBER NOT NULL -); - --- Constraints for table SENTRY_HMS_NOTIFICATION_ID for class [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] -ALTER TABLE "SENTRY_HMS_NOTIFICATION_ID" ADD CONSTRAINT "NOTIFICATION_PRIVILEGE_PK" PRIMARY KEY ("NOTIFICATION_ID"); \ No newline at end of file +); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.postgres.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.postgres.sql b/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.postgres.sql index c7c38e3..d168bf5 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.postgres.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/008-SENTRY-1569.postgres.sql @@ -17,12 +17,8 @@ CREATE TABLE "SENTRY_PATH_CHANGE" CONSTRAINT "SENTRY_PATH_CHANGE_PK" PRIMARY KEY ("CHANGE_ID") ); --- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] -CREATE UNIQUE INDEX "NOTIFICATIONID" ON "SENTRY_PATH_CHANGE" ("NOTIFICATION_ID"); - -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] CREATE TABLE "SENTRY_HMS_NOTIFICATION_ID" ( - "NOTIFICATION_ID" bigint NOT NULL, - CONSTRAINT "NOTIFICATION_PRIVILEGE_PK" PRIMARY KEY ("NOTIFICATION_ID") + "NOTIFICATION_ID" bigint NOT NULL ); http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/sentry-db2-2.0.0.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry-db2-2.0.0.sql b/sentry-provider/sentry-provider-db/src/main/resources/sentry-db2-2.0.0.sql index 01be509..69ef5b7 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/sentry-db2-2.0.0.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry-db2-2.0.0.sql @@ -241,13 +241,9 @@ CREATE TABLE SENTRY_PATH_CHANGE -- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] ALTER TABLE SENTRY_PATH_CHANGE ADD CONSTRAINT SENTRY_PATH_CHANGE_PK PRIMARY KEY (CHANGE_ID); -CREATE UNIQUE INDEX NOTIFICATIONID ON SENTRY_PATH_CHANGE (NOTIFICATION_ID); -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] CREATE TABLE SENTRY_HMS_NOTIFICATION_ID ( NOTIFICATION_ID bigint NOT NULL -); - --- Constraints for table SENTRY_HMS_NOTIFICATION_ID for class [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] -ALTER TABLE SENTRY_HMS_NOTIFICATION_ID ADD CONSTRAINT NOTIFICATION_PRIVILEGE_PK PRIMARY KEY (NOTIFICATION_ID); \ No newline at end of file +); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/sentry-derby-2.0.0.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry-derby-2.0.0.sql b/sentry-provider/sentry-provider-db/src/main/resources/sentry-derby-2.0.0.sql index dca9e47..0db7ba9 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/sentry-derby-2.0.0.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry-derby-2.0.0.sql @@ -241,7 +241,6 @@ CREATE TABLE SENTRY_PATH_CHANGE -- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] ALTER TABLE SENTRY_PATH_CHANGE ADD CONSTRAINT SENTRY_PATH_CHANGE_PK PRIMARY KEY (CHANGE_ID); -CREATE UNIQUE INDEX NOTIFICATIONID ON SENTRY_PATH_CHANGE (NOTIFICATION_ID); -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] @@ -249,6 +248,3 @@ CREATE TABLE SENTRY_HMS_NOTIFICATION_ID ( NOTIFICATION_ID BIGINT NOT NULL ); - --- Constraints for table SENTRY_HMS_NOTIFICATION_ID for class [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] -ALTER TABLE SENTRY_HMS_NOTIFICATION_ID ADD CONSTRAINT SENTRY_NOTIFICATION_PK PRIMARY KEY (NOTIFICATION_ID); http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-2.0.0.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-2.0.0.sql b/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-2.0.0.sql index 0189724..183481a 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-2.0.0.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-2.0.0.sql @@ -275,12 +275,8 @@ CREATE TABLE `SENTRY_PATH_CHANGE` CONSTRAINT `SENTRY_PATH_CHANGE_PK` PRIMARY KEY (`CHANGE_ID`) ) ENGINE=INNODB; --- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] -CREATE UNIQUE INDEX `NOTIFICATIONID` ON `SENTRY_PATH_CHANGE` (`NOTIFICATION_ID`); - -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] CREATE TABLE `SENTRY_HMS_NOTIFICATION_ID` ( - `NOTIFICATION_ID` BIGINT NOT NULL, - CONSTRAINT `SENTRY_NOTIFICATION_PK` PRIMARY KEY (`NOTIFICATION_ID`) + `NOTIFICATION_ID` BIGINT NOT NULL )ENGINE=INNODB; http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-2.0.0.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-2.0.0.sql b/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-2.0.0.sql index ecb76fc..cf4f0ed 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-2.0.0.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-2.0.0.sql @@ -256,14 +256,10 @@ CREATE TABLE "SENTRY_PATH_CHANGE" ); -- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] -CREATE UNIQUE INDEX "NOTIFICATIONID" ON "SENTRY_PATH_CHANGE" ("NOTIFICATION_ID"); ALTER TABLE "SENTRY_PATH_CHANGE" ADD CONSTRAINT SENTRY_PATH_CHANGE_PK PRIMARY KEY ("CHANGE_ID"); -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] CREATE TABLE "SENTRY_HMS_NOTIFICATION_ID" ( "NOTIFICATION_ID" NUMBER NOT NULL -); - --- Constraints for table SENTRY_HMS_NOTIFICATION_ID for class [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] -ALTER TABLE "SENTRY_HMS_NOTIFICATION_ID" ADD CONSTRAINT "NOTIFICATION_PRIVILEGE_PK" PRIMARY KEY ("NOTIFICATION_ID"); \ No newline at end of file +); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-2.0.0.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-2.0.0.sql b/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-2.0.0.sql index 3e5d554..5974ed9 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-2.0.0.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-2.0.0.sql @@ -263,14 +263,10 @@ CREATE TABLE "SENTRY_PATH_CHANGE" CONSTRAINT "SENTRY_PATH_CHANGE_PK" PRIMARY KEY ("CHANGE_ID") ); --- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] -CREATE UNIQUE INDEX "NOTIFICATIONID" ON "SENTRY_PATH_CHANGE" ("NOTIFICATION_ID"); - -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] CREATE TABLE "SENTRY_HMS_NOTIFICATION_ID" ( - "NOTIFICATION_ID" bigint NOT NULL, - CONSTRAINT "NOTIFICATION_PRIVILEGE_PK" PRIMARY KEY ("NOTIFICATION_ID") + "NOTIFICATION_ID" bigint NOT NULL ); COMMIT; http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/main/resources/sentry-upgrade-db2-1.7.0-to-2.0.0.sql ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry-upgrade-db2-1.7.0-to-2.0.0.sql b/sentry-provider/sentry-provider-db/src/main/resources/sentry-upgrade-db2-1.7.0-to-2.0.0.sql index ac85968..20c50b7 100644 --- a/sentry-provider/sentry-provider-db/src/main/resources/sentry-upgrade-db2-1.7.0-to-2.0.0.sql +++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry-upgrade-db2-1.7.0-to-2.0.0.sql @@ -88,7 +88,6 @@ CREATE TABLE SENTRY_PATH_CHANGE -- Constraints for table SENTRY_PATH_CHANGE for class [org.apache.sentry.provider.db.service.model.MSentryPathChange] ALTER TABLE SENTRY_PATH_CHANGE ADD CONSTRAINT SENTRY_PATH_CHANGE_PK PRIMARY KEY (CHANGE_ID); -CREATE UNIQUE INDEX NOTIFICATIONID ON SENTRY_PATH_CHANGE (NOTIFICATION_ID); -- Table SENTRY_HMS_NOTIFICATION_ID for classes [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] CREATE TABLE SENTRY_HMS_NOTIFICATION_ID @@ -96,8 +95,5 @@ CREATE TABLE SENTRY_HMS_NOTIFICATION_ID NOTIFICATION_ID bigint NOT NULL ); --- Constraints for table SENTRY_HMS_NOTIFICATION_ID for class [org.apache.sentry.provider.db.service.model.MSentryHmsNotification] -ALTER TABLE SENTRY_HMS_NOTIFICATION_ID ADD CONSTRAINT NOTIFICATION_PRIVILEGE_PK PRIMARY KEY (NOTIFICATION_ID); - -- Version update UPDATE SENTRY_VERSION SET SCHEMA_VERSION='2.0.0', VERSION_COMMENT='Sentry release version 2.0.0' WHERE VER_ID=1; http://git-wip-us.apache.org/repos/asf/sentry/blob/7bac9f4f/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java index d35cafb..2d6b92a 100644 --- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java +++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/service/persistent/TestSentryStore.java @@ -2478,6 +2478,62 @@ public class TestSentryStore extends org.junit.Assert { } @Test + public void testAddPathsWithDuplicatedNotificationIdShouldBeAllowed() throws Exception { + long notificationID = 1; + + // Persist an empty image so that we can add paths to it. + sentryStore.persistFullPathsImage(new HashMap<String, Set<String>>(), 0); + + // Create two path updates with the same sequence ID + PathsUpdate update1 = new PathsUpdate(notificationID, false); + PathsUpdate update2 = new PathsUpdate(notificationID, false); + + // Populate the path updates with different objects and paths + update1.newPathChange("db1").addToAddPaths(Arrays.asList("/hive/db1")); + update2.newPathChange("db2").addToAddPaths(Arrays.asList("/hive/db2")); + + // Persist both path updates. Persisting should be allowed, and paths should be + // persisted even if they have the same sequence ID + sentryStore.addAuthzPathsMapping("db1", Arrays.asList("/hive/db1"), update1); + sentryStore.addAuthzPathsMapping("db2", Arrays.asList("/hive/db2"), update2); + + // Check the latest persisted ID matches to both the path updates + long latestID = sentryStore.getLastProcessedNotificationID(); + assertEquals(notificationID, latestID); + + // Check that retrieving a full paths image returns both paths updates + Map<String, Set<String>> pathsImage = sentryStore.retrieveFullPathsImage().getPathImage(); + assertEquals(2, pathsImage.size()); + assertEquals(1, pathsImage.get("db1").size()); + assertTrue(pathsImage.get("db1").contains("/hive/db1")); + assertEquals(1, pathsImage.get("db2").size()); + assertTrue(pathsImage.get("db2").contains("/hive/db2")); + + // Check that retrieving delta changes returns both patch updates + List<MSentryPathChange> pathsChanges = sentryStore.getMSentryPathChanges(); + assertEquals(2, pathsChanges.size()); + assertEquals(1, pathsChanges.get(0).getChangeID()); // changeID = 1 + assertEquals(notificationID, pathsChanges.get(0).getNotificationID()); + assertTrue(pathsChanges.get(0).getPathChange().contains("/hive/db1")); + assertEquals(2, pathsChanges.get(1).getChangeID()); // changeID = 2 + assertEquals(notificationID, pathsChanges.get(1).getNotificationID()); + assertTrue(pathsChanges.get(1).getPathChange().contains("/hive/db2")); + } + + @Test + public void testPersistDuplicatedNotificationIdShouldBeAllowed() throws Exception { + long notificationID = 1; + + // Persist the same ID twice should not cause any issues + sentryStore.persistLastProcessedNotificationID(notificationID); + sentryStore.persistLastProcessedNotificationID(notificationID); + + // Retrieving latest peristed ID should match with the previous persisted ID + long latestID = sentryStore.getLastProcessedNotificationID(); + assertEquals(notificationID, latestID); + } + + @Test public void testAddDeleteAuthzPathsMapping() throws Exception { long notificationID = 0;
