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/08/21 22:27:12 UTC
[1/3] git commit: ACCUMULO-3072 Split the test into multiple methods
and use proper assertions
Repository: accumulo
Updated Branches:
refs/heads/1.6.1-SNAPSHOT caf1ca8cc -> b47c86dcf
refs/heads/master b223488b5 -> c884c8259
ACCUMULO-3072 Split the test into multiple methods and use proper assertions
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/b47c86dc
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/b47c86dc
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/b47c86dc
Branch: refs/heads/1.6.1-SNAPSHOT
Commit: b47c86dcf01dfd1e5503e09910d4379959a2d846
Parents: caf1ca8
Author: Josh Elser <el...@apache.org>
Authored: Thu Aug 21 16:25:42 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 21 16:26:14 2014 -0400
----------------------------------------------------------------------
.../test/functional/CreateAndUseIT.java | 62 +++++++++-----------
test/src/test/resources/log4j.properties | 3 +-
2 files changed, 30 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b47c86dc/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java b/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
index 45c4a31..c1225b3 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.test.functional;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.Map.Entry;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -32,8 +33,12 @@ import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.hadoop.io.Text;
+import org.junit.Assert;
+import org.junit.BeforeClass;
import org.junit.Test;
+import com.google.common.collect.Iterators;
+
public class CreateAndUseIT extends SimpleMacIT {
@Override
@@ -41,21 +46,23 @@ public class CreateAndUseIT extends SimpleMacIT {
return 2 * 60;
}
- @Test
- public void run() throws Exception {
- SortedSet<Text> splits = new TreeSet<Text>();
+ private static SortedSet<Text> splits;
+
+ @BeforeClass
+ public static void createData() throws Exception {
+ splits = new TreeSet<Text>();
for (int i = 1; i < 256; i++) {
splits.add(new Text(String.format("%08x", i << 8)));
}
+ }
- // TEST 1 create a table and immediately batch write to it
-
+ @Test(timeout = 2 * 60 * 1000)
+ public void verifyDataIsPresent() throws Exception {
Text cf = new Text("cf1");
Text cq = new Text("cq1");
- String[] tableNames = getUniqueNames(3);
- String tableName = tableNames[0];
+ String tableName = getUniqueNames(1)[0];
getConnector().tableOperations().create(tableName);
getConnector().tableOperations().addSplits(tableName, splits);
BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
@@ -68,30 +75,23 @@ public class CreateAndUseIT extends SimpleMacIT {
}
bw.close();
-
- // verify data is there
Scanner scanner1 = getConnector().createScanner(tableName, Authorizations.EMPTY);
int ei = 1;
for (Entry<Key,Value> entry : scanner1) {
- if (!entry.getKey().getRow().toString().equals(String.format("%08x", (ei << 8) - 16))) {
- throw new Exception("Expected row " + String.format("%08x", (ei << 8) - 16) + " saw " + entry.getKey().getRow());
- }
-
- if (!entry.getValue().toString().equals("" + ei)) {
- throw new Exception("Expected value " + ei + " saw " + entry.getValue());
- }
+ Assert.assertEquals(String.format("%08x", (ei << 8) - 16), entry.getKey().getRow().toString());
+ Assert.assertEquals(Integer.toString(ei), entry.getValue().toString());
ei++;
}
- if (ei != 257) {
- throw new Exception("Did not see expected number of rows, ei = " + ei);
- }
+ Assert.assertEquals("Did not see expected number of rows", 257, ei);
+ }
- // TEST 2 create a table and immediately scan it
- String table2 = tableNames[1];
+ @Test(timeout = 2 * 60 * 1000)
+ public void createTableAndScan() throws Exception {
+ String table2 = getUniqueNames(1)[0];
getConnector().tableOperations().create(table2);
getConnector().tableOperations().addSplits(table2, splits);
Scanner scanner2 = getConnector().createScanner(table2, Authorizations.EMPTY);
@@ -104,31 +104,25 @@ public class CreateAndUseIT extends SimpleMacIT {
if (count != 0) {
throw new Exception("Did not see expected number of entries, count = " + count);
}
+ }
- // TEST 3 create a table and immediately batch scan it
-
+ @Test(timeout = 2 * 60 * 1000)
+ public void createTableAndBatchScan() throws Exception {
ArrayList<Range> ranges = new ArrayList<Range>();
for (int i = 1; i < 257; i++) {
ranges.add(new Range(new Text(String.format("%08x", (i << 8) - 16))));
}
- String table3 = tableNames[2];
+ String table3 = getUniqueNames(1)[0];
getConnector().tableOperations().create(table3);
getConnector().tableOperations().addSplits(table3, splits);
BatchScanner bs = getConnector().createBatchScanner(table3, Authorizations.EMPTY, 3);
bs.setRanges(ranges);
- count = 0;
- for (Entry<Key,Value> entry : bs) {
- if (entry != null)
- count++;
- }
-
- if (count != 0) {
- throw new Exception("Did not see expected number of entries, count = " + count);
- }
-
+ Iterator<Entry<Key,Value>> iter = bs.iterator();
+ int count = Iterators.size(iter);
bs.close();
+ Assert.assertEquals("Did not expect to find any entries", 0, count);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b47c86dc/test/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/test/src/test/resources/log4j.properties b/test/src/test/resources/log4j.properties
index 3fa1983..67deacd 100644
--- a/test/src/test/resources/log4j.properties
+++ b/test/src/test/resources/log4j.properties
@@ -28,6 +28,7 @@ log4j.logger.org.apache.hadoop.mapred=ERROR
log4j.logger.org.apache.hadoop.tools.DistCp=WARN
log4j.logger.org.apache.hadoop.util.NativeCodeLoader=ERROR
log4j.logger.org.apache.hadoop.util.ProcessTree=WARN
-#log4j.logger.org.apache.zookeeper.ClientCnxn=FATAL
+log4j.logger.org.apache.zookeeper.ClientCnxn=ERROR
#log4j.logger.org.apache.zookeeper.ZooKeeper=WARN
log4j.logger.org.apache.accumulo.core.file.rfile.bcfile=INFO
+log4j.logger.org.apache.accumulo.core.client.impl.ThriftScanner=INFO
\ No newline at end of file
[3/3] git commit: Merge branch '1.6.1-SNAPSHOT'
Posted by el...@apache.org.
Merge branch '1.6.1-SNAPSHOT'
Conflicts:
test/src/test/resources/log4j.properties
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/c884c825
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/c884c825
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/c884c825
Branch: refs/heads/master
Commit: c884c825944d33d3dad067318b4fa4846bbf7ab8
Parents: b223488 b47c86d
Author: Josh Elser <el...@apache.org>
Authored: Thu Aug 21 16:26:55 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 21 16:26:55 2014 -0400
----------------------------------------------------------------------
.../test/functional/CreateAndUseIT.java | 62 +++++++++-----------
test/src/test/resources/log4j.properties | 2 +-
2 files changed, 29 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/c884c825/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
----------------------------------------------------------------------
diff --cc test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
index a91c17c,c1225b3..e31f4b9
--- a/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
@@@ -16,8 -16,8 +16,9 @@@
*/
package org.apache.accumulo.test.functional;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+ import java.util.Iterator;
import java.util.Map.Entry;
import java.util.SortedSet;
import java.util.TreeSet;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/c884c825/test/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --cc test/src/test/resources/log4j.properties
index a960c35,67deacd..d8beb4b
--- a/test/src/test/resources/log4j.properties
+++ b/test/src/test/resources/log4j.properties
@@@ -29,15 -28,7 +29,15 @@@ log4j.logger.org.apache.hadoop.mapred=E
log4j.logger.org.apache.hadoop.tools.DistCp=WARN
log4j.logger.org.apache.hadoop.util.NativeCodeLoader=ERROR
log4j.logger.org.apache.hadoop.util.ProcessTree=WARN
-log4j.logger.org.apache.zookeeper.ClientCnxn=ERROR
-#log4j.logger.org.apache.zookeeper.ZooKeeper=WARN
+log4j.logger.org.apache.zookeeper.ClientCnxn=FATAL
+log4j.logger.org.apache.zookeeper.ZooKeeper=WARN
log4j.logger.org.apache.accumulo.core.file.rfile.bcfile=INFO
-log4j.logger.org.apache.accumulo.core.client.impl.ThriftScanner=INFO
+log4j.logger.org.apache.accumulo.server.util.ReplicationTableUtil=TRACE
+log4j.logger.org.apache.accumulo.core.client.impl.ThriftScanner=INFO
+log4j.logger.org.apache.accumulo.fate.zookeeper.DistributedReadWriteLock=WARN
+log4j.logger.org.mortbay.log=WARN
+log4j.logger.org.apache.hadoop=WARN
+log4j.logger.org.apache.jasper=INFO
+log4j.logger.org.apache.hadoop.hdfs.server.namenode.FSNamesystem.audit=WARN
+log4j.logger.org.apache.hadoop.hdfs.server.datanode.DataNode.clienttrace=WARN
- log4j.logger.BlockStateChange=WARN
++log4j.logger.BlockStateChange=WARN
[2/3] git commit: ACCUMULO-3072 Split the test into multiple methods
and use proper assertions
Posted by el...@apache.org.
ACCUMULO-3072 Split the test into multiple methods and use proper assertions
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/b47c86dc
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/b47c86dc
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/b47c86dc
Branch: refs/heads/master
Commit: b47c86dcf01dfd1e5503e09910d4379959a2d846
Parents: caf1ca8
Author: Josh Elser <el...@apache.org>
Authored: Thu Aug 21 16:25:42 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Aug 21 16:26:14 2014 -0400
----------------------------------------------------------------------
.../test/functional/CreateAndUseIT.java | 62 +++++++++-----------
test/src/test/resources/log4j.properties | 3 +-
2 files changed, 30 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b47c86dc/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java b/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
index 45c4a31..c1225b3 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.test.functional;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.Map.Entry;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -32,8 +33,12 @@ import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.hadoop.io.Text;
+import org.junit.Assert;
+import org.junit.BeforeClass;
import org.junit.Test;
+import com.google.common.collect.Iterators;
+
public class CreateAndUseIT extends SimpleMacIT {
@Override
@@ -41,21 +46,23 @@ public class CreateAndUseIT extends SimpleMacIT {
return 2 * 60;
}
- @Test
- public void run() throws Exception {
- SortedSet<Text> splits = new TreeSet<Text>();
+ private static SortedSet<Text> splits;
+
+ @BeforeClass
+ public static void createData() throws Exception {
+ splits = new TreeSet<Text>();
for (int i = 1; i < 256; i++) {
splits.add(new Text(String.format("%08x", i << 8)));
}
+ }
- // TEST 1 create a table and immediately batch write to it
-
+ @Test(timeout = 2 * 60 * 1000)
+ public void verifyDataIsPresent() throws Exception {
Text cf = new Text("cf1");
Text cq = new Text("cq1");
- String[] tableNames = getUniqueNames(3);
- String tableName = tableNames[0];
+ String tableName = getUniqueNames(1)[0];
getConnector().tableOperations().create(tableName);
getConnector().tableOperations().addSplits(tableName, splits);
BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
@@ -68,30 +75,23 @@ public class CreateAndUseIT extends SimpleMacIT {
}
bw.close();
-
- // verify data is there
Scanner scanner1 = getConnector().createScanner(tableName, Authorizations.EMPTY);
int ei = 1;
for (Entry<Key,Value> entry : scanner1) {
- if (!entry.getKey().getRow().toString().equals(String.format("%08x", (ei << 8) - 16))) {
- throw new Exception("Expected row " + String.format("%08x", (ei << 8) - 16) + " saw " + entry.getKey().getRow());
- }
-
- if (!entry.getValue().toString().equals("" + ei)) {
- throw new Exception("Expected value " + ei + " saw " + entry.getValue());
- }
+ Assert.assertEquals(String.format("%08x", (ei << 8) - 16), entry.getKey().getRow().toString());
+ Assert.assertEquals(Integer.toString(ei), entry.getValue().toString());
ei++;
}
- if (ei != 257) {
- throw new Exception("Did not see expected number of rows, ei = " + ei);
- }
+ Assert.assertEquals("Did not see expected number of rows", 257, ei);
+ }
- // TEST 2 create a table and immediately scan it
- String table2 = tableNames[1];
+ @Test(timeout = 2 * 60 * 1000)
+ public void createTableAndScan() throws Exception {
+ String table2 = getUniqueNames(1)[0];
getConnector().tableOperations().create(table2);
getConnector().tableOperations().addSplits(table2, splits);
Scanner scanner2 = getConnector().createScanner(table2, Authorizations.EMPTY);
@@ -104,31 +104,25 @@ public class CreateAndUseIT extends SimpleMacIT {
if (count != 0) {
throw new Exception("Did not see expected number of entries, count = " + count);
}
+ }
- // TEST 3 create a table and immediately batch scan it
-
+ @Test(timeout = 2 * 60 * 1000)
+ public void createTableAndBatchScan() throws Exception {
ArrayList<Range> ranges = new ArrayList<Range>();
for (int i = 1; i < 257; i++) {
ranges.add(new Range(new Text(String.format("%08x", (i << 8) - 16))));
}
- String table3 = tableNames[2];
+ String table3 = getUniqueNames(1)[0];
getConnector().tableOperations().create(table3);
getConnector().tableOperations().addSplits(table3, splits);
BatchScanner bs = getConnector().createBatchScanner(table3, Authorizations.EMPTY, 3);
bs.setRanges(ranges);
- count = 0;
- for (Entry<Key,Value> entry : bs) {
- if (entry != null)
- count++;
- }
-
- if (count != 0) {
- throw new Exception("Did not see expected number of entries, count = " + count);
- }
-
+ Iterator<Entry<Key,Value>> iter = bs.iterator();
+ int count = Iterators.size(iter);
bs.close();
+ Assert.assertEquals("Did not expect to find any entries", 0, count);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b47c86dc/test/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/test/src/test/resources/log4j.properties b/test/src/test/resources/log4j.properties
index 3fa1983..67deacd 100644
--- a/test/src/test/resources/log4j.properties
+++ b/test/src/test/resources/log4j.properties
@@ -28,6 +28,7 @@ log4j.logger.org.apache.hadoop.mapred=ERROR
log4j.logger.org.apache.hadoop.tools.DistCp=WARN
log4j.logger.org.apache.hadoop.util.NativeCodeLoader=ERROR
log4j.logger.org.apache.hadoop.util.ProcessTree=WARN
-#log4j.logger.org.apache.zookeeper.ClientCnxn=FATAL
+log4j.logger.org.apache.zookeeper.ClientCnxn=ERROR
#log4j.logger.org.apache.zookeeper.ZooKeeper=WARN
log4j.logger.org.apache.accumulo.core.file.rfile.bcfile=INFO
+log4j.logger.org.apache.accumulo.core.client.impl.ThriftScanner=INFO
\ No newline at end of file