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 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.master.procedure;
019
020import static org.junit.jupiter.api.Assertions.assertThrows;
021
022import java.io.IOException;
023import java.util.Arrays;
024import org.apache.hadoop.hbase.TableNotEnabledException;
025import org.apache.hadoop.hbase.TableNotFoundException;
026import org.apache.hadoop.hbase.client.Admin;
027import org.apache.hadoop.hbase.testclassification.LargeTests;
028import org.apache.hadoop.hbase.testclassification.MasterTests;
029import org.junit.jupiter.api.Tag;
030import org.junit.jupiter.api.Test;
031
032@Tag(MasterTests.TAG)
033@Tag(LargeTests.TAG)
034public class TestFlushTableProcedure extends TestFlushTableProcedureBase {
035
036  @Test
037  public void testSimpleFlush() throws IOException {
038    assertTableMemStoreNotEmpty();
039    TEST_UTIL.getAdmin().flush(TABLE_NAME);
040    assertTableMemStoreEmpty();
041  }
042
043  @Test
044  public void testFlushTableExceptionally() throws IOException {
045    Admin admin = TEST_UTIL.getAdmin();
046    admin.disableTable(TABLE_NAME);
047    assertThrows(TableNotEnabledException.class, () -> admin.flush(TABLE_NAME));
048    admin.deleteTable(TABLE_NAME);
049    assertThrows(TableNotFoundException.class, () -> admin.flush(TABLE_NAME));
050  }
051
052  @Test
053  public void testSingleColumnFamilyFlush() throws IOException {
054    assertTableMemStoreNotEmpty();
055    TEST_UTIL.getAdmin().flush(TABLE_NAME, Arrays.asList(FAMILY1, FAMILY2, FAMILY3));
056    assertTableMemStoreEmpty();
057  }
058
059  @Test
060  public void testMultiColumnFamilyFlush() throws IOException {
061    assertTableMemStoreNotEmpty();
062    TEST_UTIL.getAdmin().flush(TABLE_NAME, Arrays.asList(FAMILY1, FAMILY2, FAMILY3));
063    assertTableMemStoreEmpty();
064  }
065}