db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r761204 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/MogTest.java
Date Thu, 02 Apr 2009 08:36:01 GMT
Author: kristwaa
Date: Thu Apr  2 08:36:01 2009
New Revision: 761204

URL: http://svn.apache.org/viewvc?rev=761204&view=rev
Log:
DERBY-4085: Improve testing of the in-memory back end.
Report the seed on a failure, so that the run can be repeated.

Patch file: derby-4085-5a-report_seed_on_failure.diff


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/MogTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/MogTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/MogTest.java?rev=761204&r1=761203&r2=761204&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/MogTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memorydb/MogTest.java
Thu Apr  2 08:36:01 2009
@@ -89,7 +89,7 @@
           throws SQLException {
 
     // Initialize test objects.
-    long _seed = System.currentTimeMillis();
+    final long _seed = System.currentTimeMillis();
     java.util.Random rng = new java.util.Random(_seed);
     /** MOG generator being tested */
     GenMog genMog = new GenMog(rng);
@@ -124,10 +124,11 @@
       // Cluster the samples again, using SQL.
       clusMogSql.clusterSQL(genMog.n, center, ns, sample);
       // Compare the computed MOG configurations.
-      assertEquals(clusMog.n, clusMogSql.n);
-      compare(clusMog.n, clusMog.weight, clusMogSql.weight);
-      compare(clusMog.n, clusMog.mean, clusMogSql.mean);
-      compare(clusMog.n, clusMog.var, clusMogSql.var);
+      assertEquals("MOG configurations differ, seed=" + _seed,
+              clusMog.n, clusMogSql.n);
+      compare(clusMog.n, clusMog.weight, clusMogSql.weight, _seed);
+      compare(clusMog.n, clusMog.mean, clusMogSql.mean, _seed);
+      compare(clusMog.n, clusMog.var, clusMogSql.var, _seed);
 
       // Produce another initial cluster center configuration.
       ClusMog.random(genMog.n, center, ns, sample, rng);
@@ -136,15 +137,16 @@
       // Cluster the samples again, using SQL.
       clusMogSql.clusterSQL(genMog.n, center, ns, sample);
       // Compare the computed MOG configurations.
-      assertEquals(clusMog.n, clusMogSql.n);
-      compare(clusMog.n, clusMog.weight, clusMogSql.weight);
-      compare(clusMog.n, clusMog.mean, clusMogSql.mean);
-      compare(clusMog.n, clusMog.var, clusMogSql.var);
+      assertEquals("MOG configurations differ, seed=" + _seed,
+              clusMog.n, clusMogSql.n);
+      compare(clusMog.n, clusMog.weight, clusMogSql.weight, _seed);
+      compare(clusMog.n, clusMog.mean, clusMogSql.mean, _seed);
+      compare(clusMog.n, clusMog.var, clusMogSql.var, _seed);
     }
   }
 
   /** Compare two floating-point arrays, with tolerance. */
-  private void compare(int n, double ones[], double oths[])
+  private void compare(int n, double ones[], double oths[], final long seed)
   {
     final double thresh = 1.0e-6;
     for (int i=0; i<n; ++i) {
@@ -154,7 +156,7 @@
       final double err = dif / (1.0 + Math.abs(one));
       // Use if to avoid unnecessary string concatenation.
       if (err >= thresh) {
-        fail("Error too big;" + err + " >= " + thresh);
+        fail("Error too big;" + err + " >= " + thresh + ", seed=" + seed);
       }
     }
   }



Mime
View raw message