You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2015/06/16 16:33:10 UTC
svn commit: r1685847 -
/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java
Author: markrmiller
Date: Tue Jun 16 14:33:09 2015
New Revision: 1685847
URL: http://svn.apache.org/r1685847
Log:
SOLR-7458: Improve test assert messages.
Modified:
lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java?rev=1685847&r1=1685846&r2=1685847&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java Tue Jun 16 14:33:09 2015
@@ -194,12 +194,15 @@ public class HdfsDirectoryFactoryTest ex
SolrInfoMBean localityBean = it.next(); // brittle, but it's ok
// Make sure we have the right bean.
- assertEquals("hdfs-locality", localityBean.getName());
+ assertEquals("Got the wrong bean: " + localityBean.getName(), "hdfs-locality", localityBean.getName());
// We haven't done anything, so there should be no data
NamedList<?> statistics = localityBean.getStatistics();
- assertEquals(0l, statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL));
- assertEquals(0, statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_RATIO));
+ assertEquals("Saw bytes that were not written: " + statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL), 0l,
+ statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL));
+ assertEquals(
+ "Counted bytes as local when none written: " + statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_RATIO), 0,
+ statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_RATIO));
// create a directory and a file
String path = HdfsTestUtil.getURI(dfsCluster) + "/solr3/";
@@ -211,16 +214,24 @@ public class HdfsDirectoryFactoryTest ex
final long long_bytes = Long.SIZE / Byte.SIZE;
// no locality because hostname not set
+ factory.setHost("bogus");
statistics = localityBean.getStatistics();
- assertEquals(long_bytes, statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL));
- assertEquals(1, statistics.get(HdfsLocalityReporter.LOCALITY_BLOCKS_TOTAL));
- assertEquals(0, statistics.get(HdfsLocalityReporter.LOCALITY_BLOCKS_LOCAL));
-
+ assertEquals("Wrong number of total bytes counted: " + statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL),
+ long_bytes, statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_TOTAL));
+ assertEquals("Wrong number of total blocks counted: " + statistics.get(HdfsLocalityReporter.LOCALITY_BLOCKS_TOTAL),
+ 1, statistics.get(HdfsLocalityReporter.LOCALITY_BLOCKS_TOTAL));
+ assertEquals(
+ "Counted block as local when bad hostname set: " + statistics.get(HdfsLocalityReporter.LOCALITY_BLOCKS_LOCAL),
+ 0, statistics.get(HdfsLocalityReporter.LOCALITY_BLOCKS_LOCAL));
+
// set hostname and check again
factory.setHost("127.0.0.1");
statistics = localityBean.getStatistics();
- assertEquals(long_bytes, statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_LOCAL));
-
+ assertEquals(
+ "Did not count block as local after setting hostname: "
+ + statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_LOCAL),
+ long_bytes, statistics.get(HdfsLocalityReporter.LOCALITY_BYTES_LOCAL));
+
factory.close();
}
}