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.chaos.actions; 019 020import org.apache.hadoop.hbase.IntegrationTestingUtility; 021import org.apache.hadoop.hbase.TableName; 022import org.apache.hadoop.hbase.client.Admin; 023import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; 024import org.apache.hadoop.hbase.client.TableDescriptorBuilder; 025import org.apache.hadoop.hbase.testclassification.MediumTests; 026import org.junit.jupiter.api.AfterAll; 027import org.junit.jupiter.api.BeforeAll; 028import org.junit.jupiter.api.BeforeEach; 029import org.junit.jupiter.api.Tag; 030import org.junit.jupiter.api.Test; 031import org.mockito.Mockito; 032 033@Tag(MediumTests.TAG) 034public class TestChangeSplitPolicyAction { 035 036 private final static IntegrationTestingUtility TEST_UTIL = new IntegrationTestingUtility(); 037 private final TableName tableName = TableName.valueOf("ChangeSplitPolicyAction"); 038 039 @BeforeAll 040 public static void setUpBeforeClass() throws Exception { 041 TEST_UTIL.startMiniCluster(2); 042 } 043 044 @AfterAll 045 public static void tearDownAfterClass() throws Exception { 046 TEST_UTIL.shutdownMiniCluster(); 047 } 048 049 @BeforeEach 050 public void setUp() throws Exception { 051 Admin admin = TEST_UTIL.getAdmin(); 052 TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName); 053 admin.createTable(builder.setColumnFamily(ColumnFamilyDescriptorBuilder.of("fam")).build()); 054 } 055 056 @Test 057 public void testChangeSplitPolicyAction() throws Exception { 058 Action.ActionContext ctx = Mockito.mock(Action.ActionContext.class); 059 Mockito.when(ctx.getHBaseIntegrationTestingUtility()).thenReturn(TEST_UTIL); 060 Mockito.when(ctx.getHBaseCluster()).thenReturn(TEST_UTIL.getHBaseCluster()); 061 ChangeSplitPolicyAction action = new ChangeSplitPolicyAction(tableName); 062 action.init(ctx); 063 action.perform(); 064 } 065}