jruby and test suite

5 views
Skip to first unread message

Gonzalo

unread,
Jun 19, 2009, 12:09:45 PM6/19/09
to Ruote (OpenWFEru) users
Hi all,

I've run last version of ruote-rest with jruby 1.3.0 and everything
(on the browser) seems to work pretty fine*. I just wanted to pass the
test suite with 'rake test' task and I'm having some problems.

I've changed 'conf/database.yaml' so 'defaults' looks like this:

defaults: &defaults
adapter: jdbcmysql
#adapter: mysql
host: localhost
encoding: utf8


Then, I tried to run the test suite with: 'jruby -S rake test' and
here comes the exit:

Started
..............EEEEEEEEEEEEEEEEEEEEE
Finished in 11.007 seconds.

[...]

35 tests, 22 assertions, 0 failures, 21 errors
rake aborted!



First tests (t_misc, t_auth, ft_auth, st_service) pass. The tests that
have something to do with ar_workitems fail.

Here is the output of some of them:

1) Error:
test_get_errors(StErrorsTest):
ActiveRecord::StatementInvalid:
ActiveRecord::ConnectionNotEstablished: no connection available:
DELETE FROM `ar_workitems`

2) Error:
test_replay_error(StErrorsTest):
ActiveRecord::StatementInvalid:
ActiveRecord::ConnectionNotEstablished: no connection available:
DELETE FROM `ar_workitems`

Rake version is 0.8.7

