1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.migration;
19
20
21 import java.io.IOException;
22
23 import junit.framework.Assert;
24
25 import org.apache.hadoop.hbase.HColumnDescriptor;
26 import org.apache.hadoop.hbase.HConstants;
27 import org.apache.hadoop.hbase.HRegionInfo;
28 import org.apache.hadoop.hbase.HTableDescriptor;
29 import org.apache.hadoop.hbase.catalog.MetaMigrationRemovingHTD;
30 import org.apache.hadoop.hbase.util.Writables;
31 import org.junit.Test;
32
33
34
35
36
37 public class TestMigrationFrom090To092 {
38 @Test
39 public void testMigrateHRegionInfoFromVersion0toVersion1()
40 throws IOException {
41 HTableDescriptor htd =
42 getHTableDescriptor("testMigrateHRegionInfoFromVersion0toVersion1");
43 HRegionInfo090x ninety =
44 new HRegionInfo090x(htd, HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW);
45 byte [] bytes = Writables.getBytes(ninety);
46
47 HRegionInfo hri = Writables.getHRegionInfo(bytes);
48 Assert.assertEquals(hri.getTableNameAsString(),
49 ninety.getTableDesc().getNameAsString());
50 Assert.assertEquals(HRegionInfo.VERSION, hri.getVersion());
51 }
52
53 private HTableDescriptor getHTableDescriptor(final String name) {
54 HTableDescriptor htd = new HTableDescriptor(name);
55 htd.addFamily(new HColumnDescriptor("family"));
56 return htd;
57 }
58 }