Patch #5404

Fix Redmine tests for JRuby 1.4.x and 1.5.0

Added by Gregor Schmidt over 7 years ago. Updated about 5 years ago.

Status:ClosedStart date:2010-04-29
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Ruby support
Target version:-

Description

The attached patch will fix all test failures and error for JRuby 1.4.x and the current JRuby 1.5.1.RC1 and RC2. Compatibility with Ruby 1.8.7 is preserved.

The patches are apply to r3695 (trunk) and r3662 (0.9-stable).

Please also have a look at the git branches at

5404_fix_redmine_on_jruby_stable.diff Magnifier (8.39 KB) Gregor Schmidt, 2010-04-29 20:21

5404_fix_redmine_on_jruby_trunk.diff Magnifier (8.54 KB) Gregor Schmidt, 2010-04-29 20:21

git_adapter.rb.diff Magnifier - Fix Git adapter on JRuby and Windows (397 Bytes) Babar O'Cap, 2010-06-23 10:35


Related issues

Related to Redmine - Defect #632: Theme discovery doesn't work under JRuby on Rails war str... New 2008-02-12
Related to Redmine - Defect #4494: Mercurial access not working in jruby Closed 2009-12-28
Related to Redmine - Defect #8510: JRuby: Can't open administrator panel if scm command is ... Closed 2011-06-03

Associated revisions

Revision 3708
Added by Jean-Philippe Lang over 7 years ago

