[1/2] hbase git commit: HBASE-19792 TestReplicationSmallTests.testDisableEnable fails

2018-01-16 Thread zhangduo
Repository: hbase
Updated Branches:
  refs/heads/branch-2 20afaca76 -> 48bb19012


http://git-wip-us.apache.org/repos/asf/hbase/blob/48bb1901/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
--
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
new file mode 100644
index 000..cb47827
--- /dev/null
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
@@ -0,0 +1,436 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.replication;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NavigableMap;
+import java.util.TreeMap;
+import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.RegionInfoBuilder;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
+import org.apache.hadoop.hbase.client.replication.TableCFs;
+import org.apache.hadoop.hbase.regionserver.HRegion;
+import org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl;
+import org.apache.hadoop.hbase.replication.regionserver.Replication;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.testclassification.ReplicationTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALEdit;
+import org.apache.hadoop.hbase.wal.WALKeyImpl;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos;
+
+@Category({ ReplicationTests.class, LargeTests.class })
+public class TestReplicationSmallTests extends TestReplicationBase {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(TestReplicationSmallTests.class);
+  private static final String PEER_ID = "2";
+
+  @Before
+  public void setUp() throws Exception {
+cleanUp();
+  }
+
+  /**
+   * Verify that version and column delete marker types are replicated 
correctly.
+   */
+  @Test
+  public void testDeleteTypes() throws Exception {
+LOG.info("testDeleteTypes");
+final byte[] v1 = Bytes.toBytes("v1");
+final byte[] v2 = Bytes.toBytes("v2");
+final byte[] v3 = Bytes.toBytes("v3");
+htable1 = utility1.getConnection().getTable(tableName);
+
+long t = EnvironmentEdgeManager.currentTime();
+// create three versions for "row"
+Put put = new Put(row);
+put.addColumn(famName, row, t, v1);
+htable1.put(put);
+
+put = new Put(row);
+put.addColumn(famName, row, t + 1, v2);
+htable1.put(put);
+
+put = new Put(row);
+put.addColumn(famName, row, t + 2, v3);
+htable1.put(put);
+
+Get get = new Get(row);
+get.readAllVersions();
+for (int i = 0; i < NB_RETRIES; i++) {
+  if (i == NB_RETRIES - 1) {
+fail("Waited too much time for put replication");
+  }
+  Result res = htable2.get(get);
+  if (res.size() < 3) {
+LOG.info("Rows not available");
+Thread.sleep(SLEEP_TIME);
+  } else {
+assertArrayEquals(CellUtil.cloneValue(res.rawCells()

[1/2] hbase git commit: HBASE-19792 TestReplicationSmallTests.testDisableEnable fails

2018-01-16 Thread zhangduo
Repository: hbase
Updated Branches:
  refs/heads/master 8b6b2b0b2 -> d8d6ecdad


http://git-wip-us.apache.org/repos/asf/hbase/blob/d8d6ecda/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
--
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
new file mode 100644
index 000..cb47827
--- /dev/null
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
@@ -0,0 +1,436 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.replication;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NavigableMap;
+import java.util.TreeMap;
+import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.RegionInfoBuilder;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
+import org.apache.hadoop.hbase.client.replication.TableCFs;
+import org.apache.hadoop.hbase.regionserver.HRegion;
+import org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl;
+import org.apache.hadoop.hbase.replication.regionserver.Replication;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.testclassification.ReplicationTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
+import org.apache.hadoop.hbase.wal.WAL;
+import org.apache.hadoop.hbase.wal.WALEdit;
+import org.apache.hadoop.hbase.wal.WALKeyImpl;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos;
+
+@Category({ ReplicationTests.class, LargeTests.class })
+public class TestReplicationSmallTests extends TestReplicationBase {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(TestReplicationSmallTests.class);
+  private static final String PEER_ID = "2";
+
+  @Before
+  public void setUp() throws Exception {
+cleanUp();
+  }
+
+  /**
+   * Verify that version and column delete marker types are replicated 
correctly.
+   */
+  @Test
+  public void testDeleteTypes() throws Exception {
+LOG.info("testDeleteTypes");
+final byte[] v1 = Bytes.toBytes("v1");
+final byte[] v2 = Bytes.toBytes("v2");
+final byte[] v3 = Bytes.toBytes("v3");
+htable1 = utility1.getConnection().getTable(tableName);
+
+long t = EnvironmentEdgeManager.currentTime();
+// create three versions for "row"
+Put put = new Put(row);
+put.addColumn(famName, row, t, v1);
+htable1.put(put);
+
+put = new Put(row);
+put.addColumn(famName, row, t + 1, v2);
+htable1.put(put);
+
+put = new Put(row);
+put.addColumn(famName, row, t + 2, v3);
+htable1.put(put);
+
+Get get = new Get(row);
+get.readAllVersions();
+for (int i = 0; i < NB_RETRIES; i++) {
+  if (i == NB_RETRIES - 1) {
+fail("Waited too much time for put replication");
+  }
+  Result res = htable2.get(get);
+  if (res.size() < 3) {
+LOG.info("Rows not available");
+Thread.sleep(SLEEP_TIME);
+  } else {
+assertArrayEquals(CellUtil.cloneValue(res.rawCells()[0