001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.mapreduce; 019 020import static org.junit.jupiter.api.Assertions.assertFalse; 021import static org.junit.jupiter.api.Assertions.assertTrue; 022 023import java.io.IOException; 024import java.util.HashMap; 025import java.util.Map; 026import org.apache.hadoop.hbase.HBaseTestingUtil; 027import org.apache.hadoop.hbase.testclassification.LargeTests; 028import org.apache.hadoop.hbase.testclassification.MapReduceTests; 029import org.junit.jupiter.api.Tag; 030import org.junit.jupiter.api.Test; 031 032@Tag(MapReduceTests.TAG) 033@Tag(LargeTests.TAG) 034public class TestHBaseMRTestingUtility { 035 036 @Test 037 public void testMRYarnConfigsPopulation() throws IOException { 038 Map<String, String> dummyProps = new HashMap<>(); 039 dummyProps.put("mapreduce.jobtracker.address", "dummyhost:11234"); 040 dummyProps.put("yarn.resourcemanager.address", "dummyhost:11235"); 041 dummyProps.put("mapreduce.jobhistory.address", "dummyhost:11236"); 042 dummyProps.put("yarn.resourcemanager.scheduler.address", "dummyhost:11237"); 043 dummyProps.put("mapreduce.jobhistory.webapp.address", "dummyhost:11238"); 044 dummyProps.put("yarn.resourcemanager.webapp.address", "dummyhost:11239"); 045 046 HBaseTestingUtil hbt = new HBaseTestingUtil(); 047 048 // populate the mr props to the Configuration instance 049 for (Map.Entry<String, String> entry : dummyProps.entrySet()) { 050 hbt.getConfiguration().set(entry.getKey(), entry.getValue()); 051 } 052 053 for (Map.Entry<String, String> entry : dummyProps.entrySet()) { 054 assertTrue(hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue()), 055 "The Configuration for key " + entry.getKey() + " and value: " + entry.getValue() 056 + " is not populated correctly"); 057 } 058 059 hbt.startMiniMapReduceCluster(); 060 061 // Confirm that MiniMapReduceCluster overwrites the mr properties and updates the Configuration 062 for (Map.Entry<String, String> entry : dummyProps.entrySet()) { 063 assertFalse(hbt.getConfiguration().get(entry.getKey()).equals(entry.getValue()), 064 "The MR prop: " + entry.getValue() + " is not overwritten when map reduce mini" 065 + "cluster is started"); 066 } 067 068 hbt.shutdownMiniMapReduceCluster(); 069 } 070}