Fixes time report with JRuby (#5404).

Revision 3709
Added by Jean-Philippe Lang over 7 years ago

Fixes workflow edit with JRuby (#5404).

Revision 3710
Added by Jean-Philippe Lang over 7 years ago

Fixes theme discovery under JRuby on Rails war structure (#632, #5404).

Revision 3718
Added by Jean-Philippe Lang over 7 years ago

Fixes some textile issues with JRuby (#5404).

Revision 3721
Added by Jean-Philippe Lang over 7 years ago

Adds jdbc rake tasks (#5404).

Revision 3722
Added by Jean-Philippe Lang over 7 years ago

Fixes Mercurial adapter for JRuby (#4494, #5404).

Revision 3723
Added by Jean-Philippe Lang over 7 years ago

Fixes Bazaar adapter for JRuby/Win32 (#5404).

Revision 4624
Added by Toshi MARUYAMA almost 7 years ago

repository: git: change io.gets to io.readlines (#5404, #5096).

Revision 4743
Added by Toshi MARUYAMA almost 7 years ago

scm: darcs: change io.gets to io.read and add darcs version unit (#4494, #5404).

Revision 6230
Added by Toshi MARUYAMA over 6 years ago

scm: catch all exceptions at adapter shellout() to fork scm command (#8510, #6713, #4725, #5404).

If scm command does not exist,
Linux JRuby 1.6.2 (ruby-1.8.7-p330) raises java.io.IOException in production environment.

History

#2 Updated by Gregor Schmidt over 7 years ago

this should also fix #4494 and #632

#3 Updated by Eric Davis over 7 years ago

Anyone with experience with jruby want to test these? It would be nice to fully support jruby in Redmine 1.0.

#4 Updated by Jean-Philippe Lang over 7 years ago

I have made a few tests with JRuby1.4.0 / Win32 with Mysql and SQLite3. I'm still getting a bunch of failures with Mysql. It's much better with Sqlite3 (after fixing a few errors in r3700 and r3701). What's your testing platform? Also, it looks like Bazaar tests all failed.

Your patch includes a few patches to JDBC postgres and sqlite3 adapters. Where do this patches come from? I'd really like that the adapters get fixed rather than including these patches in the Redmine code.

>java -version
java version "1.6.0_17" 
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)

>jruby -v
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) Client VM 1.6.0_17) [x86-java]

#5 Updated by Gregor Schmidt over 7 years ago

Thank you for having a look at the patch.

I was testing on Mac OS X using the JVM shipped with 10.5.

$ ruby -v
jruby 1.4.1 (ruby 1.8.7 patchlevel 174) (2010-04-26 ea6db6a) (Java HotSpot(TM) Server VM 1.5.0_22) [i386-java]

$ ruby -v
jruby 1.5.0.RC2 (ruby 1.8.7 patchlevel 249) (2010-04-28 7c245f3) (Java HotSpot(TM) Server VM 1.5.0_22) [i386-java]

$ java -version
java version "1.5.0_22" 
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03-333-9M3125)

I forgot to mention, that the SQLite test do not work on my machine either. It seems, that activerecord-jdcbsqlite3-adapter and jdbc-sqlite3 are way behind the sqlite3-ruby gem. Both show very different behaviour on my machine. MySQL (5.1.45) and PostgreSQL (8.3.4) on the other hand work without problems.

Concerning the patches to activerecord-jdbc*-adapter

The patch to the Postgres adapter is filed as Bug on AR-JDBC-104 and I wrote a mail to the jruby list. Unfortunately, I did not get any feedback.

I'm not sure about the Patches to the SQLite3 adapter. I wrote another mail to the JRuby Mailing list, concerning my problems, I had with SQLite and also added a simple test case. Unfortunately I did not get any feedback here, either.

Therefore, I've added the patches into a single file, such that we are able to keep an eye on them. I totally get your argument about getting the adapters fixed instead of fixing them in redmine, but I wanted to get the test running and a working Redmine. I will keep bullying the AR-JDBC guys to get their libraries fixed.

Repository Adapters

Sorry, I was a bit hastily. I've only tested file system, mercurial, subversion and git. I simply forgot the others. I could have a look at bazaar, cvs and darcs, if you like.

#6 Updated by Jean-Philippe Lang over 7 years ago

The patch to Engines to make use of Rails.public_path does not seem to have any effect when deploying a WAR.

When Engines gets loaded, Rails.public_path points to WEB-INF/public and thus assets are mirrored to WEB-INF/public. After the application started Rails.public_path points to the root of the webapp but it's too late... I really don't know how to fix it.

#7 Updated by Gregor Schmidt over 7 years ago

Jean-Philippe Lang wrote:

The patch to Engines to make use of Rails.public_path does not seem to have any effect when deploying a WAR.

When Engines gets loaded, Rails.public_path points to WEB-INF/public and thus assets are mirrored to WEB-INF/public. After the application started Rails.public_path points to the root of the webapp but it's too late... I really don't know how to fix it.

You are totally right. When I fixed the theme loading mechanism, I grepped for other occurances of RAILS_ROOT + '/public' and replaced them with Rails.public_path with further testing. But after the change, its a bug in JRuby-Rack. Beforehand it was one in Redmine. Therefore the change has a certain value, somehow.

I will try to debug the issue in the context of JRuby-Rack and give feedback, once I have made some progress on that.

#8 Updated by Jean-Philippe Lang over 7 years ago

The only way I found to fix it is the following patch:

Index: config/environment.rb
===================================================================
--- config/environment.rb    (revision 3701)
+++ config/environment.rb    (working copy)
@@ -13,6 +13,11 @@
 # Load Engine plugin if available
 begin
   require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot')
+  module Engines
+    def self.public_directory
+      File.join(Rails.public_path, 'plugin_assets')
+    end
+  end
 rescue LoadError
   # Not available
 end

It works because Rails.public_path is properly set when assets get actually mirrored.

#9 Updated by Gregor Schmidt over 7 years ago

Your fix works for me, but I still think, that this would be a bug in JRuby-Rack, which is responsible for setting the correct public_path.

Currently it's no problem for me, that it does not work correctly, since the plugin assets are already copied when 'environment' is loaded during my warbling.

#10 Updated by Jean-Philippe Lang over 7 years ago

Gregor Schmidt wrote:

Currently it's no problem for me, that it does not work correctly, since the plugin assets are already copied when 'environment' is loaded during my warbling.

I wasn't aware of that. Then I think we can live without this patch.

#11 Updated by Jean-Philippe Lang over 7 years ago

Mercurial and Bazaar adapters are now fixed for JRuby.

r3724 passes all tests with JRuby 1.5.0 RC2 and MySQL for me. But it looks like something still goes wrong at finn.de:
http://ci.finn.de/builds/jruby_redmine-trunk_mysql/3724

#12 Updated by Jean-Philippe Lang over 7 years ago

With your jruby_compat initializer:
  • PostgreSQL: all tests pass
  • SQLite3: the patches almost fix it, but there's still a failure (leaving the due date field empty when creating an issue leads to "Due date must be greater than start date")

#13 Updated by Gregor Schmidt over 7 years ago

Concerning the failures on ci.finn.de. rake db:schema:dump produces a faulty db/schema.rb. All tests pass, when using config.active_record.schema_format = :sql. I will try to build a simple failing test case for AR-JDBC, as I think it is their fault.

Concerning the jruby_compat initializer. As long as they are not fixed in AR-JDBC itself, are you willing to provide these patches in Redmine itself or should be publish them via plugin for everybody interested?

#14 Updated by Gregor Schmidt over 7 years ago

Furthermore I would like to thank you for your fast feedback and integration of the patches.

#15 Updated by Gregor Schmidt over 7 years ago

The db:schema:dump bug is now known as ACTIVERECORD_JDBC-112. Let's that this will be fixed soon.

#16 Updated by Babar O'Cap over 7 years ago

I've a bug with JRuby 1.5.1 in Git repositories on Windows.

Redmine::Scm::Adapters::GitAdapter#last_rev source:trunk/lib/redmine/scm/adapters/git_adapter.rb#L87 doesn't work properly.

Here a patch to fix this issue.

NB: I didn't test on an other platform.

#17 Updated by Toshi MARUYAMA almost 7 years ago

Babar O'Cap wrote:

I've a bug with JRuby 1.5.1 in Git repositories on Windows.

Redmine::Scm::Adapters::GitAdapter#last_rev source:trunk/lib/redmine/scm/adapters/git_adapter.rb#L87 doesn't work properly.

Here a patch to fix this issue.

It seems io.gets() problem of git adapter.
I posted git-io-gets.diff to fix it at note-11 of #5096.

#18 Updated by Toshi MARUYAMA over 6 years ago

  • Category set to Ruby support

#19 Updated by Jean-Philippe Lang about 5 years ago

  • Status changed from New to Closed

Closing it, the test suite is running fine with JRuby 1.6.7 now.

Also available in: Atom PDF