It seems that it has something to do with ActiveRecord and that a
connection can't be established... but I was able to run ruote-rest
(create proccesses, update workitems, etc...) just fine with jruby
using 'jruby lib/start.rb' command :(


Is anyone facing the same issue? Thanks for the help.
Gonzalo.



*everything except for GET /history

John Mettraux

unread,
Jun 19, 2009, 6:22:48 PM6/19/09
to openwfe...@googlegroups.com
On Sat, Jun 20, 2009 at 1:09 AM, Gonzalo<gonzalo....@gmail.com> wrote:
>
> It seems that it has something to do with ActiveRecord and that a
> connection can't be established... but I was able to run ruote-rest
> (create proccesses, update workitems, etc...) just fine with jruby
> using 'jruby lib/start.rb' command :(
>
>
> Is anyone facing the same issue? Thanks for the help.

Hi Gonzalo,

yes, this issue has already been seen. A bit of searching and :

http://groups.google.com/group/openwferu-users/browse_frm/thread/4d7fcb0cab66e363
http://groups.google.com/group/openwferu-users/browse_frm/thread/a802c856569c05f8

It seems that modifying lib/openwfe/extras/singlecon.rb so that it becomes :

http://gist.github.com/132922

could help.

I haven't had time to look at this more and those discussion threads
went nowhere as my questions were not answered.

I'd be glad to help, best regards

--
John Mettraux - http://jmettraux.wordpress.com

Gonzalo

unread,
Jun 22, 2009, 3:53:32 AM6/22/09
to Ruote (OpenWFEru) users
Great!
I will give those threads a look and, whether I find something
interesting I'll let you know.

Regards,
Gonzalo.



On Jun 20, 12:22 am, John Mettraux <jmettr...@openwfe.org> wrote:
> On Sat, Jun 20, 2009 at 1:09 AM, Gonzalo<gonzalo.llore...@gmail.com> wrote:
>
> > It seems that it has something to do with ActiveRecord and that a
> > connection can't be established... but I was able to run ruote-rest
> > (create proccesses, update workitems, etc...) just fine with jruby
> > using 'jruby lib/start.rb' command :(
>
> > Is anyone facing the same issue? Thanks for the help.
>
> Hi Gonzalo,
>
> yes, this issue has already been seen. A bit of searching and :
>
>  http://groups.google.com/group/openwferu-users/browse_frm/thread/4d7f...
>  http://groups.google.com/group/openwferu-users/browse_frm/thread/a802...

Gonzalo

unread,
Jun 22, 2009, 12:55:25 PM6/22/09
to Ruote (OpenWFEru) users
Hi John,

I commented out the lines in 'vendor/ruote/lib/openwfe/extras/
singlecon.rb' as you suggested in the last post and most of the the
tests pass now with jruby1.3.0

Only, 'test/st_errors.rb' and 'test/st_expressions.rb' still fail
because XML problems I think... I'll try to find more on that and fix
it.


On the other hand, my co-worker Nando found an issue when requesting
"GET /history" (ruote-rest + jruby). It seems that using jdbcmysql
adapter makes SQL queries not to return a Mysql::Request object but a
simple Hash. When the method fetch_row is invoked on that Hash, an
error rises.

We came out with the following fix for that.
Edit 'lib/res/history.rb'

70 #total = ActiveRecord::Base::connection.execute(
71 # 'select count(*) from history').fetch_row[0].to_i
72
73 total = ActiveRecord::Base::connection.execute('select count(*)
from history')
74 total = total.respond_to?("fetch_row") ? total.fetch_row
[0].to_i : total.fetch(0).fetch("count(*)").to_i


Now the code above will work fine whether you run ruote-rest with ruby
or with jruby :)

Best regards.
Gonzalo.

John Mettraux

unread,
Jun 22, 2009, 8:40:30 PM6/22/09
to openwfe...@googlegroups.com
On Tue, Jun 23, 2009 at 1:55 AM, Gonzalo<gonzalo....@gmail.com> wrote:
>
> I commented out the lines in 'vendor/ruote/lib/openwfe/extras/
> singlecon.rb' as you suggested in the last post and most of the the
> tests pass now with jruby1.3.0
>
> Only, 'test/st_errors.rb' and 'test/st_expressions.rb' still fail
> because XML problems I think... I'll try to find more on that and fix
> it.

Hello Gonzalo,

OK, understood, waiting for your feedback.

> On the other hand, my co-worker Nando found an issue when requesting
> "GET /history" (ruote-rest + jruby). It seems that using jdbcmysql
> adapter makes SQL queries not to return a Mysql::Request object but a
> simple Hash. When the method fetch_row is invoked on that Hash, an
> error rises.
>
> We came out with the following fix for that.
> Edit 'lib/res/history.rb'
>
>  70  #total = ActiveRecord::Base::connection.execute(
>  71  #  'select count(*) from history').fetch_row[0].to_i
>  72
>  73  total = ActiveRecord::Base::connection.execute('select count(*)
> from history')
>  74  total = total.respond_to?("fetch_row") ? total.fetch_row
> [0].to_i : total.fetch(0).fetch("count(*)").to_i
>
> Now the code above will work fine whether you run ruote-rest with ruby
> or with jruby :)

So, would it be worth reporting the issue to the maintainers of the
jdbc-mysql bridge ?

On the other hand I took a closer look at the active-record
documentation and came up with that modification which happily works
with Ruby and JRuby :

http://github.com/jmettraux/ruote-rest/commit/b52b06c9b2214944c16bf292f460d1f8f429784e


Thanks a lot,

Gonzalo Suarez

unread,
Jun 23, 2009, 4:02:54 AM6/23/09
to openwfe...@googlegroups.com
Hi John,

Nice fix!

We will also report the jdbc-mysql adapter issue to the maintainers.

Thanks a lot.
Regards.

Gonzalo.





2009/6/23 John Mettraux <jmet...@openwfe.org>:

Gonzalo Suarez

unread,
Jun 24, 2009, 10:53:15 AM6/24/09
to openwfe...@googlegroups.com
Hi John,

I reported the issue with jdbcmysql-adapter to the jruby guys. Just
for our records:

http://jira.codehaus.org/browse/JRUBY-3772


Regards,
Gonzalo

Nando

unread,
Jun 24, 2009, 11:40:53 AM6/24/09
to Ruote (OpenWFEru) users
¡Hola!

Talking about JRuby bugs, it seems that the custom YAML encoders/
decoders at
"vendor/ruote/lib/openwfe/flowexpressionid.rb"

are still troublesome for JRuby 1.3.1 - I took the liberty of cloning
John's [JRUBY-801] issue, in hope that it's reopened:
http://jira.codehaus.org/browse/JRUBY-3773

Best,
//nando

John Mettraux

unread,
Jun 24, 2009, 8:14:07 PM6/24/09
to openwfe...@googlegroups.com

Hi Gonzalo and Nando,

many thanks for reporting those issues to the JRuby team.

Just as a side note, since Ruote 0.9.20, the default persistence mode
is via Marshal.dump (instead of YAML). It's way faster. The
disadvantage is that the marshal format [may] change[s] from one ruby
to the other (version/platform). I have added a tool (pooltool.ru) for
migration purposes (to/from marshal/yaml).

http://openwferu.rubyforge.org/persistence.html#pooltool


Best regards, keep up the great work,

Nando

unread,
Jun 25, 2009, 4:52:46 AM6/25/09
to Ruote (OpenWFEru) users


On Jun 25, 2:14 am, John Mettraux <jmettr...@openwfe.org> wrote:
>
> Just as a side note, since Ruote 0.9.20, the default persistence mode
> is via Marshal.dump (instead of YAML).

Yes, we are aware of that, and it has saved us lots of headaches. In
fact, I was supposed to report that strange "to_yaml" behavior as a
JRuby issue some months ago, but then I found yours [JRUBY-801].
However, we couldn't escape JRuby-Syck's quirks, since, for example
"GET /expressions/20090625-gishikozaja/0_0_0?format=yaml" still
renders broken YAML :-(

Just in case, I'll prepare a more complex test case to attach to my
report.


>
> Best regards, keep up the great work,

Always happy to help :-)

//nando

Li Xiao

unread,
Jun 27, 2009, 8:17:19 PM6/27/09
to Ruote (OpenWFEru) users
Hi Nando,

One JRuby YAML problem I got is it couldn't load Java objects from a
jruby yaml dump.
In this case, we couldn't use Marshal instead, because JRuby can't use
Marshal dump Java objects too.

(I also got same problem with yours, and changed to use Marshal dump/
load to fix it, when I created jruote)

Currently, my solution would be serialize Java object as byte array
and then convert it to string, and then put the string into attributes
of workitem, so that I could load it back later in Java.
Yes, JRuby also has problem with byte array, because it's a Java array
object, I didn't get right way to simply convert it into ruby array.
And the byte would be handle as java.lang.Long in jruby, so I think
it's better to convert into string.

John Mettraux

unread,
Jun 29, 2009, 4:27:00 AM6/29/09
to openwfe...@googlegroups.com
On Sun, Jun 28, 2009 at 9:17 AM, Li Xiao<swin...@gmail.com> wrote:
>
> Hi Nando,
>
> One JRuby YAML problem I got is it couldn't load Java objects from a
> jruby yaml dump.
> In this case, we couldn't use Marshal instead, because JRuby can't use
> Marshal dump Java objects too.
>
> (I also got same problem with yours, and changed to use Marshal dump/
> load to fix it, when I created jruote)
>
> Currently, my solution would be serialize Java object as byte array
> and then convert it to string, and then put the string into attributes
> of workitem, so that I could load it back later in Java.
> Yes, JRuby also has problem with byte array, because it's a Java array
> object, I didn't get right way to simply convert it into ruby array.
> And the byte would be handle as java.lang.Long in jruby, so I think
> it's better to convert into string.

Hi Li and Nando,

if you need any help on this one, please tell me.


Best regards,

Reply all
Reply to author
Forward
0 new messages