void expectFailure(QuotaSettings one, QuotaSettings two) throws IOException { try { one.merge(two); fail("Expected to see an Exception merging " + two + " into " + one); } catch (IllegalArgumentException e) {} } }
@Test public void testQuotaMerging() throws IOException { TableName tn = TableName.valueOf("foo"); QuotaSettings originalSettings = QuotaSettingsFactory.limitTableSpace( tn, 1024L * 1024L, SpaceViolationPolicy.DISABLE); QuotaSettings largerSizeLimit = QuotaSettingsFactory.limitTableSpace( tn, 5L * 1024L * 1024L, SpaceViolationPolicy.DISABLE); QuotaSettings differentPolicy = QuotaSettingsFactory.limitTableSpace( tn, 1024L * 1024L, SpaceViolationPolicy.NO_WRITES); QuotaSettings incompatibleSettings = QuotaSettingsFactory.limitNamespaceSpace( "ns1", 5L * 1024L * 1024L, SpaceViolationPolicy.NO_WRITES); assertEquals(originalSettings.merge(largerSizeLimit), largerSizeLimit); assertEquals(originalSettings.merge(differentPolicy), differentPolicy); try { originalSettings.merge(incompatibleSettings); fail("Should not be able to merge a Table space quota with a namespace space quota."); } catch (IllegalArgumentException e) { //pass } } }
void expectFailure(QuotaSettings one, QuotaSettings two) throws IOException { try { one.merge(two); fail("Expected to see an Exception merging " + two + " into " + one); } catch (IllegalArgumentException e) {} } }
@Test public void testQuotaMerging() throws IOException { TableName tn = TableName.valueOf("foo"); QuotaSettings originalSettings = QuotaSettingsFactory.limitTableSpace( tn, 1024L * 1024L, SpaceViolationPolicy.DISABLE); QuotaSettings largerSizeLimit = QuotaSettingsFactory.limitTableSpace( tn, 5L * 1024L * 1024L, SpaceViolationPolicy.DISABLE); QuotaSettings differentPolicy = QuotaSettingsFactory.limitTableSpace( tn, 1024L * 1024L, SpaceViolationPolicy.NO_WRITES); QuotaSettings incompatibleSettings = QuotaSettingsFactory.limitNamespaceSpace( "ns1", 5L * 1024L * 1024L, SpaceViolationPolicy.NO_WRITES); assertEquals(originalSettings.merge(largerSizeLimit), largerSizeLimit); assertEquals(originalSettings.merge(differentPolicy), differentPolicy); try { originalSettings.merge(incompatibleSettings); fail("Should not be able to merge a Table space quota with a namespace space quota."); } catch (IllegalArgumentException e) { //pass } } }