Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Database Connection Pool causing JUnit tests to timeout(Database Connection Pool causing JUnit tests to timeout)
Database Connection Pool causing JUnit tests to timeout [message #1816657] Mon, 04 November 2019 09:03 Go to next message
Mark Ashworth is currently offline Mark AshworthFriend
Messages: 40
Registered: January 2012
Member
The application uses two instances of AbstractSQLService, one for Microsoft SQL Server and another for PostgreSQL because of the partitioning of the data between these two database servers.

The problem arises when I try to write unit tests for the retrieve, delete, insert and update methods that use the AbstractMsSqlSqlService (i.e. I have tried this on Derby and MS SQL Server and got the same results).

The problem is that the unit test does not report success because the Scout Test Library is indicating that the connection pool job indicated that there are open connections.

However all the transactions have passed through phase 1 and phase 2 commit stage at this point, so I am not sure what further I should do.

Also I also tried to destroy the connection pool in the @AfterClass method of the unit test but this is only called after the previous error indicates that there are connections in the pool that caused the unit test to fail.

Also tried committing to the transactions explicitly in the service methods that perform the retrieval from the database but this also does not work.

This only seems to be an issue in the unit test and the application uses the services correctly when running the application.

Thank you in advance for any help.


java.lang.AssertionError: Test failed because some jobs did not complete yet. [context=Test method, jobs=[Managing SQL connection pool for xxx.xxx.xxx.xxx.server.sql.SomeSqlService]]
at org.junit.Assert.fail(Assert.java:88)
at org.eclipse.scout.rt.testing.platform.runner.statement.AssertNoRunningJobsStatement.assertNoRunningJobs(AssertNoRunningJobsStatement.java:87)
at org.eclipse.scout.rt.testing.platform.runner.statement.AssertNoRunningJobsStatement.evaluate(AssertNoRunningJobsStatement.java:70)
at org.eclipse.scout.rt.testing.platform.runner.statement.TimesStatement.evaluate(TimesStatement.java:44)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.eclipse.scout.rt.testing.platform.runner.PlatformTestRunner$2.evaluate(PlatformTestRunner.java:104)
at org.eclipse.scout.rt.testing.platform.runner.PlatformTestRunner$InterceptedAfterStatement.evaluate(PlatformTestRunner.java:355)
at org.eclipse.scout.rt.testing.platform.runner.SafeStatementInvoker.run(SafeStatementInvoker.java:39)
at org.eclipse.scout.rt.platform.util.concurrent.Callables.lambda$0(Callables.java:31)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequiresNew(TransactionProcessor.java:100)
at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:69)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:156)
at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:137)
at org.eclipse.scout.rt.platform.context.RunContext.run(RunContext.java:108)
at org.eclipse.scout.rt.testing.platform.runner.statement.RunContextStatement.evaluate(RunContextStatement.java:41)
at org.eclipse.scout.rt.testing.platform.runner.statement.AssertNoRunningJobsStatement.evaluate(AssertNoRunningJobsStatement.java:62)
at org.eclipse.scout.rt.testing.platform.runner.statement.PlatformStatement.evaluateWithGlobalPlatform(PlatformStatement.java:96)
at org.eclipse.scout.rt.testing.platform.runner.statement.PlatformStatement.evaluate(PlatformStatement.java:75)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

[Updated on: Mon, 04 November 2019 09:06]

Report message to a moderator

Re: Database Connection Pool causing JUnit tests to timeout [message #1816794 is a reply to message #1816657] Thu, 07 November 2019 05:33 Go to previous message
Mark Ashworth is currently offline Mark AshworthFriend
Messages: 40
Registered: January 2012
Member
At first I tried to shutdown the JobManager after every test and although this resolved the issue initially, I found that other tests would fail when executed in a Maven build because the JobManager was no longer available.

My current solution (i.e. without understanding as yet why the Job is not closing correctly), it to cancel all jobs at the end of the each test case.

	@After
	public void shutdown() {
		
		/* Cancel all jobs in JobManager so that the test completes */		
		IJobManager jobManager = BEANS.get(IJobManager.class);
		
		Predicate<IFuture<?>> filter = Jobs.newFutureFilterBuilder().toFilter();
		
		jobManager.cancel(filter, true);
	}
Previous Topic:How to block a specific Job
Next Topic:Re-use Table class used in TablePage and in Form
Goto Forum:
  


Current Time: Tue Dec 10 02:34:19 GMT 2024

Powered by FUDForum. Page generated in 0.03122 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top