From d8ec10e20f2c30641b3c8d13a902c9c158b9dd3b Mon Sep 17 00:00:00 2001 From: Mike Drob Date: Wed, 21 Feb 2018 10:53:42 -0600 Subject: [PATCH] HBASE-20039 MR tests out to hbase-mapreduce mobile --- .../mapreduce/TestHBaseMRTestingUtility.java | 73 +++++++++++++++++++ .../hadoop/hbase/TestHBaseTestingUtility.java | 32 -------- 2 files changed, 73 insertions(+), 32 deletions(-) create mode 100644 hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHBaseMRTestingUtility.java diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHBaseMRTestingUtility.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHBaseMRTestingUtility.java new file mode 100644 index 00000000000..2467dcace23 --- /dev/null +++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHBaseMRTestingUtility.java @@ -0,0 +1,73 @@ +/** + * 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.mapreduce; + +import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.testclassification.LargeTests; +import org.apache.hadoop.hbase.testclassification.MapReduceTests; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +@Category({MapReduceTests.class, LargeTests.class}) +public class TestHBaseMRTestingUtility { + @ClassRule + public static final HBaseClassTestRule CLASS_RULE = + HBaseClassTestRule.forClass(TestHBaseMRTestingUtility.class); + + @Test + public void testMRYarnConfigsPopulation() throws IOException { + Map dummyProps = new HashMap<>(); + dummyProps.put("mapreduce.jobtracker.address", "dummyhost:11234"); + dummyProps.put("yarn.resourcemanager.address", "dummyhost:11235"); + dummyProps.put("mapreduce.jobhistory.address", "dummyhost:11236"); + dummyProps.put("yarn.resourcemanager.scheduler.address", "dummyhost:11237"); + dummyProps.put("mapreduce.jobhistory.webapp.address", "dummyhost:11238"); + dummyProps.put("yarn.resourcemanager.webapp.address", "dummyhost:11239"); + + HBaseTestingUtility hbt = new HBaseTestingUtility(); + + // populate the mr props to the Configuration instance + for (Map.Entry entry : dummyProps.entrySet()) { + hbt.getConfiguration().set(entry.getKey(), entry.getValue()); + } + + for (Map.Entry entry : dummyProps.entrySet()) { + assertTrue("The Configuration for key " + entry.getKey() +" and value: " + entry.getValue() + + " is not populated correctly", hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue())); + } + + hbt.startMiniMapReduceCluster(); + + // Confirm that MiniMapReduceCluster overwrites the mr properties and updates the Configuration + for (Map.Entry entry : dummyProps.entrySet()) { + assertFalse("The MR prop: " + entry.getValue() + " is not overwritten when map reduce mini"+ + "cluster is started", hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue())); + } + + hbt.shutdownMiniMapReduceCluster(); + } +} diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java index 4e09e1ea1b7..f49171c5182 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseTestingUtility.java @@ -458,36 +458,4 @@ public class TestHBaseTestingUtility { assertEquals(nonDefaultRegionServerPort , htu.getConfiguration().getInt(HConstants.REGIONSERVER_PORT, 0)); } - - @Test public void testMRYarnConfigsPopulation() throws IOException { - Map dummyProps = new HashMap<>(); - dummyProps.put("mapreduce.jobtracker.address", "dummyhost:11234"); - dummyProps.put("yarn.resourcemanager.address", "dummyhost:11235"); - dummyProps.put("mapreduce.jobhistory.address", "dummyhost:11236"); - dummyProps.put("yarn.resourcemanager.scheduler.address", "dummyhost:11237"); - dummyProps.put("mapreduce.jobhistory.webapp.address", "dummyhost:11238"); - dummyProps.put("yarn.resourcemanager.webapp.address", "dummyhost:11239"); - - HBaseTestingUtility hbt = new HBaseTestingUtility(); - - // populate the mr props to the Configuration instance - for (Entry entry : dummyProps.entrySet()) { - hbt.getConfiguration().set(entry.getKey(), entry.getValue()); - } - - for (Entry entry : dummyProps.entrySet()) { - assertTrue("The Configuration for key " + entry.getKey() +" and value: " + entry.getValue() + - " is not populated correctly", hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue())); - } - - hbt.startMiniMapReduceCluster(); - - // Confirm that MiniMapReduceCluster overwrites the mr properties and updates the Configuration - for (Entry entry : dummyProps.entrySet()) { - assertFalse("The MR prop: " + entry.getValue() + " is not overwritten when map reduce mini"+ - "cluster is started", hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue())); - } - - hbt.shutdownMiniMapReduceCluster(); - } }