SoftCacheTest is Failing

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SoftCacheTest is Failing

Dan Forward
I just checked out the latest code for iBATIS 3 and discovered that a unit test fails while building.

------------------------------------------------------------
Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.006 sec <<< FAILURE!
shouldDemonstrateObjectsBeingCollectedAsNeeded(org.apache.ibatis.cache.SoftCacheTest)  Time elapsed: 4.96 sec  <<< FAILURE!
java.lang.AssertionError:
        at org.junit.Assert.fail(Assert.java:71)
        at org.junit.Assert.assertTrue(Assert.java:34)
        at org.junit.Assert.assertTrue(Assert.java:43)
        at org.apache.ibatis.cache.SoftCacheTest.shouldDemonstrateObjectsBeingCollectedAsNeeded(SoftCacheTest.java:21)
------------------------------------------------------------

It seems that this test attempts to fill the cache beyond the limits of available memory, then checks whether the size of the cache is smaller than the number of items added. The cache is filled with 300,000 byte arrays that are 5001 bytes in size.

I set the limit to 3,000,000 and told the loop to break as soon as the size of the cache was less than the number entered, and discovered that it happened after 326,315 entries and approximately 6 seconds on my machine. The test I used is below.

@Test
public void shouldDemonstrateObjectsBeingCollectedAsNeeded() throws Exception {
        final int N = 3000000;
        SoftCache cache = new SoftCache(new PerpetualCache("default"));
        for (int i = 0; i < N; i++) {
          byte[] array = new byte[5001]; //waste a bunch of memory
          array[5000] = 1;
          cache.putObject(i, array);
          Object value = cache.getObject(i);
          if (cache.getSize() < i + 1) {
                  System.out.println("Cache exceeded with " + (i + 1) + " entries.");
                  break;
          }
        }
        assertTrue(cache.getSize() < N);
}
Reply | Threaded
Open this post in threaded view
|

Re: SoftCacheTest is Failing

nmaves
Dan,

What release did you check out?  What does your env look like?  OS?
Java version?

I have not seen a test failing in any of the beta builds.

Nathan

On Wed, Dec 23, 2009 at 11:30 AM, Dan Forward
<[hidden email]> wrote:

>
> I just checked out the latest code for iBATIS 3 and discovered that a unit
> test fails while building.
>
> ------------------------------------------------------------
> Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.006 sec
> <<< FAILURE!
> shouldDemonstrateObjectsBeingCollectedAsNeeded(org.apache.ibatis.cache.SoftCacheTest)
> Time elapsed: 4.96 sec  <<< FAILURE!
> java.lang.AssertionError:
>        at org.junit.Assert.fail(Assert.java:71)
>        at org.junit.Assert.assertTrue(Assert.java:34)
>        at org.junit.Assert.assertTrue(Assert.java:43)
>        at
> org.apache.ibatis.cache.SoftCacheTest.shouldDemonstrateObjectsBeingCollectedAsNeeded(SoftCacheTest.java:21)
> ------------------------------------------------------------
>
> It seems that this test attempts to fill the cache beyond the limits of
> available memory, then checks whether the size of the cache is smaller than
> the number of items added. The cache is filled with 300,000 byte arrays that
> are 5001 bytes in size.
>
> I set the limit to 3,000,000 and told the loop to break as soon as the size
> of the cache was less than the number entered, and discovered that it
> happened after 326,315 entries and approximately 6 seconds on my machine.
> The test I used is below.
>
> @Test
> public void shouldDemonstrateObjectsBeingCollectedAsNeeded() throws
> Exception {
>        final int N = 3000000;
>        SoftCache cache = new SoftCache(new PerpetualCache("default"));
>        for (int i = 0; i < N; i++) {
>          byte[] array = new byte[5001]; //waste a bunch of memory
>          array[5000] = 1;
>          cache.putObject(i, array);
>          Object value = cache.getObject(i);
>          if (cache.getSize() < i + 1) {
>                  System.out.println("Cache exceeded with " + (i + 1) + " entries.");
>                  break;
>          }
>        }
>        assertTrue(cache.getSize() < N);
> }
>
> --
> View this message in context: http://old.nabble.com/SoftCacheTest-is-Failing-tp26905687p26905687.html
> Sent from the iBATIS - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: SoftCacheTest is Failing

Clinton Begin
Those are a bit environment specific.  I've had that one fail the odd time, and I believe one of the other memory tests is ignored because it's very difficult to make work consistently.  It's not the best way to test, but it's better than no test at all (and this one rarely fails, and I run it on 3 different OS/architecture combinations).  

That said, I do like Dan's enhancement to the test.  I'll have a closer look this week. 

clinton

On Wed, Dec 23, 2009 at 4:21 PM, Nathan Maves <[hidden email]> wrote:
Dan,

What release did you check out?  What does your env look like?  OS?
Java version?

I have not seen a test failing in any of the beta builds.

Nathan

