001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.apache.hadoop.hbase.quotas; 017 018import java.util.concurrent.atomic.AtomicLong; 019 020import org.apache.hadoop.conf.Configuration; 021import org.apache.hadoop.hbase.HBaseClassTestRule; 022import org.apache.hadoop.hbase.HBaseTestingUtility; 023import org.apache.hadoop.hbase.TableName; 024import org.apache.hadoop.hbase.testclassification.SmallTests; 025import org.junit.AfterClass; 026import org.junit.Before; 027import org.junit.BeforeClass; 028import org.junit.ClassRule; 029import org.junit.Rule; 030import org.junit.Test; 031import org.junit.experimental.categories.Category; 032import org.junit.rules.TestName; 033 034@Category(SmallTests.class) 035public class TestSpaceQuotaOnNonExistingTables { 036 037 @ClassRule 038 public static final HBaseClassTestRule CLASS_RULE = 039 HBaseClassTestRule.forClass(TestSpaceQuotaOnNonExistingTables.class); 040 041 private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); 042 043 private final TableName NON_EXISTENT_TABLE = TableName.valueOf("NON_EXISTENT_TABLE"); 044 045 @Rule 046 public TestName testName = new TestName(); 047 private SpaceQuotaHelperForTests helper; 048 049 @BeforeClass 050 public static void setUp() throws Exception { 051 Configuration conf = TEST_UTIL.getConfiguration(); 052 SpaceQuotaHelperForTests.updateConfigForQuotas(conf); 053 TEST_UTIL.startMiniCluster(1); 054 } 055 056 @AfterClass 057 public static void tearDown() throws Exception { 058 TEST_UTIL.shutdownMiniCluster(); 059 } 060 061 @Before 062 public void removeAllQuotas() throws Exception { 063 helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong(0)); 064 helper.removeAllQuotas(); 065 } 066 067 @Test 068 public void testSetQuotaOnNonExistingTableWithNoInserts() throws Exception { 069 helper.setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.NO_INSERTS, 2L); 070 } 071 072 @Test 073 public void testSetQuotaOnNonExistingTableWithNoWrites() throws Exception { 074 helper.setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.NO_WRITES, 2L); 075 } 076 077 @Test 078 public void testSetQuotaOnNonExistingTableWithNoWritesCompaction() throws Exception { 079 helper.setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.NO_WRITES_COMPACTIONS, 2L); 080 } 081 082 @Test 083 public void testSetQuotaOnNonExistingTableWithDisable() throws Exception { 084 helper.setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.DISABLE, 2L); 085 } 086}