Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BIGTOP-627. Add HBase balancer test (Stephen Chu via rvs)
git-svn-id: https://svn.apache.org/repos/asf/incubator/bigtop/trunk@1351430 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...ifacts/hbase/src/main/groovy/org/apache/bigtop/itest/hbase/smoke/TestHBaseBalancer.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |