2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org
.apache
.hadoop
.hbase
.wal
;
20 import static org
.junit
.Assert
.assertNotNull
;
21 import static org
.junit
.Assert
.fail
;
23 import java
.io
.IOException
;
25 import org
.apache
.hadoop
.conf
.Configuration
;
26 import org
.apache
.hadoop
.hbase
.HBaseClassTestRule
;
27 import org
.apache
.hadoop
.hbase
.HBaseTestingUtility
;
28 import org
.apache
.hadoop
.hbase
.TableName
;
29 import org
.apache
.hadoop
.hbase
.client
.Get
;
30 import org
.apache
.hadoop
.hbase
.client
.Put
;
31 import org
.apache
.hadoop
.hbase
.client
.Result
;
32 import org
.apache
.hadoop
.hbase
.client
.Table
;
33 import org
.apache
.hadoop
.hbase
.testclassification
.MediumTests
;
34 import org
.apache
.hadoop
.hbase
.testclassification
.RegionServerTests
;
35 import org
.apache
.hadoop
.hbase
.util
.Bytes
;
36 import org
.junit
.After
;
37 import org
.junit
.AfterClass
;
38 import org
.junit
.Before
;
39 import org
.junit
.BeforeClass
;
40 import org
.junit
.ClassRule
;
41 import org
.junit
.Rule
;
42 import org
.junit
.Test
;
43 import org
.junit
.experimental
.categories
.Category
;
44 import org
.junit
.rules
.TestName
;
46 import org
.slf4j
.Logger
;
47 import org
.slf4j
.LoggerFactory
;
49 @Category({ RegionServerTests
.class, MediumTests
.class })
50 public class TestDisabledWAL
{
53 public static final HBaseClassTestRule CLASS_RULE
=
54 HBaseClassTestRule
.forClass(TestDisabledWAL
.class);
57 public TestName name
= new TestName();
59 private static final Logger LOG
= LoggerFactory
.getLogger(TestDisabledWAL
.class);
60 static final HBaseTestingUtility TEST_UTIL
= new HBaseTestingUtility();
62 private TableName tableName
;
63 private byte[] fam
= Bytes
.toBytes("f1");
66 public static void beforeClass() throws Exception
{
67 Configuration conf
= TEST_UTIL
.getConfiguration();
68 conf
.setBoolean("hbase.regionserver.hlog.enabled", false);
70 TEST_UTIL
.startMiniCluster();
71 } catch (RuntimeException
| IOException e
) {
72 LOG
.error("Master failed to start.", e
);
73 fail("Failed to start cluster. Reason being: " + e
.getCause().getMessage());
78 public static void afterClass() throws Exception
{
79 TEST_UTIL
.shutdownMiniCluster();
83 public void setup() throws Exception
{
84 tableName
= TableName
.valueOf(name
.getMethodName().replaceAll("[^a-zA-Z0-9]", "_"));
85 LOG
.info("Creating table " + tableName
);
86 table
= TEST_UTIL
.createTable(tableName
, fam
);
90 public void cleanup() throws Exception
{
91 LOG
.info("Deleting table " + tableName
);
92 TEST_UTIL
.deleteTable(tableName
);
96 public void testDisabledWAL() throws Exception
{
97 LOG
.info("Writing data to table " + tableName
);
98 Put p
= new Put(Bytes
.toBytes("row"));
99 p
.addColumn(fam
, Bytes
.toBytes("qual"), Bytes
.toBytes("val"));
102 LOG
.info("Flushing table " + tableName
);
103 TEST_UTIL
.flush(tableName
);
105 LOG
.info("Getting data from table " + tableName
);
106 Get get
= new Get(Bytes
.toBytes("row"));
108 Result result
= table
.get(get
);
109 assertNotNull(result
.getValue(fam
, Bytes
.toBytes("qual")));