You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/12/02 21:36:55 UTC
[07/50] [abbrv] accumulo git commit: ACCUMULO-3167 Make cleanwalit
pass on a real instance.
ACCUMULO-3167 Make cleanwalit pass on a real instance.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/7a020e57
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/7a020e57
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/7a020e57
Branch: refs/heads/metrics2
Commit: 7a020e571b6c90c5b7d949b7c29b2c248f61402c
Parents: 612c574
Author: Josh Elser <el...@apache.org>
Authored: Wed Nov 19 23:09:37 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Mon Nov 24 18:08:17 2014 -0500
----------------------------------------------------------------------
.../org/apache/accumulo/test/CleanWalIT.java | 55 +++++++++++++++++---
1 file changed, 47 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/7a020e57/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java b/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java
index 31bb1d9..1fcd5a4 100644
--- a/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/CleanWalIT.java
@@ -18,13 +18,17 @@ package org.apache.accumulo.test;
import static org.junit.Assert.assertEquals;
+import java.util.Map.Entry;
+
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.RootTable;
import org.apache.accumulo.core.metadata.schema.MetadataSchema;
@@ -35,9 +39,13 @@ import org.apache.accumulo.minicluster.ServerType;
import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
import org.apache.accumulo.test.functional.FunctionalTestUtils;
import org.apache.hadoop.conf.Configuration;
+import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
public class CleanWalIT extends AccumuloClusterIT {
+ private static final Logger log = Logger.getLogger(CleanWalIT.class);
@Override
public int defaultTimeoutSeconds() {
@@ -51,6 +59,24 @@ public class CleanWalIT extends AccumuloClusterIT {
cfg.useMiniDFS(true);
}
+ @Before
+ public void offlineTraceTable() throws Exception {
+ Connector conn = getConnector();
+ String traceTable = conn.instanceOperations().getSystemConfiguration().get(Property.TRACE_TABLE.getKey());
+ if (conn.tableOperations().exists(traceTable)) {
+ conn.tableOperations().offline(traceTable, true);
+ }
+ }
+
+ @After
+ public void onlineTraceTable() throws Exception {
+ Connector conn = getConnector();
+ String traceTable = conn.instanceOperations().getSystemConfiguration().get(Property.TRACE_TABLE.getKey());
+ if (conn.tableOperations().exists(traceTable)) {
+ conn.tableOperations().online(traceTable, true);
+ }
+ }
+
// test for ACCUMULO-1830
@Test
public void test() throws Exception {
@@ -65,12 +91,16 @@ public class CleanWalIT extends AccumuloClusterIT {
getCluster().getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
// all 3 tables should do recovery, but the bug doesn't really remove the log file references
- getCluster().start();
+ getCluster().getClusterControl().startAllServers(ServerType.TABLET_SERVER);
+
for (String table : new String[] {MetadataTable.NAME, RootTable.NAME})
conn.tableOperations().flush(table, null, null, true);
+ log.debug("Checking entries for " + tableName);
assertEquals(1, count(tableName, conn));
- for (String table : new String[] {MetadataTable.NAME, RootTable.NAME})
- assertEquals(0, countLogs(table, conn));
+ for (String table : new String[] {MetadataTable.NAME, RootTable.NAME}) {
+ log.debug("Checking logs for " + table);
+ assertEquals("Found logs for " + table, 0, countLogs(table, conn));
+ }
bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
m = new Mutation("row");
@@ -81,20 +111,29 @@ public class CleanWalIT extends AccumuloClusterIT {
conn.tableOperations().flush(tableName, null, null, true);
conn.tableOperations().flush(MetadataTable.NAME, null, null, true);
conn.tableOperations().flush(RootTable.NAME, null, null, true);
- getCluster().getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
- UtilWaitThread.sleep(3 * 1000);
- getCluster().start();
+ try {
+ getCluster().getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
+ UtilWaitThread.sleep(3 * 1000);
+ } finally {
+ getCluster().getClusterControl().startAllServers(ServerType.TABLET_SERVER);
+ }
assertEquals(0, count(tableName, conn));
}
private int countLogs(String tableName, Connector conn) throws TableNotFoundException {
Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
scanner.fetchColumnFamily(MetadataSchema.TabletsSection.LogColumnFamily.NAME);
- return FunctionalTestUtils.count(scanner);
+ int count = 0;
+ for (Entry<Key,Value> entry : scanner) {
+ log.debug("Saw " + entry.getKey() + "=" + entry.getValue());
+ count++;
+ }
+ return count;
}
int count(String tableName, Connector conn) throws Exception {
- return FunctionalTestUtils.count(conn.createScanner(tableName, Authorizations.EMPTY));
+ Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
+ return FunctionalTestUtils.count(s);
}
}