Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-27169 TestSeparateClientZKCluster is flaky #4587

Merged
merged 1 commit into from
Jul 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
Expand All @@ -40,6 +40,7 @@
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
Expand Down Expand Up @@ -100,6 +101,24 @@ public static void afterAllTests() throws Exception {
FileUtils.deleteDirectory(clientZkDir);
}

@Before
public void setUp() throws IOException {
try (Admin admin = TEST_UTIL.getConnection().getAdmin()) {
waitForNewMasterUpAndAddressSynced(admin);
}
}

private void waitForNewMasterUpAndAddressSynced(Admin admin) {
TEST_UTIL.waitFor(30000, () -> {
try {
return admin.listNamespaces().length > 0;
} catch (Exception e) {
LOG.warn("failed to list namespaces", e);
return false;
}
});
}

@Test
public void testBasicOperation() throws Exception {
TableName tn = name.getTableName();
Expand Down Expand Up @@ -139,7 +158,7 @@ public void testMasterSwitch() throws Exception {
() -> cluster.getMaster() != null && cluster.getMaster().isInitialized());
LOG.info("Got master {}", cluster.getMaster().getServerName());
// confirm client access still works
assertTrue(admin.balance(BalanceRequest.defaultInstance()).isBalancerRan());
waitForNewMasterUpAndAddressSynced(admin);
}
}

Expand Down