1

I am using in memory databases like HSQL and FONGO in my java application for junit tests

I am executing these build on linux machine.

Due to these in memory database, build are taking too long to build.

Build which is supposed to complete in 2 minutes is taking 30 mins.

Any pointers would be of great help

Patan
  • 17,073
  • 36
  • 124
  • 198
  • 1
    Have you checked how your memory evolves during your tests using the jconsole or jvisualvm? maybe the GC activity is too high so you need to allocate more memory to your JVM? – Nicolas Filotto Sep 24 '16 at 13:23
  • Maybe you should rewrite your tests to use mocks more. Only repository classes need to access a database. DI engines will slow down tests if you recreate beans over and over. Maybe your unit tests are really integration tests. Review them all to be sure that they're all giving you real value. – duffymo Sep 24 '16 at 13:28
  • @NicolasFilotto.. Thank you for reply. I have JAVA_OPTS set as -XX:MaxPermSize=1200M -Xms2400M -Xmx4800M – Patan Sep 24 '16 at 14:03
  • how do you build? with maven? If so please note that surefire uses `MAVEN_OPTS` not `JAVA_OPTS` – Nicolas Filotto Sep 24 '16 at 14:06
  • @NicolasFilotto. I have set the MAVEN_OPTS. Still it takes time. – Patan Sep 24 '16 at 14:24
  • Have you checked how your memory evolves as asked in my first comment? – Nicolas Filotto Sep 24 '16 at 15:45

1 Answers1

0

I was able to fix the issue with this.

The random number generation was taking too long. I did the following changes.

The library used for random number generation in Sun's JVM relies on /dev/random by default for UNIX platforms. This can potentially block the WebLogic SIP Server process because on some operating systems /dev/random waits for a certain amount of "noise" to be generated on the host machine before returning a result. Although /dev/random is more secure, BEA recommends using /dev/urandom if the default JVM configuration delays WebLogic SIP Server startup.

To determine if your operating system exhibits this behavior, try displaying a portion of the file from a shell prompt:

head -n 1 /dev/random

If the command returns immediately, you can use /dev/random as the default generator for SUN's JVM. If the command does not return immediately, use these steps to configure the JVM to use /dev/urandom:

 1. Open the $JAVA_HOME/jre/lib/security/java.security file in a text
    editor. 
 2. Change the line:  
    securerandom.source=file:/dev/random
            to
    securerandom.source=file:/dev/urandom 
 3. Save your change and exit the text editor.
Patan
  • 17,073
  • 36
  • 124
  • 198
  • Please provide the information inside the answer. Link only answers are not answers. – Svetlin Zarev Oct 18 '16 at 05:54
  • That doesn't even make sense as an answer. Why would your build be blocked by random number generation?? –  Oct 18 '16 at 06:01
  • @duskwuff. The build uses in Fongo in memory database which is using random number generator. Hence the builds are hanged. – Patan Oct 18 '16 at 06:03