You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by siddharth srivastava <ak...@gmail.com> on 2011/02/11 19:49:42 UTC

Regarding Store Test

Hi

I am planning to work on store JUnit conversions. But I am not very much
familiar with it. Some pointers to it and related SQL Conversions would be
helpful.
Probably its a vague question, but at the moment I am unsure of how it works
exactly and don't want to be speculating things.

Thanks
-- 
Regards
Siddharth Srivastava

Re: Regarding Store Test

Posted by Myrna van Lunteren <m....@gmail.com>.
On Sat, Feb 12, 2011 at 8:03 PM, Dag H. Wanvik <da...@oracle.com> wrote:
> Tiago Espinha <ti...@espinhas.net> writes:
>
>> I remember something like this as well but I also seem to remember that
>> there was something "wrong" with it. If I'm not mistaken, it just throws the
>> whole SQL script into one big JUnit fixture and then even if the work is
>> greatly reduced, there's still an awful lot of work that has to be done
>> manually.
>
> You are right about the fact that it puts stuff into one big JUnit
> fixture. I used the converter though a while ago and it saved me a lot
> of work, although I had to tweak it a lot after conversion
> (OuterJoinTest, 3500 lines, DERBY-4471) with some creative Emacs
> macros...
>
>> Personally I find that running the SQL file against the output file within a
>> JUnit test is acceptable.. the test functionality is maintained and the test
>> is converted into JUnit, so I'm not sure there are any significant drawbacks
>> about it.
>
> I think part of the reason why we converted to JUnit was to make the
> test assertion based. I am not sure, but I think ScriptTestCase was made
> to accelerate the move away from the old test harness, not because we
> wanted to continue using script output based comparisons which are more
> brittle. Your call, either way, conversion to JUnit is good.
>
> Thanks,
> Dag
>
>
>>
>> Tiago
>>
>> On Sat, Feb 12, 2011 at 5:11 PM, Bryan Pendleton <bpendleton.derby@gmail.com
>>> wrote:
>>
>>> \> As you'll be able to see on that
>>>
>>>  page, SQL tests can be converted by either running the current SQL file as
>>>> part of a test that extends from the
>>>> util.ScriptTestCase or... alternatively... you can convert the test by
>>>> hand with JDBC calls that execute the SQL commands.
>>>>
>>>
>>> Isn't there still a tool that performs the conversion
>>> from SQL script to JDBC test case automatically? You
>>> still have to process the results by hand, but I recall
>>> that the tool does an enormous amount of the heavy lifting
>>> for you.
>>>
>>> I think it's called:
>>>
>>>  org.apache.derbyTesting.functionTests.util.SQLToJUnit
>>>
>>> thanks,
>>>
>>> bryan
>>>
>

My 2 c:
The SQLToJUnit is indeed a first step for converting .sql scripts to
junit - and you'll need to do a lot of massaging. And of course it
does nothing for tests that are already jave programs.

We really wanted to go towards 'pure' junit conversions unless we want
to test specific ij commands - which would mostly apply to tests in
the 'tools' area.
The scripttests were originally mostly a way to get more tests
converted quicker.
The trouble with the scripttests is that they're still master based,
and the trouble with master based is that it's more sensitive to
variations and so harder to maintain/control. (For instance, the
behavior between network server and embedded runs might be different,
or the behavior on different operating systems, or the behavior with
different versions of the jvm.)

Myrna

Re: Regarding Store Test

Posted by "Dag H. Wanvik" <da...@oracle.com>.
Tiago Espinha <ti...@espinhas.net> writes:

> I remember something like this as well but I also seem to remember that
> there was something "wrong" with it. If I'm not mistaken, it just throws the
> whole SQL script into one big JUnit fixture and then even if the work is
> greatly reduced, there's still an awful lot of work that has to be done
> manually.

You are right about the fact that it puts stuff into one big JUnit
fixture. I used the converter though a while ago and it saved me a lot
of work, although I had to tweak it a lot after conversion
(OuterJoinTest, 3500 lines, DERBY-4471) with some creative Emacs
macros...

> Personally I find that running the SQL file against the output file within a
> JUnit test is acceptable.. the test functionality is maintained and the test
> is converted into JUnit, so I'm not sure there are any significant drawbacks
> about it.

I think part of the reason why we converted to JUnit was to make the
test assertion based. I am not sure, but I think ScriptTestCase was made
to accelerate the move away from the old test harness, not because we
wanted to continue using script output based comparisons which are more
brittle. Your call, either way, conversion to JUnit is good.

Thanks,
Dag


>
> Tiago
>
> On Sat, Feb 12, 2011 at 5:11 PM, Bryan Pendleton <bpendleton.derby@gmail.com
>> wrote:
>
>> \> As you'll be able to see on that
>>
>>  page, SQL tests can be converted by either running the current SQL file as
>>> part of a test that extends from the
>>> util.ScriptTestCase or... alternatively... you can convert the test by
>>> hand with JDBC calls that execute the SQL commands.
>>>
>>
>> Isn't there still a tool that performs the conversion
>> from SQL script to JDBC test case automatically? You
>> still have to process the results by hand, but I recall
>> that the tool does an enormous amount of the heavy lifting
>> for you.
>>
>> I think it's called:
>>
>>  org.apache.derbyTesting.functionTests.util.SQLToJUnit
>>
>> thanks,
>>
>> bryan
>>

