1   /**
2    * Copyright 2011 The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  package org.apache.hadoop.hbase.catalog;
21  
22  import org.apache.commons.logging.Log;
23  import org.apache.commons.logging.LogFactory;
24  import org.apache.hadoop.hbase.Abortable;
25  import org.apache.hadoop.hbase.HBaseTestingUtility;
26  import org.apache.hadoop.hbase.HServerAddress;
27  import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
28  import org.junit.Test;
29  
30  /**
31   * Do {@link CatalogTracker} tests on running cluster.
32   */
33  public class TestCatalogTrackerOnCluster {
34    private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
35    private static final Log LOG =
36      LogFactory.getLog(TestCatalogTrackerOnCluster.class);
37  
38    /**
39     * @throws Exception 
40     * @see https://issues.apache.org/jira/browse/HBASE-3445
41     */
42    @Test public void testBadOriginalRootLocation() throws Exception {
43      UTIL.getConfiguration().setInt("ipc.socket.timeout", 3000);
44      // Launch cluster so it does bootstrapping.
45      UTIL.startMiniCluster();
46      // Shutdown hbase.
47      UTIL.shutdownMiniHBaseCluster();
48      // Mess with the root location in the running zk.  Set it to be nonsense.
49      ZooKeeperWatcher zookeeper = new ZooKeeperWatcher(UTIL.getConfiguration(),
50        "Bad Root Location Writer", new Abortable() {
51          @Override
52          public void abort(String why, Throwable e) {
53            LOG.error("Abort was called on 'bad root location writer'", e);
54          }
55      });
56      HServerAddress nonsense = new HServerAddress("example.org:1234");
57      RootLocationEditor.setRootLocation(zookeeper, nonsense);
58      // Bring back up the hbase cluster.  See if it can deal with nonsense root
59      // location.
60      UTIL.startMiniHBaseCluster(1, 1);
61      UTIL.shutdownMiniCluster();
62    }
63  }