You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Yonik Seeley (JIRA)" <ji...@apache.org> on 2006/11/01 19:40:16 UTC

[jira] Created: (SOLR-62) scripts don't check return code

scripts don't check return code
-------------------------------

                 Key: SOLR-62
                 URL: http://issues.apache.org/jira/browse/SOLR-62
             Project: Solr
          Issue Type: Bug
          Components: replication
            Reporter: Yonik Seeley
            Priority: Minor


Solr scripts that post commands to solr don't check the return code.

The scripts (like optimize) currently follow this pattern:

rs=`curl http://localhost:5051/update -s -d "<optimize/>"`
if [[ $? != 0 ]]
then
  [...]
fi

# check status of optimize request
rc=`echo $rs|cut -f2 -d'"'`
if [[ $? != 0 ]]
then
  [...]

$rc is never checked.  In addition, the line that grabs rc appears pretty
fragile by depending on an exact field column.  Unless we have a simple command
line XML parser, how about checking for the return code this way:

echo $rs | grep '<response.*status="0"' > /dev/null 2>&1
if [[ $? != 0 ]]
then
  [...]

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Re: [jira] Created: (SOLR-62) scripts don't check return code

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Nov 1, 2006, at 3:19 PM, Mike Klaas wrote:
> On 11/1/06, Yonik Seeley (JIRA) <ji...@apache.org> wrote:
>
>> echo $rs | grep '<response.*status="0"' > /dev/null 2>&1
>> if [[ $? != 0 ]]
>> then
>>   [...]
>
> Looks good.
>
> Any thought on switching to a more powerful scripting language for
> these things?  Were this python, frinstance, a basic xml parser could
> be thrown together in a couple lines.  Python is also more
> cross-platform than bash scripting.

I'm personally interested in a Ruby Solr DSL (domain specific  
language) which would make this kind of stuff be API'ish instead of  
even having to deal with XML directly... maybe something like this:

	doc = SolrDoc.new
	doc.title = "foo"
	doc.text = "blah blah blah"

	Solr.post doc

Come on someone.... take this as a challenge and beat me to it :)

	Erik


Re: Re: [jira] Created: (SOLR-62) scripts don't check return code

Posted by Chris Hostetter <ho...@fucit.org>.
: It seems hard to not depend on _something_ which provides shell-like
: functionality, if not a shell itself.  I also suspect that java
: wouldn't be up to the task.

agreed, i'm just saying if we switch to python or ruby or whatever we
should try to keep the scripts simple (ie: no crazy library dependencies)

: > is it something that can be done natively in python?
:
: os.link(src, dest)

coolio.



-Hoss


Re: Re: [jira] Created: (SOLR-62) scripts don't check return code

Posted by Mike Klaas <mi...@gmail.com>.
On 11/1/06, Chris Hostetter <ho...@fucit.org> wrote:

> I have no strong opinion about what language they be implimented in ..
> ideally it would be nice if they could be done in java so there were no
> additional dependencies (ie: bash or python) ... but i'm not sure if
> making hardlinks in java is really feasible.

It seems hard to not depend on _something_ which provides shell-like
functionality, if not a shell itself.  I also suspect that java
wouldn't be up to the task.

The nice thing about using python (or some other cross-platform
scripting language) is that it abstracts away platform details.
os.path.join('a', 'b') -> 'a/b' on linux and 'a\b' on windows.

> is it something that can be done natively in python?

os.link(src, dest)

regards,
-Mike

Re: [jira] Created: (SOLR-62) scripts don't check return code

Posted by Yonik Seeley <yo...@apache.org>.
While I'm definitely for Solr interfaces in different languages, I'd
wouldn't want to add a Python or Ruby dependency just to get
distribution working.

-Yonik

Re: [jira] Created: (SOLR-62) scripts don't check return code

Posted by Chris Hostetter <ho...@fucit.org>.
: Any thought on switching to a more powerful scripting language for
: these things?  Were this python, frinstance, a basic xml parser could
: be thrown together in a couple lines.  Python is also more
: cross-platform than bash scripting.

I have no strong opinion about what language they be implimented in ..
ideally it would be nice if they could be done in java so there were no
additional dependencies (ie: bash or python) ... but i'm not sure if
making hardlinks in java is really feasible.

is it something that can be done natively in python?


-Hoss


Re: [jira] Created: (SOLR-62) scripts don't check return code

Posted by Mike Klaas <mi...@gmail.com>.
On 11/1/06, Yonik Seeley (JIRA) <ji...@apache.org> wrote:

> echo $rs | grep '<response.*status="0"' > /dev/null 2>&1
> if [[ $? != 0 ]]
> then
>   [...]

Looks good.

Any thought on switching to a more powerful scripting language for
these things?  Were this python, frinstance, a basic xml parser could
be thrown together in a couple lines.  Python is also more
cross-platform than bash scripting.

-Mike

[jira] Updated: (SOLR-62) scripts don't check return code

Posted by "Bill Au (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/SOLR-62?page=all ]

Bill Au updated SOLR-62:
------------------------

    Attachment: solr-scripts-solr-62.patch

Attached patch for proposed solution.
Note that the XML response of the commit and optimize is a little different from that of a query:

<result status="0"></result>

> scripts don't check return code
> -------------------------------
>
>                 Key: SOLR-62
>                 URL: http://issues.apache.org/jira/browse/SOLR-62
>             Project: Solr
>          Issue Type: Bug
>          Components: replication
>            Reporter: Yonik Seeley
>            Priority: Minor
>         Attachments: solr-scripts-solr-62.patch
>
>
> Solr scripts that post commands to solr don't check the return code.
> The scripts (like optimize) currently follow this pattern:
> rs=`curl http://localhost:5051/update -s -d "<optimize/>"`
> if [[ $? != 0 ]]
> then
>   [...]
> fi
> # check status of optimize request
> rc=`echo $rs|cut -f2 -d'"'`
> if [[ $? != 0 ]]
> then
>   [...]
> $rc is never checked.  In addition, the line that grabs rc appears pretty
> fragile by depending on an exact field column.  Unless we have a simple command
> line XML parser, how about checking for the return code this way:
> echo $rs | grep '<response.*status="0"' > /dev/null 2>&1
> if [[ $? != 0 ]]
> then
>   [...]

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (SOLR-62) scripts don't check return code

Posted by "Bill Au (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/SOLR-62?page=all ]

Bill Au resolved SOLR-62.
-------------------------

    Resolution: Fixed

patch committed.

> scripts don't check return code
> -------------------------------
>
>                 Key: SOLR-62
>                 URL: http://issues.apache.org/jira/browse/SOLR-62
>             Project: Solr
>          Issue Type: Bug
>          Components: replication
>            Reporter: Yonik Seeley
>            Priority: Minor
>         Attachments: solr-scripts-solr-62.patch
>
>
> Solr scripts that post commands to solr don't check the return code.
> The scripts (like optimize) currently follow this pattern:
> rs=`curl http://localhost:5051/update -s -d "<optimize/>"`
> if [[ $? != 0 ]]
> then
>   [...]
> fi
> # check status of optimize request
> rc=`echo $rs|cut -f2 -d'"'`
> if [[ $? != 0 ]]
> then
>   [...]
> $rc is never checked.  In addition, the line that grabs rc appears pretty
> fragile by depending on an exact field column.  Unless we have a simple command
> line XML parser, how about checking for the return code this way:
> echo $rs | grep '<response.*status="0"' > /dev/null 2>&1
> if [[ $? != 0 ]]
> then
>   [...]

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira