keith-turner commented on a change in pull request #1043: FLUO-1002 Create
integration test for `FluoAdmin.remove()`
URL: https://github.com/apache/fluo/pull/1043#discussion_r196760081
##########
File path:
modules/integration/src/test/java/org/apache/fluo/integration/client/FluoAdminImplIT.java
##########
@@ -184,4 +197,98 @@ public void testInitializeLongChroot() throws Exception {
}
}
+
+ @Test
+ public void testRemove() throws Exception {
+
+ // the oracle server is started before every test so it is running
+ // double check by making sure its leader
+
+ try (FluoAdmin admin = new FluoAdminImpl(config)) {
+ admin.remove();
+ fail("expected remove() to fail with oracle server running");
+ } catch (FluoException e) {
+ }
+
+ oserver.stop();
+
+ try (CuratorFramework curator = CuratorUtil.newAppCurator(config)) {
+ curator.start();
+ Assert.assertFalse(OracleServerUtils.oracleExists(curator));
+ }
+ // this should succeed now with the oracle server stopped
+ try (FluoAdmin admin = new FluoAdminImpl(config)) {
+ admin.remove();
+ }
+
+ // verify path is not in zookeeper after remove
+ try (CuratorFramework curator = CuratorUtil.newRootFluoCurator(config)) {
+ curator.start();
+ String appRootDir = ZookeeperUtil.parseRoot(config.getAppZookeepers());
+ assertFalse(CuratorUtil.pathExist(curator, appRootDir));
+ }
+
+ // should succeed without clearing anything
+ try (FluoAdmin admin = new FluoAdminImpl(config)) {
+ InitializationOptions opts =
+ new
InitializationOptions().setClearTable(false).setClearZookeeper(false);
+ admin.initialize(opts);
+ }
+
+ oserver.start();
+
+ // write some data into the table and test remove again
+ BatchWriter writer = conn.createBatchWriter(getCurTableName(), new
BatchWriterConfig());
+ Mutation mutation = new Mutation("id0001");
+ mutation.put("hero", "alias", "Batman");
+ mutation.put("hero", "name", "Bruce Wayne");
+ mutation.put("hero", "wearsCape?", "true");
+
+ writer.addMutation(mutation);
+ writer.close();
+
+ // verify we wrote some table data
+ Scanner scan = conn.createScanner(getCurTableName(), Authorizations.EMPTY);
+
+ int count = 0;
+ for (Entry<Key, Value> entry : scan) {
+ count++;
+ assertNotNull(entry);
+ }
+
+ Assert.assertEquals(count, 3);
+ scan.close();
+
+ oserver.stop();
+
+ // test remove again and make sure we have a clean initialization
+ try (FluoAdmin admin = new FluoAdminImpl(config)) {
+ admin.remove();
+ }
+
+ // verify path is not in zookeeper after remove
+ try (CuratorFramework curator = CuratorUtil.newRootFluoCurator(config)) {
+ curator.start();
+ String appRootDir = ZookeeperUtil.parseRoot(config.getAppZookeepers());
+ assertFalse(CuratorUtil.pathExist(curator, appRootDir));
+ }
+
+ // should succeed without clearing anything
+ try (FluoAdmin admin = new FluoAdminImpl(config)) {
+ InitializationOptions opts =
+ new
InitializationOptions().setClearTable(false).setClearZookeeper(false);
+ admin.initialize(opts);
+ }
+
+ // verify the table is empty after remove
+ count = 0; // reset the count
+ scan = conn.createScanner(getCurTableName(), Authorizations.EMPTY);
+
+ for (Entry<Key, Value> entry : scan) {
Review comment:
This loop could be replaced with `count = Iterables.size(scan)` using
Guava. Also, I don't think entry will or should be null, so do not need to
check that.
In addition to this Accumulo scan, it would also be nice to scan using Fluo.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services