How to handle to run testcases in ruby code for solr

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

How to handle to run testcases in ruby code for solr

solr
Hi  all,
Am writing rails application by using solr_ruby gem to access solr .
Can anybody suggest how to handle testcaeses for solr code and connections in functionaltetsing.
Reply | Threaded
Open this post in threaded view
|

Re: How to handle to run testcases in ruby code for solr

Erik Hatcher-4
Just FYI.... the solr-ruby (hyphen, not underscore to be precise) is "deprecated" in that the source no longer lives under Apache's svn.  The gem is still out there, and it's still a useful library, but the Ruby/Solr world seems to use RSolr the most.  Both have their pros/cons, but solr-ruby works just fine as you'll see.   The source code for it was relocated to my personal github account for posterity: <https://github.com/erikhatcher/solr-ruby-flare>

All that being said, the solr-ruby library itself has extensive coverage with unit and functional tests.  For the functional side, you can see here <https://github.com/erikhatcher/solr-ruby-flare/blob/master/solr-ruby/test/functional/server_test.rb>   which ends up getting wrapped with a test Solr instance and leveraged in the :test Rake task here: <https://github.com/erikhatcher/solr-ruby-flare/blob/master/solr-ruby/Rakefile>

Hope that helps.

        Erik




On Feb 17, 2012, at 07:12 , solr wrote:

> Hi  all,
> Am writing rails application by using solr_ruby gem to access solr .
> Can anybody suggest how to handle testcaeses for solr code and connections
> in functionaltetsing.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/How-to-handle-to-run-testcases-in-ruby-code-for-solr-tp3753479p3753479.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: How to handle to run testcases in ruby code for solr

Paul-8
Are you asking how to test your own code, that happens to have a solr
query somewhere in the middle of it? I've done this two ways:

1) You can mock the solr call by detecting that you are in test mode
and just return the right answer. That will be fast.

2) Or you set up a second core with the name "test", and initialize it
for each test. That will give you confidence that your queries are
formed correctly.

Since your test data is generally really small, I've found that using
the second method performs well enough.

I use a global in my app that contains the name of the core, and I set
that in a before filter in application_controller depending whether
I'm in test mode or not.

As part of the test set up I delete all documents. The "delete *:*"
call is really fast. Then I commit a dozen documents or so. With that
little data that is fast, too.

I wrap all calls to solr in a single model so there is one point in my
app that calls rsolr. I can override that class to mock it out if the
solr result is not the focus of the test, and do the above work if the
solr result is the focus of the test.

>
> On Feb 17, 2012, at 07:12 , solr wrote:
>
>> Hi  all,
>> Am writing rails application by using solr_ruby gem to access solr .
>> Can anybody suggest how to handle testcaeses for solr code and connections
>> in functionaltetsing.
>>
Reply | Threaded
Open this post in threaded view
|

Re: How to handle to run testcases in ruby code for solr

solr
In reply to this post by Erik Hatcher-4
Hi Erik,
I have tried links which you given. while runnign rake
am getting error

======================================================================
Errno::ECONNREFUSED: No connection could be made because the target machine acti
vely refused it. - connect(2)
===================================================================
Reply | Threaded
Open this post in threaded view
|

Re: How to handle to run testcases in ruby code for solr

Erik Hatcher-4
I'm not sure what to suggest at this point... obviously your test setup is trying to hit a Solr server that isn't running.  Check the host and port that it is trying and ensure that Solr is running as your tests expect or use the mock way that I just replied about.

Note, again, that solr-ruby is deprecated and unsupported at this point.  I recommend you give the RSolr project a try if you want support with it in the future.

        Erik

On Feb 22, 2012, at 09:10 , solr wrote:

> Hi Erik,
> I have tried links which you given. while runnign rake
> am getting error
>
> ======================================================================
> Errno::ECONNREFUSED: No connection could be made because the target machine
> acti
> vely refused it. - connect(2)
> ===================================================================
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/How-to-handle-to-run-testcases-in-ruby-code-for-solr-tp3753479p3766559.html
> Sent from the Solr - User mailing list archive at Nabble.com.