On Wed, Dec 23, 2009 at 11:30 AM, Dan Forward
<[hidden email]> wrote:
>
> I just checked out the latest code for iBATIS 3 and discovered that a unit
> test fails while building.
>
> ------------------------------------------------------------
> Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.006 sec
> <<< FAILURE!
> shouldDemonstrateObjectsBeingCollectedAsNeeded(org.apache.ibatis.cache.SoftCacheTest)
> Time elapsed: 4.96 sec  <<< FAILURE!
> java.lang.AssertionError:
>        at org.junit.Assert.fail(Assert.java:71)
>        at org.junit.Assert.assertTrue(Assert.java:34)
>        at org.junit.Assert.assertTrue(Assert.java:43)
>        at
> org.apache.ibatis.cache.SoftCacheTest.shouldDemonstrateObjectsBeingCollectedAsNeeded(SoftCacheTest.java:21)
> ------------------------------------------------------------
>
> It seems that this test attempts to fill the cache beyond the limits of
> available memory, then checks whether the size of the cache is smaller than
> the number of items added. The cache is filled with 300,000 byte arrays that
> are 5001 bytes in size.
>
> I set the limit to 3,000,000 and told the loop to break as soon as the size
> of the cache was less than the number entered, and discovered that it
> happened after 326,315 entries and approximately 6 seconds on my machine.
> The test I used is below.
>
> @Test
> public void shouldDemonstrateObjectsBeingCollectedAsNeeded() throws
> Exception {
>        final int N = 3000000;
>        SoftCache cache = new SoftCache(new PerpetualCache("default"));
>        for (int i = 0; i < N; i++) {
>          byte[] array = new byte[5001]; //waste a bunch of memory
>          array[5000] = 1;
>          cache.putObject(i, array);
>          Object value = cache.getObject(i);
>          if (cache.getSize() < i + 1) {
>                  System.out.println("Cache exceeded with " + (i + 1) + " entries.");
>                  break;
>          }
>        }
>        assertTrue(cache.getSize() < N);
> }
>
> --
> View this message in context: http://old.nabble.com/SoftCacheTest-is-Failing-tp26905687p26905687.html
> Sent from the iBATIS - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: SoftCacheTest is Failing

Dan Forward
In reply to this post by nmaves
Subversion
------------------------------------------------------------
URL: http://svn.apache.org/repos/asf/ibatis/java/ibatis-3/trunk
Revision: 893634
Last Changed Author: cbegin
Last Changed Rev: 893558
Last Changed Date: 2009-12-23 09:01:16 -0700 (Wed, 23 Dec 2009)
------------------------------------------------------------

Java
------------------------------------------------------------
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02, mixed mode)
-vmargs -Xms256m -Xmx2048m -XX:MaxPermSize=512m
------------------------------------------------------------

OS
------------------------------------------------------------
Linux host 2.6.31-16-generic #53-Ubuntu SMP Tue Dec 8 04:02:15 UTC 2009 x86_64 GNU/Linux
(Ubuntu 9.10 64-bit)
------------------------------------------------------------

nmaves wrote
Dan,

What release did you check out?  What does your env look like?  OS?
Java version?

I have not seen a test failing in any of the beta builds.

Nathan

On Wed, Dec 23, 2009 at 11:30 AM, Dan Forward
<dan-nabble@forwardhome.com> wrote:
>
> I just checked out the latest code for iBATIS 3 and discovered that a unit
> test fails while building.
>
> ------------------------------------------------------------
> Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.006 sec
> <<< FAILURE!
> shouldDemonstrateObjectsBeingCollectedAsNeeded(org.apache.ibatis.cache.SoftCacheTest)
> Time elapsed: 4.96 sec  <<< FAILURE!
> java.lang.AssertionError:
>        at org.junit.Assert.fail(Assert.java:71)
>        at org.junit.Assert.assertTrue(Assert.java:34)
>        at org.junit.Assert.assertTrue(Assert.java:43)
>        at
> org.apache.ibatis.cache.SoftCacheTest.shouldDemonstrateObjectsBeingCollectedAsNeeded(SoftCacheTest.java:21)
> ------------------------------------------------------------
>
> It seems that this test attempts to fill the cache beyond the limits of
> available memory, then checks whether the size of the cache is smaller than
> the number of items added. The cache is filled with 300,000 byte arrays that
> are 5001 bytes in size.
>
> I set the limit to 3,000,000 and told the loop to break as soon as the size
> of the cache was less than the number entered, and discovered that it
> happened after 326,315 entries and approximately 6 seconds on my machine.
> The test I used is below.
>
> @Test
> public void shouldDemonstrateObjectsBeingCollectedAsNeeded() throws
> Exception {
>        final int N = 3000000;
>        SoftCache cache = new SoftCache(new PerpetualCache("default"));
>        for (int i = 0; i < N; i++) {
>          byte[] array = new byte[5001]; //waste a bunch of memory
>          array[5000] = 1;
>          cache.putObject(i, array);
>          Object value = cache.getObject(i);
>          if (cache.getSize() < i + 1) {
>                  System.out.println("Cache exceeded with " + (i + 1) + " entries.");
>                  break;
>          }
>        }
>        assertTrue(cache.getSize() < N);
> }
>
> --
> View this message in context: http://old.nabble.com/SoftCacheTest-is-Failing-tp26905687p26905687.html
> Sent from the iBATIS - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: dev-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ibatis.apache.org
For additional commands, e-mail: dev-help@ibatis.apache.org