Author: rvs
Date: Mon Jun 18 18:01:11 2012
New Revision: 1351430
URL: http://svn.apache.org/viewvc?rev=1351430&view=rev
Log:
BIGTOP-627. Add HBase balancer test (Stephen Chu via rvs)
Added:
incubator/bigtop/trunk/bigtop-tests/test-artifacts/hbase/src/main/groovy/org/apache/bigtop/itest/hbase/smoke/TestHBaseBalancer.groovy
Added:
incubator/bigtop/trunk/bigtop-tests/test-artifacts/hbase/src/main/groovy/org/apache/bigtop/itest/hbase/smoke/TestHBaseBalancer.groovy
URL:
http://svn.apache.org/viewvc/incubator/bigtop/trunk/bigtop-tests/test-artifacts/hbase/src/main/groovy/org/apache/bigtop/itest/hbase/smoke/TestHBaseBalancer.groovy?rev=1351430&view=auto
==============================================================================
---
incubator/bigtop/trunk/bigtop-tests/test-artifacts/hbase/src/main/groovy/org/apache/bigtop/itest/hbase/smoke/TestHBaseBalancer.groovy
(added)
+++
incubator/bigtop/trunk/bigtop-tests/test-artifacts/hbase/src/main/groovy/org/apache/bigtop/itest/hbase/smoke/TestHBaseBalancer.groovy
Mon Jun 18 18:01:11 2012
@@ -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)
+ }
+}