I was working on JRubyOnRails project, where we used Cucumber in providing a web-app feature that required functional testing of some web portals.
Scenario:
In this Rails application, 'Cucumber' tests for different web-portals are invoked every scheduled interval using 'derailed_cuke' and then the test results are processed and saved in a MySQL database.
Gems Used:
#for Rails3
'rails', '3.0.3'
#for MySQL ActiveRecord
'activerecord-jdbcmysql-adapter', '1.0.2'
'activerecord-jdbc-adapter', '1.0.2'
'jdbc-mysql', '5.0.4'
#for Cucumber
'cucumber', '0.10.0'
'cucumber-rails', '0.3.2'
in my JRubyOnRails appication (one of the major benefit of using JRuby).
[] using JVM Parameters to increase the Heap Size used by Rails application
#jruby -J-Xmx2500m -J-Xms2500m -J-Xmn512m -S rails s
here,
-J-Xmx2500m ~ means maximum Java Heap Size increased to 2500m
-J-Xms2500m ~ means initial Java Heap Size increased to 2500m
-J-Xmn2500m ~ means eden Java Heap Size increased to 500m
for server-side applications, Xmx & Xms is preferred to be kept same
Scenario:
In this Rails application, 'Cucumber' tests for different web-portals are invoked every scheduled interval using 'derailed_cuke' and then the test results are processed and saved in a MySQL database.
Gems Used:
#for Rails3
'rails', '3.0.3'
#for MySQL ActiveRecord
'activerecord-jdbcmysql-adapter', '1.0.2'
'activerecord-jdbc-adapter', '1.0.2'
'jdbc-mysql', '5.0.4'
#for Cucumber
'cucumber', '0.10.0'
'cucumber-rails', '0.3.2'
'gherkin', '2.3.3'
#with JRuby version 1.5.5
Exception:
- After starting Rails Server and waiting for some non-specific time, an exception started arising mentioning ActiveRecord and an Heap OutOfMemory Exception being raised.
- I checked for my database services, schema & content; all was as expected and even working fine from 'rails console'.
Action:
- My bad old debug-style... the first thing I did was inserted 'print STATUS_MSG' at all suspected locations for ActiveRecord.
- It worked :), and the location sorted out was the place where cucumber-tests' processed results was saved in database.
- So now, 'Cucumber' was under suspicion radar... I google-d over recent incidents including both 'OutOfMemory Exception' and 'Cucumber', and there were few blogposts about similar problem of 'memory leakage' in Cucumber.
in my JRubyOnRails appication (one of the major benefit of using JRuby).
- So, I started tweaking the Cucumber test's schedule interval to a higher and lower value.
This clearly showed it's impact over the Memory Profiling by JConsole and the relativity of duration in which the Exception was being raised.
Solution:
Until the Cucumber flaw is corrected, the work-around used was
[] pushing in some more RAM[] using JVM Parameters to increase the Heap Size used by Rails application
#jruby -J-Xmx2500m -J-Xms2500m -J-Xmn512m -S rails s
here,
-J-Xmx2500m ~ means maximum Java Heap Size increased to 2500m
-J-Xms2500m ~ means initial Java Heap Size increased to 2500m
-J-Xmn2500m ~ means eden Java Heap Size increased to 500m
for server-side applications, Xmx & Xms is preferred to be kept same