@Test
public void testSplitOrMoveAffectClient() throws SQLException, IOException, InterruptedException {
WaspAdmin admin = TEST_UTIL.getWaspAdmin();
String createTableSql = "CREATE TABLE user123{REQUIRED INT64 user_id;" +
"REQUIRED INT64 photo_id;}" +
"PRIMARY KEY(user_id)," +
"ENTITY GROUP ROOT," +
"ENTITY GROUP KEY(user_id)," +
"PARTITION BY RANGE('A', 'Z', 4);";
stat = conn.createStatement();
stat.executeUpdate(createTableSql);
admin.waitTableNotLocked("user123");
admin.disableTable("user123");
admin.waitTableDisabled("user123", 3000);
stat.executeUpdate("create index test_index on " + "user123" + "(photo_id);");
admin.waitTableNotLocked("user123");
admin.enableTable("user123");
admin.waitTableEnabled("user123", 3000);
stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (1, 1)");
stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (2, 2)");
stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (3, 3)");
stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (4, 4)");
List<EntityGroupInfo> egis = admin.getTableEntityGroups(Bytes.toBytes("user123"));
admin.split(egis.get(0).getEntityGroupName(), Bytes.toBytes("H"));
stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (5, 5)");
ResultSet rs;
rs = stat.executeQuery("select * from user123 where photo_id=5");
assertTrue(rs.next());
assertTrue(rs.getLong("user_id") == 5);
egis = admin.getTableEntityGroups(Bytes.toBytes("user123"));
ClusterStatus status = admin.getClusterStatus();
List<ServerName> serverNames = new ArrayList<ServerName>(status.getServers());
egis = admin.getOnlineEntityGroups(serverNames.get(0));
admin.move(egis.get(0).getEncodedNameAsBytes(), Bytes.toBytes(serverNames.get(1).getServerName()));
stat.execute("INSERT INTO user123 (user_id, photo_id) VALUES (6, 6)");
rs = stat.executeQuery("select * from user123 where photo_id=6");
assertTrue(rs.next());
assertTrue(rs.getLong("user_id") == 6);