HBASE-24033 Add ut for loading the corrupt recovered hfiles (#1322)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / procedure / TestProcedureDescriber.java
blob836c54d31c2afb3ed330bdcedc98e1e48efabda7
1 /**
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.procedure;
20 import static org.junit.Assert.*;
22 import java.io.IOException;
23 import java.util.Date;
24 import org.apache.hadoop.hbase.HBaseClassTestRule;
25 import org.apache.hadoop.hbase.master.procedure.ProcedureDescriber;
26 import org.apache.hadoop.hbase.procedure2.Procedure;
27 import org.apache.hadoop.hbase.procedure2.ProcedureStateSerializer;
28 import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException;
29 import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
30 import org.apache.hadoop.hbase.testclassification.MasterTests;
31 import org.apache.hadoop.hbase.testclassification.SmallTests;
32 import org.junit.ClassRule;
33 import org.junit.Test;
34 import org.junit.experimental.categories.Category;
36 import org.apache.hbase.thirdparty.com.google.protobuf.ByteString;
37 import org.apache.hbase.thirdparty.com.google.protobuf.BytesValue;
39 @Category({MasterTests.class, SmallTests.class})
40 public class TestProcedureDescriber {
42 @ClassRule
43 public static final HBaseClassTestRule CLASS_RULE =
44 HBaseClassTestRule.forClass(TestProcedureDescriber.class);
46 public static class TestProcedure extends Procedure {
47 @Override
48 protected Procedure[] execute(Object env) throws ProcedureYieldException,
49 ProcedureSuspendedException, InterruptedException {
50 return null;
53 @Override
54 protected void rollback(Object env)
55 throws IOException, InterruptedException {
58 @Override
59 protected boolean abort(Object env) {
60 return false;
63 @Override
64 protected void serializeStateData(ProcedureStateSerializer serializer)
65 throws IOException {
66 ByteString byteString = ByteString.copyFrom(new byte[] { 'A' });
67 BytesValue state = BytesValue.newBuilder().setValue(byteString).build();
68 serializer.serialize(state);
71 @Override
72 protected void deserializeStateData(ProcedureStateSerializer serializer)
73 throws IOException {
77 @Test
78 public void test() {
79 TestProcedure procedure = new TestProcedure();
80 String result = ProcedureDescriber.describe(procedure);
82 Date epoch = new Date(0);
84 assertEquals("{ ID => '-1', PARENT_ID => '-1', STATE => 'INITIALIZING', OWNER => '', "
85 + "TYPE => 'org.apache.hadoop.hbase.procedure.TestProcedureDescriber$TestProcedure', "
86 + "START_TIME => '" + epoch + "', LAST_UPDATE => '" + epoch + "', PARAMETERS => [ "
87 + "{ value => 'QQ==' } ] }", result);