Re: Regarding Store Test

Posted by Tiago Espinha <ti...@espinhas.net>.
I remember something like this as well but I also seem to remember that
there was something "wrong" with it. If I'm not mistaken, it just throws the
whole SQL script into one big JUnit fixture and then even if the work is
greatly reduced, there's still an awful lot of work that has to be done
manually.

Personally I find that running the SQL file against the output file within a
JUnit test is acceptable.. the test functionality is maintained and the test
is converted into JUnit, so I'm not sure there are any significant drawbacks
about it.

Tiago

On Sat, Feb 12, 2011 at 5:11 PM, Bryan Pendleton <bpendleton.derby@gmail.com
> wrote:

> \> As you'll be able to see on that
>
>  page, SQL tests can be converted by either running the current SQL file as
>> part of a test that extends from the
>> util.ScriptTestCase or... alternatively... you can convert the test by
>> hand with JDBC calls that execute the SQL commands.
>>
>
> Isn't there still a tool that performs the conversion
> from SQL script to JDBC test case automatically? You
> still have to process the results by hand, but I recall
> that the tool does an enormous amount of the heavy lifting
> for you.
>
> I think it's called:
>
>  org.apache.derbyTesting.functionTests.util.SQLToJUnit
>
> thanks,
>
> bryan
>

Re: Regarding Store Test

Posted by Bryan Pendleton <bp...@gmail.com>.
\> As you'll be able to see on that
> page, SQL tests can be converted by either running the current SQL file as part of a test that extends from the
> util.ScriptTestCase or... alternatively... you can convert the test by hand with JDBC calls that execute the SQL commands.

Isn't there still a tool that performs the conversion
from SQL script to JDBC test case automatically? You
still have to process the results by hand, but I recall
that the tool does an enormous amount of the heavy lifting
for you.

I think it's called:

   org.apache.derbyTesting.functionTests.util.SQLToJUnit

thanks,

bryan

Re: Regarding Store Test

Posted by Tiago Espinha <ti...@espinhas.net>.
Hi Siddharth,

We have some documentation on the wiki on how to get started, so maybe you
want to check that first as it will contain most of the information that you
need.

This page is the general overview on the effort being done to "kill" the
harness tests (the old framework that is still lurking on Derby, like I told
you previously on IRC) and convert them into JUnit tests:
http://wiki.apache.org/db-derby/KillDerbyTestHarness?highlight=(conversions)|(sql)#SQL_tests

<http://wiki.apache.org/db-derby/KillDerbyTestHarness?highlight=(conversions)|(sql)#SQL_tests>As
you'll be able to see on that page, SQL tests can be converted by either
running the current SQL file as part of a test that extends from the
util.ScriptTestCase or... alternatively... you can convert the test by hand
with JDBC calls that execute the SQL commands.

The second option might be very time consuming if the SQL file is large, so
in my opinion you can stick to extending tests from the util.ScriptTestCase
class. I'm not at my computer right now so my access is a bit limited, but
it helps quite a lot to look at tests that have been previously converted
using this method. You can perhaps on Eclipse find classes that extend
ScriptTestCase? Then you'll have a good idea of how things work.

Hope it helps,
Tiago

On Fri, Feb 11, 2011 at 7:49 PM, siddharth srivastava
<ak...@gmail.com>wrote:

> Hi
>
> I am planning to work on store JUnit conversions. But I am not very much
> familiar with it. Some pointers to it and related SQL Conversions would be
> helpful.
> Probably its a vague question, but at the moment I am unsure of how it
> works exactly and don't want to be speculating things.
>
> Thanks
> --
> Regards
> Siddharth Srivastava
>
>
>

Re: Regarding Store Test

Posted by Mike Matrigali <mi...@sbcglobal.net>.
I am sure some others more experienced with test conversions will give 
you pointers.  I would suggest starting with store/madhare.sql as it is
the simplest (it's history is I think it was the first sql level test
that ran against the original project when it was written from scratch - 
and tested a limited set of functionality at that time) and should make 
it a good 1st test to learn the junit and
conversion side of the project.  I will look at tests later to suggest
the next set of tests.

Some of the store tests are written such that they must be run one after
the other, which should not be an issue as long as you know it for the
conversion.

Others depend on the server shutting down and then restarting for the
next test.  I believe Kathy Marsden has a solution for this also.


siddharth srivastava wrote:
> Hi
> 
> I am planning to work on store JUnit conversions. But I am not very much 
> familiar with it. Some pointers to it and related SQL Conversions would 
> be helpful. 
> Probably its a vague question, but at the moment I am unsure of how it 
> works exactly and don't want to be speculating things.
> 
> Thanks
> -- 
> Regards
> Siddharth Srivastava
> 
>