You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Aristedes Maniatis <ar...@ish.com.au> on 2009/11/10 12:46:50 UTC
tests against other databases
When I run:
mvn test -Dcayenne.test.connection=h2
or
mvn test -Dcayenne.test.connection=derby
I don't think those other databases are being used for the tests. I always see this in the log output:
Nov 10, 2009 10:40:32 PM org.apache.cayenne.unit.CayenneResources setupTestDir
INFO: No property 'cayenne.test.dir' set. Using default directory: 'target/testrun'
Nov 10, 2009 10:40:32 PM org.apache.cayenne.unit.CayenneResources setConnectionKey
INFO: Invalid connection key 'h2', trying default: internal_embedded_datasource
Nov 10, 2009 10:40:32 PM org.apache.cayenne.unit.CayenneResources setConnectionKey
INFO: test connection info: [org.apache.cayenne.conn.DataSourceInfo:
user name: sa
password: **********
driver: org.hsqldb.jdbcDriver
db adapter class: org.apache.cayenne.dba.hsqldb.HSQLDBAdapter
url: jdbc:hsqldb:mem:aname
min. connections: 1
max. connections: 1
]
Is HSQLDB the only database which can run completely within maven in this way? Do all others, even the pure Java ones, require an external database to be already set up and connection.properties installed?
Ari
--
-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001 fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: tests against other databases
Posted by Ольга Ткачева <tk...@gmail.com>.
No, all DB can run completely within maven in this way
2009/11/10 Aristedes Maniatis <ar...@ish.com.au>
> When I run:
>
> mvn test -Dcayenne.test.connection=h2
>
> or
>
> mvn test -Dcayenne.test.connection=derby
>
>
> I don't think those other databases are being used for the tests. I always
> see this in the log output:
>
> Nov 10, 2009 10:40:32 PM org.apache.cayenne.unit.CayenneResources
> setupTestDir
> INFO: No property 'cayenne.test.dir' set. Using default directory:
> 'target/testrun'
> Nov 10, 2009 10:40:32 PM org.apache.cayenne.unit.CayenneResources
> setConnectionKey
> INFO: Invalid connection key 'h2', trying default:
> internal_embedded_datasource
> Nov 10, 2009 10:40:32 PM org.apache.cayenne.unit.CayenneResources
> setConnectionKey
> INFO: test connection info: [org.apache.cayenne.conn.DataSourceInfo:
> user name: sa
> password: **********
> driver: org.hsqldb.jdbcDriver
> db adapter class: org.apache.cayenne.dba.hsqldb.HSQLDBAdapter
> url: jdbc:hsqldb:mem:aname
> min. connections: 1
> max. connections: 1
> ]
>
>
> Is HSQLDB the only database which can run completely within maven in this
> way? Do all others, even the pure Java ones, require an external database to
> be already set up and connection.properties installed?
>
>
> Ari
>
>
>
>
> --
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001 fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
>
--
Olga
Re: tests against other databases
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Nov 12, 2009, at 9:53 AM, Andrus Adamchik wrote:
> On Nov 11, 2009, at 9:29 PM, Lachlan Deck wrote:
>
>> Sure, except Ari's question is about not hardcoding this path but
>> allowing maven to define it.
>
> Hmm.. How is that hardcoded? It is in a config file specific to each
> user.
>
> Andrus
Hudson example is the first time we actually run into a problem with a
user not being able to write in his own home dir. So yeah, having a
set of properties overriding connection info is a good idea. Not sure
we need to put that in Maven though. The code processing
connection.properties file can default to system properties as well.
Andrus
Re: tests against other databases
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Nov 11, 2009, at 9:29 PM, Lachlan Deck wrote:
> Sure, except Ari's question is about not hardcoding this path but
> allowing maven to define it.
Hmm.. How is that hardcoded? It is in a config file specific to each
user.
Andrus
Re: tests against other databases
Posted by Lachlan Deck <la...@gmail.com>.
On 11/11/2009, at 7:36 PM, Ольга Ткачева wrote:
> 2009/11/11 Aristedes Maniatis <ar...@maniatis.org>
>
>>
>> I'd never have guessed some of the above. Are you saying that the
>> file
>> needs to look *exactly* like the above, including the string
>> "path-to-hsql-db-files"?
>>
>>
> you can write instead string "path-to-hsql-db-files" any path, as
> example I
> write now this path as derby.jdbc.url =
> jdbc:derby:/home/olga/derbyFiles;create=true, it works.
Sure, except Ari's question is about not hardcoding this path but
allowing maven to define it. And so long as that file is under /src/
test/resources/... and filtering is enabled for test resources then
the answer is yes.
use something like:
jdbc:derby:${derby.dir} etc
in your pom profile put any relevant properties to be used when
filtering resource file(s).
<profile>
...
<properties>
<derby.dir>some.default.value</derby.dir>
...
</properties>
</profile>
or just use default properties like:
${project.build.directory} (i.e., path to target dir)
http://docs.codehaus.org/display/MAVENUSER/MavenPropertiesGuide
mvn .... -Dderby.dir=myCustomValueIfWantingNonDefault
with regards,
--
Lachlan Deck
Re: tests against other databases
Posted by Ольга Ткачева <tk...@gmail.com>.
2009/11/11 Aristedes Maniatis <ar...@maniatis.org>
>
> I'd never have guessed some of the above. Are you saying that the file
> needs to look *exactly* like the above, including the string
> "path-to-hsql-db-files"?
>
>
you can write instead string "path-to-hsql-db-files" any path, as example I
write now this path as derby.jdbc.url =
jdbc:derby:/home/olga/derbyFiles;create=true, it works.
--
Olga
Re: tests against other databases
Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 10/11/09 11:24 PM, Ольга Ткачева wrote:
> in connection.properties
>
> derby.adapter = org.apache.cayenne.dba.derby.DerbyAdapter
> derby.jdbc.username = username
> derby.jdbc.password = password
> derby.jdbc.url = jdbc:derby:path-to-hsql-db-files;create=true
> derby.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
>
> h2.cayenne.adapter = org.apache.cayenne.dba.h2.H2Adapter
> h2.jdbc.username = username
> h2.jdbc.password = password
> h2.jdbc.url = jdbc:h2:mem:myTestMem;MVCC=TRUE
> h2.jdbc.driver = org.h2.Driver
Thanks Olga,
I'd never have guessed some of the above. Are you saying that the file needs to look *exactly* like the above, including the string "path-to-hsql-db-files"?
Is it possible that we could commit this file into svn somewhere so that maven/junit will find it automatically when running the tests? The docs on the web site say that it can only live in ~/.cayenne.
Ari
--
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: tests against other databases
Posted by Ольга Ткачева <tk...@gmail.com>.
in connection.properties
derby.adapter = org.apache.cayenne.dba.derby.DerbyAdapter
derby.jdbc.username = username
derby.jdbc.password = password
derby.jdbc.url = jdbc:derby:path-to-hsql-db-files;create=true
derby.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
h2.cayenne.adapter = org.apache.cayenne.dba.h2.H2Adapter
h2.jdbc.username = username
h2.jdbc.password = password
h2.jdbc.url = jdbc:h2:mem:myTestMem;MVCC=TRUE
h2.jdbc.driver = org.h2.Driver
2009/11/10 Aristedes Maniatis <ar...@maniatis.org>
> On 10/11/09 11:11 PM, Andrus Adamchik wrote:
>
>>
>> On Nov 10, 2009, at 1:56 PM, Aristedes Maniatis wrote:
>>
>> On 10/11/09 10:52 PM, Andrus Adamchik wrote:
>>>
>>>> connection.properties entry is the minimal requirement
>>>>
>>>
>>> Can we avoid that file somehow so that it can run within Hudson since
>>> HSQLDB doesn't need it.
>>>
>>
>> For in-memory db's we can probably get rid of it, but not for other
>> DB's. So can you just create this file on the Hudson machine?
>>
>
> I could ask the Hudson admin guys, but I don't think I've got access to the
> hudson user's home directory. Alternatively we could set up our Cayenne zone
> as a Hudson slave and run everything there... that will work too, but is a
> bit of work to set up.
>
> We may need to do that anyway since infra aren't all that keen on
> installing a centralised db cluster.
>
> * Is it trivial to remove the need for the file for derby/h2? If so we can
> get those running now. The others still need co-operation from infra.
>
> * What would the file look like for those derby and h2 which are executed
> completely within maven? What user and pass? Is the URL pointing to
> localhost?
>
> Ari
>
>
>
> I'm not understanding why I'm seeing
>>>
>>> INFO: Invalid connection key 'h2', trying default:
>>> internal_embedded_datasource
>>>
>>> Is that due to the missing connection.properties file?
>>>
>>
>> Yes. For H2 DB of course, not HSQLDB that does not need this file.
>>
>> Andrus
>>
>
>
> --
>
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
>
--
Olga
Re: tests against other databases
Posted by Andrey Razumovsky <ra...@gmail.com>.
Maybe we just make a path to connection.properties an application parameter?
Then we could place it anywhere, like our Hudson directory (assume there is
one)
2009/11/10 Andrus Adamchik <an...@objectstyle.org>
>
> On Nov 10, 2009, at 2:19 PM, Aristedes Maniatis wrote:
>
>
>> * Is it trivial to remove the need for the file for derby/h2? If so we can
>> get those running now. The others still need co-operation from infra.
>>
>
> It should be fairly simple IIRC.
>
--
Andrey
Re: tests against other databases
Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 17/11/09 12:03 AM, Aristedes Maniatis wrote:
> On 10/11/09 11:43 PM, Andrus Adamchik wrote:
>>
>> On Nov 10, 2009, at 2:19 PM, Aristedes Maniatis wrote:
>>
>>>
>>> * Is it trivial to remove the need for the file for derby/h2? If so we
>>> can get those running now. The others still need co-operation from
>>> infra.
>>
>> It should be fairly simple IIRC.
>
>
> Andrus or Olga, if it is simple, would you be able to make the following
> changes:
>
> * rename 'cayenne.test.connection' to 'cayenneTestConnection' (Hudson
> chokes on the variables with dots since it executes some of the relevant
> scripts with Groovy).
> * absorb the connection dictionary variables into the default config so
> that we can run the tests against all Java dbs without needing any
> external file. Even Derby can run with a completely in-memory database.
>
> If it is a bit of work, point me in the right direction and I'll take a
> stab at it.
Replying to my own email since I've done a little digging. It seems to me that the ConnectionProperties class should go away entirely, or else get moved to the unit tests. It does not really seem to have a place in the Cayenne core library. Moving it to the test packages will make the above work trivial...
Any objections to getting rid of it?
Ari
--
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: tests against other databases
Posted by Ольга Ткачева <tk...@gmail.com>.
Ari, I working on this. Soon send the result.
2009/11/16 Aristedes Maniatis <ar...@maniatis.org>
> On 10/11/09 11:43 PM, Andrus Adamchik wrote:
>
>>
>> On Nov 10, 2009, at 2:19 PM, Aristedes Maniatis wrote:
>>
>>
>>> * Is it trivial to remove the need for the file for derby/h2? If so we
>>> can get those running now. The others still need co-operation from infra.
>>>
>>
>> It should be fairly simple IIRC.
>>
>
>
> Andrus or Olga, if it is simple, would you be able to make the following
> changes:
>
> * rename 'cayenne.test.connection' to 'cayenneTestConnection' (Hudson
> chokes on the variables with dots since it executes some of the relevant
> scripts with Groovy).
> * absorb the connection dictionary variables into the default config so
> that we can run the tests against all Java dbs without needing any external
> file. Even Derby can run with a completely in-memory database.
>
> If it is a bit of work, point me in the right direction and I'll take a
> stab at it.
>
>
> Cheers
> Ari
>
>
>
>
> --
>
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
>
--
Olga
Re: tests against other databases
Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 10/11/09 11:43 PM, Andrus Adamchik wrote:
>
> On Nov 10, 2009, at 2:19 PM, Aristedes Maniatis wrote:
>
>>
>> * Is it trivial to remove the need for the file for derby/h2? If so we
>> can get those running now. The others still need co-operation from infra.
>
> It should be fairly simple IIRC.
Andrus or Olga, if it is simple, would you be able to make the following changes:
* rename 'cayenne.test.connection' to 'cayenneTestConnection' (Hudson chokes on the variables with dots since it executes some of the relevant scripts with Groovy).
* absorb the connection dictionary variables into the default config so that we can run the tests against all Java dbs without needing any external file. Even Derby can run with a completely in-memory database.
If it is a bit of work, point me in the right direction and I'll take a stab at it.
Cheers
Ari
--
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: tests against other databases
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Nov 10, 2009, at 2:19 PM, Aristedes Maniatis wrote:
>
> * Is it trivial to remove the need for the file for derby/h2? If so
> we can get those running now. The others still need co-operation
> from infra.
It should be fairly simple IIRC.
Re: tests against other databases
Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 10/11/09 11:11 PM, Andrus Adamchik wrote:
>
> On Nov 10, 2009, at 1:56 PM, Aristedes Maniatis wrote:
>
>> On 10/11/09 10:52 PM, Andrus Adamchik wrote:
>>> connection.properties entry is the minimal requirement
>>
>> Can we avoid that file somehow so that it can run within Hudson since
>> HSQLDB doesn't need it.
>
> For in-memory db's we can probably get rid of it, but not for other
> DB's. So can you just create this file on the Hudson machine?
I could ask the Hudson admin guys, but I don't think I've got access to the hudson user's home directory. Alternatively we could set up our Cayenne zone as a Hudson slave and run everything there... that will work too, but is a bit of work to set up.
We may need to do that anyway since infra aren't all that keen on installing a centralised db cluster.
* Is it trivial to remove the need for the file for derby/h2? If so we can get those running now. The others still need co-operation from infra.
* What would the file look like for those derby and h2 which are executed completely within maven? What user and pass? Is the URL pointing to localhost?
Ari
>> I'm not understanding why I'm seeing
>>
>> INFO: Invalid connection key 'h2', trying default:
>> internal_embedded_datasource
>>
>> Is that due to the missing connection.properties file?
>
> Yes. For H2 DB of course, not HSQLDB that does not need this file.
>
> Andrus
--
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: tests against other databases
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Nov 10, 2009, at 1:56 PM, Aristedes Maniatis wrote:
> On 10/11/09 10:52 PM, Andrus Adamchik wrote:
>> connection.properties entry is the minimal requirement
>
> Can we avoid that file somehow so that it can run within Hudson
> since HSQLDB doesn't need it.
For in-memory db's we can probably get rid of it, but not for other
DB's. So can you just create this file on the Hudson machine?
> I'm not understanding why I'm seeing
>
> INFO: Invalid connection key 'h2', trying default:
> internal_embedded_datasource
>
> Is that due to the missing connection.properties file?
Yes. For H2 DB of course, not HSQLDB that does not need this file.
Andrus
Re: tests against other databases
Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 10/11/09 10:52 PM, Andrus Adamchik wrote:
> connection.properties entry is the minimal requirement
Can we avoid that file somehow so that it can run within Hudson since HSQLDB doesn't need it. I'm not understanding why I'm seeing
INFO: Invalid connection key 'h2', trying default: internal_embedded_datasource
Is that due to the missing connection.properties file?
I've set Hudson up to run all the combinations of databases we give it, just as soon as I solve this problem:
http://hudson.zones.apache.org/hudson/view/Cayenne/job/Cayenne-trunk/
Ari
--
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
Re: tests against other databases
Posted by Andrey Razumovsky <ra...@gmail.com>.
tried mysql run configuration I used before, I get same errors. Something
must've broken..
2009/11/10 Andrus Adamchik <an...@objectstyle.org>
>
> On Nov 10, 2009, at 1:46 PM, Aristedes Maniatis wrote:
>
> Is HSQLDB the only database which can run completely within maven in this
>> way? Do all others, even the pure Java ones, require an external database to
>> be already set up and connection.properties installed?
>>
>
> connection.properties entry is the minimal requirement. From there, Java
> in-memory DB's don't require a separate DB installation. Others do of
> course.
>
> Andrus
>
>
--
Andrey
Re: tests against other databases
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Nov 10, 2009, at 1:46 PM, Aristedes Maniatis wrote:
> Is HSQLDB the only database which can run completely within maven in
> this way? Do all others, even the pure Java ones, require an
> external database to be already set up and connection.properties
> installed?
connection.properties entry is the minimal requirement. From there,
Java in-memory DB's don't require a separate DB installation. Others
do of course.
Andrus