db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r803694 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_reclaim_longcol.java
Date Wed, 12 Aug 2009 20:16:48 GMT
Author: mikem
Date: Wed Aug 12 20:16:48 2009
New Revision: 803694

URL: http://svn.apache.org/viewvc?rev=803694&view=rev
Log:
DERBY-4037

updated test to wait longer if expected background tasks have not cleaned up
expected pages yet.  Fast machines should see no slowdown in the test.  Slower
machines will wait up to 100 seconds before reporting failure after checking
iteratively for result every 1 second.  Also enhanced printout to identify
which test is failing between the 2 possibilities.

/mikem


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_reclaim_longcol.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_reclaim_longcol.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_reclaim_longcol.java?rev=803694&r1=803693&r2=803694&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_reclaim_longcol.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_reclaim_longcol.java
Wed Aug 12 20:16:48 2009
@@ -163,26 +163,55 @@
 
         int total_expected_page_max = 12 + num_rows;
 
-        if (total_pages > total_expected_page_max)
-        {
-            // for the above test case we expect the following space:
-            //     page 0
-            //     page 1 
-            //     free space from 1 blob - 9 pages per blob
-            //     allocated page per long/short blob insert.  Each long
-            //         inserts onto a new page to try and fit it entirely
-            //         on a page.  Then the short blob goes to last inserted
-            //         page.  This process repeats.  The previous pages are
-            //         marked "half-filled" and can be used in future for
-            //         short rows that don't fit on the last page inserted.
-            
+        int MAX_WAIT_FOR_BG_THREAD = 100000;
+        int ms_waited              = 20;
 
+        while (total_pages > total_expected_page_max)
+        {
+            if (ms_waited < MAX_WAIT_FOR_BG_THREAD)
+            {
+                // The result is dependent on background activity which may
+                // differ from machine to machine.  Loop, sleeping in this
+                // thread to allow background thread to run.
+
+                try
+                {
+                    ms_waited += 1000;
+                    Thread.sleep(1000);
+                }
+                catch (Exception ex)
+                {
+                    // just ignore interupts of sleep.
+                }
+
+                sp_info = getSpaceInfo(conn, "APP", "LONGCOL", true);
+
+                total_pages = 
+                    sp_info[SPACE_INFO_NUM_ALLOC] + 
+                    sp_info[SPACE_INFO_NUM_FREE];
+            }
+            else
+            {
+                // for the above test case we expect the following space:
+                //     page 0
+                //     page 1 
+                //     free space from 1 blob - 9 pages per blob
+                //     allocated page per long/short blob insert.  Each long
+                //         inserts onto a new page to try and fit it entirely
+                //         on a page.  Then the short blob goes to last inserted
+                //         page.  This process repeats.  The previous pages are
+                //         marked "half-filled" and can be used in future for
+                //         short rows that don't fit on the last page inserted.
+
+                System.out.println(
+                    "Test 1 failed, expected less than " + 
+                    total_expected_page_max + " pages - count is:\n" +
+                    "free pages     : "   + sp_info[SPACE_INFO_NUM_FREE] +
+                    "\nallocated pages: " + sp_info[SPACE_INFO_NUM_ALLOC] +
+                    "\nWaited " + ms_waited + "ms. for background work.");
 
-            System.out.println(
-                "Test failed, expected less than " + 
-                total_expected_page_max + " pages - count is:\n" +
-                "free pages     : "   + sp_info[SPACE_INFO_NUM_FREE] +
-                "\nallocated pages: " + sp_info[SPACE_INFO_NUM_ALLOC]);
+                break;
+            }
         }
 
         if (verbose)
@@ -308,13 +337,45 @@
         // bigger than worksize, something like work_size=5 and total_work >100
         int total_expected_page_max = 30 * work_size; 
 
-        if (total_pages > total_expected_page_max)
+        int MAX_WAIT_FOR_BG_THREAD = 100000;
+        int ms_waited              = 20;
+
+        while (total_pages > total_expected_page_max)
         {
-            System.out.println(
-                "Test failed, expected less than " + 
-                total_expected_page_max + " pages - count is:\n" +
-                "free pages     : "   + sp_info[SPACE_INFO_NUM_FREE] +
-                "\nallocated pages: " + sp_info[SPACE_INFO_NUM_ALLOC]);
+            if (ms_waited < MAX_WAIT_FOR_BG_THREAD)
+            {
+                // The result is dependent on background activity which may
+                // differ from machine to machine.  Loop, sleeping in this
+                // thread to allow background thread to run.
+
+                try
+                {
+                    ms_waited += 1000;
+                    Thread.sleep(1000);
+                }
+                catch (Exception ex)
+                {
+                    // just ignore interupts of sleep.
+                }
+
+                sp_info = getSpaceInfo(conn, "APP", "LONGCOL", true);
+
+                total_pages = 
+                    sp_info[SPACE_INFO_NUM_ALLOC] + 
+                    sp_info[SPACE_INFO_NUM_FREE];
+            }
+            else
+            {
+
+                System.out.println(
+                    "Test 2 failed, expected less than " + 
+                    total_expected_page_max + " pages - count is:\n" +
+                    "free pages     : "   + sp_info[SPACE_INFO_NUM_FREE] +
+                    "\nallocated pages: " + sp_info[SPACE_INFO_NUM_ALLOC] +
+                    "\nWaited " + ms_waited + "ms. for background work.");
+
+                break;
+            }
         }
 
         if (verbose)



Mime
View raw message