Skip to content

Commit

Permalink
Add hive hook custom config unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyx committed Jul 10, 2024
1 parent 61609db commit ab44690
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ public void unreachableMetastoreClient() {

@Test
public void loadMetastoreFilterHookFromConfig() {
AbstractMetaStore federatedMetaStore = newFederatedInstance("fed1", thrift.getThriftConnectionUri());
federatedMetaStore.setHiveMetastoreFilterHook(PrefixingMetastoreFilter.class.getName());
MetaStoreMapping mapping = factory.newInstance(federatedMetaStore);
assertThat(mapping, is(notNullValue()));
assertThat(mapping.getMetastoreFilter(), instanceOf(PrefixingMetastoreFilter.class));
}

@Test
public void loadDefaultMetastoreFilterHook() {
AbstractMetaStore federatedMetaStore = newFederatedInstance("fed1", thrift.getThriftConnectionUri());
MetaStoreMapping mapping = factory.newInstance(federatedMetaStore);
assertThat(mapping, is(notNullValue()));
assertThat(mapping.getMetastoreFilter(), instanceOf(DefaultMetaStoreFilterHookImpl.class));
}

@Test
public void loadMetastoreFilterHookWithCustomConfig() {
AbstractMetaStore federatedMetaStore = newFederatedInstance("fed1", thrift.getThriftConnectionUri());
federatedMetaStore.setHiveMetastoreFilterHook(PrefixingMetastoreFilter.class.getName());
Map<String,String> metaStoreConfigurationProperties = new HashMap<>();
Expand All @@ -149,7 +166,6 @@ public void loadMetastoreFilterHookFromConfig() {

MetaStoreMapping mapping = factory.newInstance(federatedMetaStore);
assertThat(mapping, is(notNullValue()));

MetaStoreFilterHook filterHook = mapping.getMetastoreFilter();
assertThat(filterHook, instanceOf(PrefixingMetastoreFilter.class));

Expand All @@ -165,12 +181,4 @@ public void loadMetastoreFilterHookFromConfig() {
}catch (Exception e){
}
}

@Test
public void loadDefaultMetastoreFilterHook() {
AbstractMetaStore federatedMetaStore = newFederatedInstance("fed1", thrift.getThriftConnectionUri());
MetaStoreMapping mapping = factory.newInstance(federatedMetaStore);
assertThat(mapping, is(notNullValue()));
assertThat(mapping.getMetastoreFilter(), instanceOf(DefaultMetaStoreFilterHookImpl.class));
}
}

0 comments on commit ab44690

Please sign in to comment.