You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2024/11/28 09:08:53 UTC
(tomcat) branch main updated: Avoid conflicts over derby.log when tests are run in parallel
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 5970fa4b6c Avoid conflicts over derby.log when tests are run in parallel
5970fa4b6c is described below
commit 5970fa4b6cc89e1d4a8c3b0ddf1c718f5b495099
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Nov 28 09:08:38 2024 +0000
Avoid conflicts over derby.log when tests are run in parallel
---
test/org/apache/catalina/realm/TestDataSourceRealm.java | 7 -------
test/org/apache/catalina/startup/LoggingBaseTest.java | 1 +
test/org/apache/catalina/users/TestDataSourceUserDatabase.java | 7 -------
3 files changed, 1 insertion(+), 14 deletions(-)
diff --git a/test/org/apache/catalina/realm/TestDataSourceRealm.java b/test/org/apache/catalina/realm/TestDataSourceRealm.java
index 57486a54c9..bdd1af6972 100644
--- a/test/org/apache/catalina/realm/TestDataSourceRealm.java
+++ b/test/org/apache/catalina/realm/TestDataSourceRealm.java
@@ -16,7 +16,6 @@
*/
package org.apache.catalina.realm;
-import java.io.File;
import java.security.Principal;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -24,7 +23,6 @@ import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.List;
-import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
@@ -87,11 +85,6 @@ public class TestDataSourceRealm extends LoggingBaseTest {
private DerbyDataSourceRealm db;
- @AfterClass
- public static void derbyCleanup() {
- System.out.println("Deleted derby.log: " + (new File("derby.log")).delete());
- }
-
@Test
public void testRealm() throws Exception {
diff --git a/test/org/apache/catalina/startup/LoggingBaseTest.java b/test/org/apache/catalina/startup/LoggingBaseTest.java
index 200978c92f..8a96e41436 100644
--- a/test/org/apache/catalina/startup/LoggingBaseTest.java
+++ b/test/org/apache/catalina/startup/LoggingBaseTest.java
@@ -115,6 +115,7 @@ public abstract class LoggingBaseTest {
tempDir = Files.createTempDirectory(tempBasePath, "test").toFile();
System.setProperty(Constants.CATALINA_BASE_PROP, tempDir.getAbsolutePath());
+ System.setProperty("derby.system.home", tempDir.getAbsolutePath());
// Configure logging
System.setProperty("java.util.logging.manager",
diff --git a/test/org/apache/catalina/users/TestDataSourceUserDatabase.java b/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
index 56e5458472..c331cb353d 100644
--- a/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
+++ b/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
@@ -16,13 +16,11 @@
*/
package org.apache.catalina.users;
-import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Iterator;
-import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
@@ -111,11 +109,6 @@ public class TestDataSourceUserDatabase extends LoggingBaseTest {
private DerbyUserDatabase db;
- @AfterClass
- public static void derbyCleanup() {
- System.out.println("Deleted derby.log: " + (new File("derby.log")).delete());
- }
-
@Test
public void testBasicUserRoleDatabase()
throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) branch main updated: Avoid conflicts over derby.log when tests are run in parallel
Posted by Mark Thomas <ma...@apache.org>.
On 28/11/2024 11:47, Rémy Maucherat wrote:
> On Thu, Nov 28, 2024 at 11:06 AM Mark Thomas <ma...@apache.org> wrote:
>>
>> On 28/11/2024 09:22, Rémy Maucherat wrote:
>>> On Thu, Nov 28, 2024 at 10:11 AM <ma...@apache.org> wrote:
>>>>
>>>> This is an automated email from the ASF dual-hosted git repository.
>>>>
>>>> markt pushed a commit to branch main
>>>> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>>>>
>>>>
>>>> The following commit(s) were added to refs/heads/main by this push:
>>>> new 5970fa4b6c Avoid conflicts over derby.log when tests are run in parallel
>>>> 5970fa4b6c is described below
>>>
>>> Thanks for finding the proper way to do it.
>>
>> I appreciate the thanks but it felt a bit of a hack. I'd rather have set
>> the system property just in the tests that used Derby but that would
>> have required more invasive changes to expose the temporary directory
>> via a static rather than instance method.
>>
>> Maybe I should do that refactoring. We don't need to worry about
>> backwards compatibility for the API for the tests.
>
> It looked good enough to me.
Ok.
> Since Derby is now nice for testing, I was thinking about more tests
> (and possibly more DB features included since things are better
> tested). For example the DataSourceStore, and so on.
Sounds good.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) branch main updated: Avoid conflicts over derby.log when tests are run in parallel
Posted by Rémy Maucherat <re...@apache.org>.
On Thu, Nov 28, 2024 at 11:06 AM Mark Thomas <ma...@apache.org> wrote:
>
> On 28/11/2024 09:22, Rémy Maucherat wrote:
> > On Thu, Nov 28, 2024 at 10:11 AM <ma...@apache.org> wrote:
> >>
> >> This is an automated email from the ASF dual-hosted git repository.
> >>
> >> markt pushed a commit to branch main
> >> in repository https://gitbox.apache.org/repos/asf/tomcat.git
> >>
> >>
> >> The following commit(s) were added to refs/heads/main by this push:
> >> new 5970fa4b6c Avoid conflicts over derby.log when tests are run in parallel
> >> 5970fa4b6c is described below
> >
> > Thanks for finding the proper way to do it.
>
> I appreciate the thanks but it felt a bit of a hack. I'd rather have set
> the system property just in the tests that used Derby but that would
> have required more invasive changes to expose the temporary directory
> via a static rather than instance method.
>
> Maybe I should do that refactoring. We don't need to worry about
> backwards compatibility for the API for the tests.
It looked good enough to me.
Since Derby is now nice for testing, I was thinking about more tests
(and possibly more DB features included since things are better
tested). For example the DataSourceStore, and so on.
Rémy
> Mark
>
> >
> > Rémy
> >
> >> commit 5970fa4b6cc89e1d4a8c3b0ddf1c718f5b495099
> >> Author: Mark Thomas <ma...@apache.org>
> >> AuthorDate: Thu Nov 28 09:08:38 2024 +0000
> >>
> >> Avoid conflicts over derby.log when tests are run in parallel
> >> ---
> >> test/org/apache/catalina/realm/TestDataSourceRealm.java | 7 -------
> >> test/org/apache/catalina/startup/LoggingBaseTest.java | 1 +
> >> test/org/apache/catalina/users/TestDataSourceUserDatabase.java | 7 -------
> >> 3 files changed, 1 insertion(+), 14 deletions(-)
> >>
> >> diff --git a/test/org/apache/catalina/realm/TestDataSourceRealm.java b/test/org/apache/catalina/realm/TestDataSourceRealm.java
> >> index 57486a54c9..bdd1af6972 100644
> >> --- a/test/org/apache/catalina/realm/TestDataSourceRealm.java
> >> +++ b/test/org/apache/catalina/realm/TestDataSourceRealm.java
> >> @@ -16,7 +16,6 @@
> >> */
> >> package org.apache.catalina.realm;
> >>
> >> -import java.io.File;
> >> import java.security.Principal;
> >> import java.sql.Connection;
> >> import java.sql.DriverManager;
> >> @@ -24,7 +23,6 @@ import java.sql.PreparedStatement;
> >> import java.sql.Statement;
> >> import java.util.List;
> >>
> >> -import org.junit.AfterClass;
> >> import org.junit.Assert;
> >> import org.junit.Test;
> >>
> >> @@ -87,11 +85,6 @@ public class TestDataSourceRealm extends LoggingBaseTest {
> >>
> >> private DerbyDataSourceRealm db;
> >>
> >> - @AfterClass
> >> - public static void derbyCleanup() {
> >> - System.out.println("Deleted derby.log: " + (new File("derby.log")).delete());
> >> - }
> >> -
> >> @Test
> >> public void testRealm() throws Exception {
> >>
> >> diff --git a/test/org/apache/catalina/startup/LoggingBaseTest.java b/test/org/apache/catalina/startup/LoggingBaseTest.java
> >> index 200978c92f..8a96e41436 100644
> >> --- a/test/org/apache/catalina/startup/LoggingBaseTest.java
> >> +++ b/test/org/apache/catalina/startup/LoggingBaseTest.java
> >> @@ -115,6 +115,7 @@ public abstract class LoggingBaseTest {
> >> tempDir = Files.createTempDirectory(tempBasePath, "test").toFile();
> >>
> >> System.setProperty(Constants.CATALINA_BASE_PROP, tempDir.getAbsolutePath());
> >> + System.setProperty("derby.system.home", tempDir.getAbsolutePath());
> >>
> >> // Configure logging
> >> System.setProperty("java.util.logging.manager",
> >> diff --git a/test/org/apache/catalina/users/TestDataSourceUserDatabase.java b/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
> >> index 56e5458472..c331cb353d 100644
> >> --- a/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
> >> +++ b/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
> >> @@ -16,13 +16,11 @@
> >> */
> >> package org.apache.catalina.users;
> >>
> >> -import java.io.File;
> >> import java.sql.Connection;
> >> import java.sql.DriverManager;
> >> import java.sql.Statement;
> >> import java.util.Iterator;
> >>
> >> -import org.junit.AfterClass;
> >> import org.junit.Assert;
> >> import org.junit.Test;
> >>
> >> @@ -111,11 +109,6 @@ public class TestDataSourceUserDatabase extends LoggingBaseTest {
> >>
> >> private DerbyUserDatabase db;
> >>
> >> - @AfterClass
> >> - public static void derbyCleanup() {
> >> - System.out.println("Deleted derby.log: " + (new File("derby.log")).delete());
> >> - }
> >> -
> >> @Test
> >> public void testBasicUserRoleDatabase()
> >> throws Exception {
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: dev-help@tomcat.apache.org
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: dev-help@tomcat.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) branch main updated: Avoid conflicts over derby.log when tests are run in parallel
Posted by Konstantin Kolinko <kn...@gmail.com>.
чт, 28 нояб. 2024 г. в 13:06, Mark Thomas <ma...@apache.org>:
>
> On 28/11/2024 09:22, Rémy Maucherat wrote:
> > On Thu, Nov 28, 2024 at 10:11 AM <ma...@apache.org> wrote:
> >>
> >> This is an automated email from the ASF dual-hosted git repository.
> >>
> >> markt pushed a commit to branch main
> >> in repository https://gitbox.apache.org/repos/asf/tomcat.git
> >>
> >>
> >> The following commit(s) were added to refs/heads/main by this push:
> >> new 5970fa4b6c Avoid conflicts over derby.log when tests are run in parallel
> >> 5970fa4b6c is described below
> >
> > Thanks for finding the proper way to do it.
>
> I appreciate the thanks but it felt a bit of a hack. I'd rather have set
> the system property just in the tests that used Derby but that would
> have required more invasive changes to expose the temporary directory
> via a static rather than instance method.
>
> Maybe I should do that refactoring. We don't need to worry about
> backwards compatibility for the API for the tests.
> >> @@ -115,6 +115,7 @@ public abstract class LoggingBaseTest {
> >> tempDir = Files.createTempDirectory(tempBasePath, "test").toFile();
> >>
> >> System.setProperty(Constants.CATALINA_BASE_PROP, tempDir.getAbsolutePath());
> >> + System.setProperty("derby.system.home", tempDir.getAbsolutePath());
When tests run in parallel, I wonder whether they run in the same JVM
or in different JVMs. If it is the same JVM then there is a race, as
tempDir will be different for different tests, but both above
properties will be shared.
Regarding refactoring,
as we now have a minimum of Java 8 it might be interesting to update
to JUnit 5 and think of refactoring from there.
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) branch main updated: Avoid conflicts over derby.log when tests are run in parallel
Posted by Mark Thomas <ma...@apache.org>.
On 28/11/2024 09:22, Rémy Maucherat wrote:
> On Thu, Nov 28, 2024 at 10:11 AM <ma...@apache.org> wrote:
>>
>> This is an automated email from the ASF dual-hosted git repository.
>>
>> markt pushed a commit to branch main
>> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>>
>>
>> The following commit(s) were added to refs/heads/main by this push:
>> new 5970fa4b6c Avoid conflicts over derby.log when tests are run in parallel
>> 5970fa4b6c is described below
>
> Thanks for finding the proper way to do it.
I appreciate the thanks but it felt a bit of a hack. I'd rather have set
the system property just in the tests that used Derby but that would
have required more invasive changes to expose the temporary directory
via a static rather than instance method.
Maybe I should do that refactoring. We don't need to worry about
backwards compatibility for the API for the tests.
Mark
>
> Rémy
>
>> commit 5970fa4b6cc89e1d4a8c3b0ddf1c718f5b495099
>> Author: Mark Thomas <ma...@apache.org>
>> AuthorDate: Thu Nov 28 09:08:38 2024 +0000
>>
>> Avoid conflicts over derby.log when tests are run in parallel
>> ---
>> test/org/apache/catalina/realm/TestDataSourceRealm.java | 7 -------
>> test/org/apache/catalina/startup/LoggingBaseTest.java | 1 +
>> test/org/apache/catalina/users/TestDataSourceUserDatabase.java | 7 -------
>> 3 files changed, 1 insertion(+), 14 deletions(-)
>>
>> diff --git a/test/org/apache/catalina/realm/TestDataSourceRealm.java b/test/org/apache/catalina/realm/TestDataSourceRealm.java
>> index 57486a54c9..bdd1af6972 100644
>> --- a/test/org/apache/catalina/realm/TestDataSourceRealm.java
>> +++ b/test/org/apache/catalina/realm/TestDataSourceRealm.java
>> @@ -16,7 +16,6 @@
>> */
>> package org.apache.catalina.realm;
>>
>> -import java.io.File;
>> import java.security.Principal;
>> import java.sql.Connection;
>> import java.sql.DriverManager;
>> @@ -24,7 +23,6 @@ import java.sql.PreparedStatement;
>> import java.sql.Statement;
>> import java.util.List;
>>
>> -import org.junit.AfterClass;
>> import org.junit.Assert;
>> import org.junit.Test;
>>
>> @@ -87,11 +85,6 @@ public class TestDataSourceRealm extends LoggingBaseTest {
>>
>> private DerbyDataSourceRealm db;
>>
>> - @AfterClass
>> - public static void derbyCleanup() {
>> - System.out.println("Deleted derby.log: " + (new File("derby.log")).delete());
>> - }
>> -
>> @Test
>> public void testRealm() throws Exception {
>>
>> diff --git a/test/org/apache/catalina/startup/LoggingBaseTest.java b/test/org/apache/catalina/startup/LoggingBaseTest.java
>> index 200978c92f..8a96e41436 100644
>> --- a/test/org/apache/catalina/startup/LoggingBaseTest.java
>> +++ b/test/org/apache/catalina/startup/LoggingBaseTest.java
>> @@ -115,6 +115,7 @@ public abstract class LoggingBaseTest {
>> tempDir = Files.createTempDirectory(tempBasePath, "test").toFile();
>>
>> System.setProperty(Constants.CATALINA_BASE_PROP, tempDir.getAbsolutePath());
>> + System.setProperty("derby.system.home", tempDir.getAbsolutePath());
>>
>> // Configure logging
>> System.setProperty("java.util.logging.manager",
>> diff --git a/test/org/apache/catalina/users/TestDataSourceUserDatabase.java b/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
>> index 56e5458472..c331cb353d 100644
>> --- a/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
>> +++ b/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
>> @@ -16,13 +16,11 @@
>> */
>> package org.apache.catalina.users;
>>
>> -import java.io.File;
>> import java.sql.Connection;
>> import java.sql.DriverManager;
>> import java.sql.Statement;
>> import java.util.Iterator;
>>
>> -import org.junit.AfterClass;
>> import org.junit.Assert;
>> import org.junit.Test;
>>
>> @@ -111,11 +109,6 @@ public class TestDataSourceUserDatabase extends LoggingBaseTest {
>>
>> private DerbyUserDatabase db;
>>
>> - @AfterClass
>> - public static void derbyCleanup() {
>> - System.out.println("Deleted derby.log: " + (new File("derby.log")).delete());
>> - }
>> -
>> @Test
>> public void testBasicUserRoleDatabase()
>> throws Exception {
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: (tomcat) branch main updated: Avoid conflicts over derby.log when tests are run in parallel
Posted by Rémy Maucherat <re...@apache.org>.
On Thu, Nov 28, 2024 at 10:11 AM <ma...@apache.org> wrote:
>
> This is an automated email from the ASF dual-hosted git repository.
>
> markt pushed a commit to branch main
> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>
>
> The following commit(s) were added to refs/heads/main by this push:
> new 5970fa4b6c Avoid conflicts over derby.log when tests are run in parallel
> 5970fa4b6c is described below
Thanks for finding the proper way to do it.
Rémy
> commit 5970fa4b6cc89e1d4a8c3b0ddf1c718f5b495099
> Author: Mark Thomas <ma...@apache.org>
> AuthorDate: Thu Nov 28 09:08:38 2024 +0000
>
> Avoid conflicts over derby.log when tests are run in parallel
> ---
> test/org/apache/catalina/realm/TestDataSourceRealm.java | 7 -------
> test/org/apache/catalina/startup/LoggingBaseTest.java | 1 +
> test/org/apache/catalina/users/TestDataSourceUserDatabase.java | 7 -------
> 3 files changed, 1 insertion(+), 14 deletions(-)
>
> diff --git a/test/org/apache/catalina/realm/TestDataSourceRealm.java b/test/org/apache/catalina/realm/TestDataSourceRealm.java
> index 57486a54c9..bdd1af6972 100644
> --- a/test/org/apache/catalina/realm/TestDataSourceRealm.java
> +++ b/test/org/apache/catalina/realm/TestDataSourceRealm.java
> @@ -16,7 +16,6 @@
> */
> package org.apache.catalina.realm;
>
> -import java.io.File;
> import java.security.Principal;
> import java.sql.Connection;
> import java.sql.DriverManager;
> @@ -24,7 +23,6 @@ import java.sql.PreparedStatement;
> import java.sql.Statement;
> import java.util.List;
>
> -import org.junit.AfterClass;
> import org.junit.Assert;
> import org.junit.Test;
>
> @@ -87,11 +85,6 @@ public class TestDataSourceRealm extends LoggingBaseTest {
>
> private DerbyDataSourceRealm db;
>
> - @AfterClass
> - public static void derbyCleanup() {
> - System.out.println("Deleted derby.log: " + (new File("derby.log")).delete());
> - }
> -
> @Test
> public void testRealm() throws Exception {
>
> diff --git a/test/org/apache/catalina/startup/LoggingBaseTest.java b/test/org/apache/catalina/startup/LoggingBaseTest.java
> index 200978c92f..8a96e41436 100644
> --- a/test/org/apache/catalina/startup/LoggingBaseTest.java
> +++ b/test/org/apache/catalina/startup/LoggingBaseTest.java
> @@ -115,6 +115,7 @@ public abstract class LoggingBaseTest {
> tempDir = Files.createTempDirectory(tempBasePath, "test").toFile();
>
> System.setProperty(Constants.CATALINA_BASE_PROP, tempDir.getAbsolutePath());
> + System.setProperty("derby.system.home", tempDir.getAbsolutePath());
>
> // Configure logging
> System.setProperty("java.util.logging.manager",
> diff --git a/test/org/apache/catalina/users/TestDataSourceUserDatabase.java b/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
> index 56e5458472..c331cb353d 100644
> --- a/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
> +++ b/test/org/apache/catalina/users/TestDataSourceUserDatabase.java
> @@ -16,13 +16,11 @@
> */
> package org.apache.catalina.users;
>
> -import java.io.File;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.Statement;
> import java.util.Iterator;
>
> -import org.junit.AfterClass;
> import org.junit.Assert;
> import org.junit.Test;
>
> @@ -111,11 +109,6 @@ public class TestDataSourceUserDatabase extends LoggingBaseTest {
>
> private DerbyUserDatabase db;
>
> - @AfterClass
> - public static void derbyCleanup() {
> - System.out.println("Deleted derby.log: " + (new File("derby.log")).delete());
> - }
> -
> @Test
> public void testBasicUserRoleDatabase()
> throws Exception {
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org