Derby
  1. Derby
  2. DERBY-5107

BasicInMemoryDbTest depends on implicit ordering of test cases

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.8.1.2
    • Fix Version/s: 10.8.1.2
    • Component/s: Test
    • Labels:
      None
    • Bug behavior facts:
      Regression Test Failure

      Description

      BasicInMemoryDbTest only works if the test cases run in one particular order. This should either be made explicit in the test, or the test should be changed to work regardless of the ordering.

      For example, if testEnginehutdown (sic) runs before testShutdown, testShutdown will fail:

      http://dbtg.foundry.sun.com/derby/test/Daily/jvm1.7/testing/testlog/lin/1076682-suitesAll_diff.txt

      11) testShutdown(org.apache.derbyTesting.functionTests.tests.memorydb.BasicInMemoryDbTest)junit.framework.AssertionFailedError: Warning(s) when creating database: Database 'memory:/tmp/myDB' not created, connection made to existing database instead.
      at org.apache.derbyTesting.functionTests.tests.memorydb.MemoryDbManager.createDatabase(MemoryDbManager.java:226)
      at org.apache.derbyTesting.functionTests.tests.memorydb.MemoryDbManager.createDatabase(MemoryDbManager.java:181)
      at org.apache.derbyTesting.functionTests.tests.memorydb.BasicInMemoryDbTest.testShutdown(BasicInMemoryDbTest.java:189)

      Also, when running from classes, some test cases (like testEnginehutdown and testDeleteWhenInUse) will fail with no suitable driver if they run before some other test case has called MemoryDbManager.getConnection():

      1) testEnginehutdown(org.apache.derbyTesting.functionTests.tests.memorydb.BasicInMemoryDbTest)java.sql.SQLException: No suitable driver found for jdbc:derby:memory:/tmp/myDB;create=true
      at java.sql.DriverManager.getConnection(DriverManager.java:640)
      at java.sql.DriverManager.getConnection(DriverManager.java:222)
      at org.apache.derbyTesting.functionTests.tests.memorydb.BasicInMemoryDbTest.testEnginehutdown(BasicInMemoryDbTest.java:209)

      1. derby-5107-1a.diff
        2 kB
        Knut Anders Hatlen

        Activity

        Knut Anders Hatlen created issue -
        Knut Anders Hatlen made changes -
        Field Original Value New Value
        Assignee Knut Anders Hatlen [ knutanders ]
        Knut Anders Hatlen made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Knut Anders Hatlen added a comment -

        Attaching a patch to address the problems seen in BasicInMemoryDbTest. It makes the following changes:

        1) Call super.tearDown() from tearDown(). This doesn't directly address any of the problems reported here, but cleaning up the default connection (used only by some of the test cases) sounds useful in any case.

        2) Use the helper class MemoryDbManager to create the database in testEnginehutdown(). This ensures that the created database is dropped in tearDown() and doesn't cause any problems if testShutdown() is invoked later.

        3) Make sure the JDBC driver is loaded in the tests that use DriverManager directly, so that we don't get the "no suitable driver" error if they run before any of the test cases that get the driver loaded implicitly via the framework.

        Show
        Knut Anders Hatlen added a comment - Attaching a patch to address the problems seen in BasicInMemoryDbTest. It makes the following changes: 1) Call super.tearDown() from tearDown(). This doesn't directly address any of the problems reported here, but cleaning up the default connection (used only by some of the test cases) sounds useful in any case. 2) Use the helper class MemoryDbManager to create the database in testEnginehutdown(). This ensures that the created database is dropped in tearDown() and doesn't cause any problems if testShutdown() is invoked later. 3) Make sure the JDBC driver is loaded in the tests that use DriverManager directly, so that we don't get the "no suitable driver" error if they run before any of the test cases that get the driver loaded implicitly via the framework.
        Knut Anders Hatlen made changes -
        Attachment derby-5107-1a.diff [ 12473839 ]
        Hide
        Knut Anders Hatlen added a comment -

        Committed revision 1082282.

        Show
        Knut Anders Hatlen added a comment - Committed revision 1082282.
        Knut Anders Hatlen made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s 10.8.0.0 [ 12315561 ]
        Resolution Fixed [ 1 ]
        Rick Hillegas made changes -
        Affects Version/s 10.8.1.1 [ 12316356 ]
        Affects Version/s 10.8.1.0 [ 12315561 ]
        Fix Version/s 10.8.1.1 [ 12316356 ]
        Fix Version/s 10.8.1.0 [ 12315561 ]
        Rick Hillegas made changes -
        Affects Version/s 10.8.1.2 [ 12316362 ]
        Affects Version/s 10.8.1.1 [ 12316356 ]
        Fix Version/s 10.8.1.2 [ 12316362 ]
        Fix Version/s 10.8.1.1 [ 12316356 ]
        Knut Anders Hatlen made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Gavin made changes -
        Workflow jira [ 12601056 ] Default workflow, editable Closed status [ 12801142 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        8d 2h 9m 1 Knut Anders Hatlen 16/Mar/11 18:29
        In Progress In Progress Resolved Resolved
        1h 27m 1 Knut Anders Hatlen 16/Mar/11 19:56
        Resolved Resolved Closed Closed
        105d 13h 24m 1 Knut Anders Hatlen 30/Jun/11 10:21

          People

          • Assignee:
            Knut Anders Hatlen
            Reporter:
            Knut Anders Hatlen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development