Hi, As previously discussed the new logging feature requires calling LoggingFactory.clearLogId() at the beginning of each transaction, and there were some places in test code where that was missing.
I confirm that the latest patches from Grant actually covered most cases, I could only find four more and I am attaching a patch to fix them as well. Note: at the moment we haven't looked into main application code yet. This ends this patch batch, hopefully, as we were finally able to run all the tests successfully, at least on Postgres :-) Regards, -- Silvio Moioli SUSE LINUX Products GmbH Maxfeldstraße 5, 90409 Nürnberg Germany
>From 38d72cb5bd2cc62534f5b5ad6b0048dcfb999c9a Mon Sep 17 00:00:00 2001 From: Silvio Moioli <smoi...@suse.de> Date: Mon, 9 Sep 2013 11:48:44 +0200 Subject: [PATCH 22/22] junit tests: some logging cleanups --- .../src/com/redhat/rhn/common/messaging/test/MessageQueueTest.java | 2 ++ .../rhn/frontend/action/rhnpackage/profile/test/SyncActionsTest.java | 2 ++ java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java | 2 ++ java/code/src/com/redhat/rhn/testing/BaseTestCaseWithUser.java | 3 +++ 4 files changed, 9 insertions(+) diff --git a/java/code/src/com/redhat/rhn/common/messaging/test/MessageQueueTest.java b/java/code/src/com/redhat/rhn/common/messaging/test/MessageQueueTest.java index b3ad233..2a1d4c8 100644 --- a/java/code/src/com/redhat/rhn/common/messaging/test/MessageQueueTest.java +++ b/java/code/src/com/redhat/rhn/common/messaging/test/MessageQueueTest.java @@ -26,6 +26,7 @@ import com.redhat.rhn.common.db.datasource.ModeFactory; import com.redhat.rhn.common.db.datasource.WriteMode; import com.redhat.rhn.common.hibernate.HibernateFactory; import com.redhat.rhn.common.messaging.MessageQueue; +import com.redhat.rhn.domain.common.LoggingFactory; import com.redhat.rhn.domain.monitoring.ServerProbe; import com.redhat.rhn.domain.monitoring.test.MonitoringFactoryTest; import com.redhat.rhn.domain.org.OrgFactory; @@ -60,6 +61,7 @@ public class MessageQueueTest extends RhnBaseTestCase { // If at some point we created a user and committed the transaction, we need // clean up our mess if (committed) { + LoggingFactory.clearLogId(); OrgFactory.deleteOrg(user.getOrg().getId(), user); commitAndCloseSession(); } diff --git a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/profile/test/SyncActionsTest.java b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/profile/test/SyncActionsTest.java index 2abae4e..3ac9c9d 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/profile/test/SyncActionsTest.java +++ b/java/code/src/com/redhat/rhn/frontend/action/rhnpackage/profile/test/SyncActionsTest.java @@ -19,6 +19,7 @@ import java.util.Set; import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.test.ChannelFactoryTest; +import com.redhat.rhn.domain.common.LoggingFactory; import com.redhat.rhn.domain.org.OrgFactory; import com.redhat.rhn.domain.rhnpackage.Package; import com.redhat.rhn.domain.rhnpackage.test.PackageTest; @@ -108,6 +109,7 @@ public class SyncActionsTest extends RhnMockStrutsTestCase { protected void tearDown() throws Exception { super.tearDown(); // We committed stuff - need to remove it all again + LoggingFactory.clearLogId(); OrgFactory.deleteOrg(user.getOrg().getId(), user); commitAndCloseSession(); } diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java index 935b51c..51e697f 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java @@ -18,6 +18,7 @@ import com.redhat.rhn.common.db.datasource.CallableMode; import com.redhat.rhn.common.db.datasource.DataResult; import com.redhat.rhn.common.db.datasource.ModeFactory; import com.redhat.rhn.common.hibernate.HibernateFactory; +import com.redhat.rhn.domain.common.LoggingFactory; import com.redhat.rhn.domain.kickstart.KickstartData; import com.redhat.rhn.domain.kickstart.KickstartFactory; import com.redhat.rhn.domain.kickstart.KickstartableTree; @@ -178,6 +179,7 @@ public class SatScrubberTest extends TestCase { Long id = (Long) row.get("id"); log.debug("Deleting org: " + id); try { + LoggingFactory.clearLogId(); OrgFactory.deleteOrg(new Long(id.longValue()), UserFactory .findResponsibleUser(1L, RoleFactory.SAT_ADMIN)); } diff --git a/java/code/src/com/redhat/rhn/testing/BaseTestCaseWithUser.java b/java/code/src/com/redhat/rhn/testing/BaseTestCaseWithUser.java index 8c21c45..cf85817 100644 --- a/java/code/src/com/redhat/rhn/testing/BaseTestCaseWithUser.java +++ b/java/code/src/com/redhat/rhn/testing/BaseTestCaseWithUser.java @@ -47,6 +47,9 @@ public abstract class BaseTestCaseWithUser extends RhnBaseTestCase { // If at some point we created a user and committed the transaction, we need // clean up our mess if (committed) { + // Set up logging again, as Hibernate might have swapped the connection + // with a new one after the commit + LoggingFactory.clearLogId(); OrgFactory.deleteOrg(user.getOrg().getId(), user); commitAndCloseSession(); } -- 1.8.1.4
_______________________________________________ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel