Skip to content

Commit

Permalink
BIGTOP-627. Add HBase balancer test (Stephen Chu via rvs)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/bigtop/trunk@1351430 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rvs committed Jun 18, 2012
1 parent 20f61ba commit 5dda3f6
Showing 1 changed file with 69 additions and 0 deletions.
@@ -0,0 +1,69 @@
/**
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.bigtop.itest.hbase.smoke

import org.junit.Test
import org.apache.bigtop.itest.shell.Shell
import static org.apache.bigtop.itest.LogErrorsUtils.logError
import static org.junit.Assert.assertTrue

/**
* Tests the HBase balancer tool via the HBase shell.
*/
class TestHBaseBalancer {
private static Shell sh = new Shell("hbase shell")
private static String balancer = "balancer"
private static String balanceSwitchTrue = "balance_switch true"
private static String balanceSwitchFalse = "balance_switch false"

@Test
void testBalancer() {
// Enable the balancer.
sh.exec(balanceSwitchTrue)
logError(sh)
assertTrue(sh.getRet() == 0)

/* Record the original state of the balancer switch. HBASE-5953
* should allow us to get the state in an easier manner. */
String origState = balanceSwitchTrue
if (sh.getOut().toString().indexOf("false") != -1) {
origState = balanceSwitchFalse
}

// Run the balancer.
sh.exec(balancer)
logError(sh)
assertTrue(sh.getRet() == 0)

// Disable the balancer, and verify its previous state to be true.
sh.exec(balanceSwitchFalse)
logError(sh)
assertTrue(sh.getRet() == 0)
assertTrue("balance_switch failed switching to true",
sh.getOut().toString().indexOf("true") != -1)

// Return balancer switch to original state, and verify its
// previous state to be false.
sh.exec(origState)
logError(sh)
assertTrue(sh.getRet() == 0)
assertTrue("balance_switch failed switching to false",
sh.getOut().toString().indexOf("false") != -1)
}
}

0 comments on commit 5dda3f6

Please sign in to comment.