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.security.access; 019 020import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_RETRIES_NUMBER; 021 022import org.apache.hadoop.conf.Configuration; 023import org.apache.hadoop.hbase.HBaseTestingUtil; 024import org.apache.hadoop.hbase.HConstants; 025import org.apache.hadoop.hbase.testclassification.LargeTests; 026import org.apache.hadoop.hbase.testclassification.SecurityTests; 027import org.junit.jupiter.api.AfterAll; 028import org.junit.jupiter.api.BeforeAll; 029import org.junit.jupiter.api.Tag; 030import org.junit.jupiter.api.Test; 031 032@Tag(SecurityTests.TAG) 033@Tag(LargeTests.TAG) 034@SuppressWarnings("deprecation") 035public class TestCanStartHBaseInReadOnlyMode { 036 037 private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); 038 private static Configuration conf; 039 040 @BeforeAll 041 public static void beforeClass() throws Exception { 042 conf = TEST_UTIL.getConfiguration(); 043 044 // Shorten the run time of failed unit tests by limiting retries and the session timeout 045 // threshold 046 conf.setInt(HBASE_CLIENT_RETRIES_NUMBER, 0); 047 conf.setInt("hbase.master.init.timeout.localHBaseCluster", 10000); 048 049 // Enable Read-Only mode to prove the cluster can be started in this state 050 conf.setBoolean(HConstants.HBASE_GLOBAL_READONLY_ENABLED_KEY, true); 051 } 052 053 @AfterAll 054 public static void afterClass() throws Exception { 055 TEST_UTIL.shutdownMiniCluster(); 056 } 057 058 @Test 059 public void testCanStartHBaseInReadOnlyMode() throws Exception { 060 TEST_UTIL.startMiniCluster(1); 061 } 062}