You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2018/09/10 15:13:52 UTC

svn commit: r1840470 - in /db/derby/code/trunk/java: org.apache.derby.engine/ org.apache.derby.optionaltools/ org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/derbynet/ org.apache.derby.tests/org/apache/derbyTesting/functionTests/test...

Author: rhillegas
Date: Mon Sep 10 15:13:51 2018
New Revision: 1840470

URL: http://svn.apache.org/viewvc?rev=1840470&view=rev
Log:
DERBY-6945: Run upgrade tests with a module path; commit derby-6945-51-ab-runUpgradeTestsWithModulePath.diff.

Modified:
    db/derby/code/trunk/java/org.apache.derby.engine/module-info.java
    db/derby/code/trunk/java/org.apache.derby.optionaltools/module-info.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_9.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/BaseTestCase.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
    db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/org.apache.derby.engine/module-info.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.engine/module-info.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.engine/module-info.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.engine/module-info.java Mon Sep 10 15:13:51 2018
@@ -94,6 +94,8 @@ module org.apache.derby.engine
     exports org.apache.derby.iapi.types;
     exports org.apache.derby.iapi.util;
     exports org.apache.derby.impl.sql.execute;
+    exports org.apache.derby.impl.load;
+    exports org.apache.derby.impl.jdbc;
 
     //
     // DERBY INTERNAL EXPORTS
@@ -188,12 +190,6 @@ module org.apache.derby.engine
     exports org.apache.derby.impl.io.vfmem to
         org.apache.derby.tests;
 
-    exports org.apache.derby.impl.jdbc to
-        org.apache.derby.server,
-        org.apache.derby.tools,
-        org.apache.derby.optionaltools,
-        org.apache.derby.tests;
-
     exports org.apache.derby.impl.jdbc.authentication to
         org.apache.derby.optionaltools;
 
@@ -307,6 +303,14 @@ module org.apache.derby.engine
     //        org.apache.derby.server,
     //        org.apache.derby.tools,
     //        org.apache.derby.optionaltools,
+    //        org.apache.derby.tests;
+    //
+    //
+    // QUERY PLANS REFERENCE org.apache.derby.impl.jdbc.LOBStoredProcedure
+    //    exports org.apache.derby.impl.jdbc to
+    //        org.apache.derby.server,
+    //        org.apache.derby.tools,
+    //        org.apache.derby.optionaltools,
     //        org.apache.derby.tests;
 
 }

Modified: db/derby/code/trunk/java/org.apache.derby.optionaltools/module-info.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.optionaltools/module-info.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.optionaltools/module-info.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.optionaltools/module-info.java Mon Sep 10 15:13:51 2018
@@ -55,4 +55,9 @@ module org.apache.derby.optionaltools
     provides org.apache.derby.shared.api.DerbyModuleAPI
         with org.apache.derby.optional.info.DerbyModule;
 
+    //
+    // OPEN TO REFLECTIVE ACCESS FROM THE ENGINE
+    //
+    opens org.apache.derby.optional.lucene to
+        org.apache.derby.engine;
 }

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/derbynet/ShutDownDBWhenNSShutsDownTest.java Mon Sep 10 15:13:51 2018
@@ -1,6 +1,6 @@
 /*
  *
- * Derby - Class ShutDownDBWhenNSShutsDownTest
+ * Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.ShutDownDBWhenNSShutsDownTest
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/BasicSetup.java Mon Sep 10 15:13:51 2018
@@ -28,7 +28,11 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 import javax.sql.DataSource;
+
 import junit.framework.Test;
+
+import org.apache.derby.shared.common.info.JVMInfo;
+
 import org.apache.derby.catalog.SystemProcedures;
 import org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream;
 import org.apache.derbyTesting.junit.BaseTestSuite;
@@ -104,10 +108,22 @@ public class BasicSetup extends UpgradeC
         case PH_CREATE:
         case PH_POST_SOFT_UPGRADE:
             DatabaseMetaData dmd = getConnection().getMetaData();
-            assertEquals("Old major (driver): ",
+
+            //
+            // If we are running on the classpath, then the driver
+            // will be an embedded driver corresponding to the old version.
+            // But if we are running on the module path, then the
+            // old version is running in a server and the driver
+            // is a client driver corresponding to the current version.
+            //
+            if (!JVMInfo.isModuleAware())
+            {
+              assertEquals("Old major (driver): ",
                     getOldMajor(), dmd.getDriverMajorVersion());
-            assertEquals("Old minor (driver): ",
+              assertEquals("Old minor (driver): ",
                     getOldMinor(), dmd.getDriverMinorVersion());
+            }
+            
             assertEquals("Old major (database): ",
                     getOldMajor(), dmd.getDatabaseMajorVersion());
             assertEquals("Old minor (database): ",
@@ -182,7 +198,7 @@ public class BasicSetup extends UpgradeC
      */
     public void testCreateTable() throws SQLException
     {
-        
+      Connection conn = getConnection();
         Statement stmt = createStatement();
         try {
             stmt.executeUpdate("DROP table t");
@@ -193,6 +209,7 @@ public class BasicSetup extends UpgradeC
         }
         stmt.executeUpdate("CREATE TABLE T (I INT)");
         TestConfiguration.getCurrent().shutdownDatabase();
+        conn.close();
         stmt = createStatement();
         ResultSet rs = stmt.executeQuery("SELECT * from t");
         JDBC.assertEmpty(rs);  
@@ -207,6 +224,7 @@ public class BasicSetup extends UpgradeC
      */
     public void testIndex() throws SQLException 
     {
+        Connection conn = getConnection();
         Statement stmt = createStatement();
         try {
             stmt.executeUpdate("DROP table ti");
@@ -220,6 +238,7 @@ public class BasicSetup extends UpgradeC
         stmt.executeUpdate("INSERT INTO  TI values(2)");
         stmt.executeUpdate("INSERT INTO  TI values(3)");
         TestConfiguration.getCurrent().shutdownDatabase();
+        conn.close();
         stmt = createStatement();
         ResultSet rs = stmt.executeQuery("SELECT * from TI ORDER BY I");
         JDBC.assertFullResultSet(rs, new String[][] {{"1"},{"2"},{"3"}});
@@ -242,9 +261,32 @@ public class BasicSetup extends UpgradeC
                     // Check the innermost of the nested exceptions
                     SQLException sqle = getLastSQLException(e);
                     String sqlState = sqle.getSQLState();
+                    String message = sqle.getMessage();
                 	// while beta, XSLAP is expected, if not beta, XSLAN
-                	if (!(sqlState.equals("XSLAP")) && !(sqlState.equals("XSLAN")))
-                		fail("expected an error indicating no connection");
+                    String INCOMPATIBLE_VERSION = "XSLAN";
+                    String BETA_UPGRADE_NOT_ALLOWED = "XSLAP";
+                    String BOOT_DATABASE_FAILED = "XJ040";
+                	if (
+                        // if running embedded
+                        (
+                         !(sqlState.equals(BETA_UPGRADE_NOT_ALLOWED)) &&
+                         !(sqlState.equals(INCOMPATIBLE_VERSION)) &&
+                         !(sqlState.equals(BOOT_DATABASE_FAILED))
+                         )
+                        &&
+                        // if running client/server
+                        (
+                         !message.contains(BETA_UPGRADE_NOT_ALLOWED) &&
+                         !message.contains(INCOMPATIBLE_VERSION)
+                         )
+                        )
+                    {
+                		fail
+                          (
+                           "unexpected error after attempting a new connection: " +
+                           "SQLstate = " + sqlState + ", message = '" + sqle.getMessage() + "'"
+                           );
+                    }
                 }
             break;
         }

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java Mon Sep 10 15:13:51 2018
@@ -27,6 +27,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import junit.framework.Test;
+import org.apache.derby.shared.common.info.JVMInfo;
 import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
 import org.apache.derbyTesting.junit.BaseTestSuite;
 import org.apache.derbyTesting.junit.JDBC;
@@ -329,6 +330,14 @@ public class Changes10_10 extends Upgrad
      */
     public  void    testFloatLimits()  throws Exception
     {
+        // Skip this test if we are running with a module path.
+        // That means that cases which run on the old release
+        // end up using a client driver to access the down-rev
+        // engine in a remote server. The client driver, however,
+        // corresponds to the trunk version, so these tests do
+        // not stress the engine behavior.
+        if (JVMInfo.isModuleAware()) { return; }
+      
         Statement st = createStatement();
         st.execute("create table d3398(r real, d double)");
 

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java Mon Sep 10 15:13:51 2018
@@ -25,6 +25,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import junit.framework.Test;
+import org.apache.derby.shared.common.info.JVMInfo;
 import org.apache.derby.catalog.TypeDescriptor;
 import org.apache.derby.catalog.types.RoutineAliasInfo;
 import org.apache.derbyTesting.junit.BaseTestSuite;
@@ -159,6 +160,11 @@ public class Changes10_6 extends Upgrade
             
             if ( !hasFunction ) { break; }
 
+            // If we are running with a module path, then the catalog
+            // is remote and the alias descriptor will not serialize
+            // across the client/server connection. Skip the following test.
+            if (JVMInfo.isModuleAware()) { break; }
+
             returnType = getTypeDescriptor( rs.getObject( 1 ) );
             actualJdbcType = getJDBCTypeId( returnType );
             actualLength = getMaximumWidth( returnType );

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_9.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_9.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_9.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_9.java Mon Sep 10 15:13:51 2018
@@ -33,6 +33,7 @@ import java.util.ArrayList;
 import java.util.List;
 import javax.sql.DataSource;
 import junit.framework.Test;
+import org.apache.derby.shared.common.info.JVMInfo;
 import org.apache.derbyTesting.functionTests.tests.upgradeTests.helpers.DisposableIndexStatistics;
 import org.apache.derbyTesting.junit.BaseTestSuite;
 import org.apache.derbyTesting.junit.IndexStatsUtil;
@@ -892,6 +893,13 @@ public class Changes10_9 extends Upgrade
         //  appear in order to test the drop statistics after hard upgrade
         if (!oldAtLeast(10, 5)) return;
 
+        // Also don't run this test if we are running with the module path.
+        // In that case, the engine is running remotely in a server at
+        // a different version level. The statistics objects will not
+        // serialize across a network connection: they are only meant to
+        // be deserialized inside the engine.
+        if (JVMInfo.isModuleAware()) { return; }
+
         // Helper object to obtain information about index statistics.
         IndexStatsUtil stats = new IndexStatsUtil(openDefaultConnection());
         Statement s = createStatement();
@@ -997,6 +1005,13 @@ public class Changes10_9 extends Upgrade
             return;
         }
 
+        // Also don't run this test if we are running with the module path.
+        // In that case, the engine is running remotely in a server at
+        // a different version level. The statistics objects will not
+        // serialize across a network connection: they are only meant to
+        // be deserialized inside the engine.
+        if (JVMInfo.isModuleAware()) { return; }
+
         final String TBL = "ISTAT_DISPOSABLE_STATS";
         String updateStatsSQL = "call syscs_util.syscs_update_statistics(" +
                 "'APP', ?, null)";

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/PhaseChanger.java Mon Sep 10 15:13:51 2018
@@ -29,6 +29,8 @@ import javax.sql.DataSource;
 
 import junit.framework.Test;
 
+import org.apache.derby.shared.common.info.JVMInfo;
+
 import org.apache.derbyTesting.junit.BaseTestCase;
 import org.apache.derbyTesting.junit.BaseTestSetup;
 import org.apache.derbyTesting.junit.ClassLoaderTestSetup;
@@ -184,10 +186,16 @@ final class PhaseChanger extends BaseTes
             Method m = unloader.getMethod("unload", (Class[]) null);
             Boolean res = (Boolean) m.invoke(null, (Object[]) null);
 
-            // Check that there weren't any drivers to unload except in the
-            // versions affected by DERBY-2905.
-            assertEquals("Unexpected result from driver unloading",
+            // Don't check this on a JVM which is
+            // module aware because, in that case, the relevant driver is remote
+            // in the server.
+            if (!JVMInfo.isModuleAware())
+            {
+                // Check that there weren't any drivers to unload except in the
+                // versions affected by DERBY-2905.
+                assertEquals("Unexpected result from driver unloading",
                          isAffectedVersion, res.booleanValue());
+            }
         }
     }
 
@@ -209,6 +217,12 @@ final class PhaseChanger extends BaseTes
             return;
         }
 
+        // nothing to do if we are running with a module path.
+        // in that case, the down-rev code runs remotely under
+        // a derby server. the field below no longer exists
+        // in the TableDescriptor class on the trunk.
+        if (JVMInfo.isModuleAware()) { return; }
+
         Class td = Class.forName(
                 "org.apache.derby.iapi.sql.dictionary.TableDescriptor",
                 true, loader);

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeClassLoader.java Mon Sep 10 15:13:51 2018
@@ -42,11 +42,19 @@ import org.apache.derbyTesting.junit.Bas
  */
 public class UpgradeClassLoader
 {
-    private static final String[] jarFiles = {
+    private static final Version FIRST_MODULE_SUPPORT_VERSION = new Version(new int[] { 10, 15, 0, 0 });
+    private static final String[] _preModuleSupport_jarFiles = {
             "derby.jar", 
-            //"derbynet.jar",
-            //"derbyclient.jar",
-            //"derbytools.jar"
+            "derbynet.jar",
+            "derbyTesting.jar",
+            };
+
+    private static final String[] _postModuleSupport_jarFiles = {
+            "derby.jar", 
+            "derbynet.jar",
+            "derbyTesting.jar",
+            "derbyshared.jar",
+            "derbytools.jar"
             };
 
     static final String oldVersionsPath =
@@ -133,7 +141,12 @@ public class UpgradeClassLoader
      */
     private static ClassLoader createClassLoader(int[] version)
     {
-        URL[] url = new URL[jarFiles.length];
+        Version oldVersion = new Version(version);
+        String[] jarFiles = (oldVersion.compareTo(FIRST_MODULE_SUPPORT_VERSION) < 0) ?
+            _preModuleSupport_jarFiles : _postModuleSupport_jarFiles;
+
+        // add an extra slot at the end for junit.jar
+        URL[] url = new URL[jarFiles.length + 1];
         
         String jarLocation = getOldJarLocation(version);
         
@@ -182,6 +195,10 @@ public class UpgradeClassLoader
             }
         }
 
+        // add junit.jar to the classpath
+        int lastSlot = jarFiles.length;
+        url[lastSlot] = Assert.class.getProtectionDomain().getCodeSource().getLocation();
+
         // Create a class loader which loads Derby classes from the specified
         // URL, and JDBC classes and other system classes from the platform
         // class loader.

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java Mon Sep 10 15:13:51 2018
@@ -20,10 +20,16 @@ limitations under the License.
 */
 package org.apache.derbyTesting.functionTests.tests.upgradeTests;
 
+import java.io.File;
 import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
 import java.util.Properties;
 import junit.extensions.TestSetup;
 import junit.framework.Test;
+import org.apache.derby.shared.common.info.JVMInfo;
+import org.apache.derby.shared.common.reference.Property;
 import org.apache.derbyTesting.functionTests.tests.jdbcapi.DatabaseMetaDataTest;
 import org.apache.derbyTesting.junit.BaseTestCase;
 import org.apache.derbyTesting.junit.BaseTestSuite;
@@ -43,6 +49,8 @@ import org.apache.derbyTesting.junit.Tes
  */
 class UpgradeRun extends UpgradeClassLoader
 {
+
+    private static final String QUOTE = "\"";
     
     /**
      * Set of additional databases for tests that
@@ -80,7 +88,24 @@ class UpgradeRun extends UpgradeClassLoa
                     "Empty: Skipped upgrade Tests (no jars) for " + getTextVersion(version));
             return suite;
         }
-        
+
+        //
+        // Skip tests for releases before 10.2.2.0 if
+        // we are running with a module path. That is because
+        // a module-aware run requires that the old release
+        // be booted in a server. But the handleJavaSE6() method
+        // forces us into embedded mode for releases
+        // prior to 10.2.2.0.
+        //
+        if (JVMInfo.isModuleAware() && lessThan(version, new int[] {10, 2, 2, 0}))
+        {
+            BaseTestSuite suite = new BaseTestSuite
+              (
+               "Empty: Skipped upgrade Tests (cannot use module path for " + getTextVersion(version) +
+               " because it comes before before 10.2.2.0)."
+               );
+            return suite;
+        }
 
         BaseTestSuite suite = new BaseTestSuite(
                 "Upgrade Tests from " + getTextVersion(version));
@@ -91,25 +116,29 @@ class UpgradeRun extends UpgradeClassLoa
               phase < UpgradeChange.PHASES.length; phase++)
         {
             ClassLoader loader = null;
+            boolean phaseForOldRelease = false;
             switch (phase)
             {
             case UpgradeChange.PH_CREATE:
             case UpgradeChange.PH_POST_SOFT_UPGRADE:
             case UpgradeChange.PH_POST_HARD_UPGRADE:
                 loader = oldLoader;
+                phaseForOldRelease = true;
                 break;
             case UpgradeChange.PH_SOFT_UPGRADE:
             case UpgradeChange.PH_HARD_UPGRADE:
                 break;
                 
             }
-            Test phaseTests = baseSuite(getTextVersion(version)
-                    + " Upgrade Phase: " + UpgradeChange.PHASES[phase] + " ",
+            String testName = getTextVersion(version)
+              + " Upgrade Phase: " + UpgradeChange.PHASES[phase] + " ";
+            Test phaseTests = baseSuite(testName,
                     phase, version);
             
             Test phaseSet = new PhaseChanger(phaseTests, phase, loader, version, useCreateOnUpgrade);
             phaseSet = handleJavaSE6(phase, version, phaseSet);
-            suite.addTest(phaseSet);
+            Test moduleAdjustment = adjustForModules(phaseSet, version, phaseForOldRelease, oldLoader);
+            suite.addTest(moduleAdjustment);
         }
           
         TestSetup setup = TestConfiguration.singleUseDatabaseDecorator(suite);
@@ -127,12 +156,73 @@ class UpgradeRun extends UpgradeClassLoa
         
         Properties preReleaseUpgrade = new Properties();
         preReleaseUpgrade.setProperty(
-                "derby.database.allowPreReleaseUpgrade", "true");
+                Property.ALPHA_BETA_ALLOW_UPGRADE, "true");
         
         setup = new SystemPropertyTestSetup(setup, preReleaseUpgrade);
    
         return SecurityManagerSetup.noSecurityManager(setup);
     }
+
+    /**
+     * Adjust with a client/server decorator if we are running on
+     * the module path and the test phase is one of those which
+     * is performed on the old database.
+     *
+     * @param test The test to possibly decorate
+     * @param versionNumber The old version number
+     * @param phaseForOldRelease True if the phase runs on the old release
+     * @param classLoader The ClassLoader to use to find the old release jars
+     *
+     * @return the test, possibly decorate with a client/server wrapper
+     */
+    private static Test adjustForModules
+      (Test test, int[] versionNumber, boolean phaseForOldRelease, ClassLoader loader)
+    {
+        // nothing to do if we aren't running with a module path
+        if (!JVMInfo.isModuleAware()) { return test; }
+
+        // only boot a server off the old release jars
+        // if the phase is an old release phase
+        if (!phaseForOldRelease) { return test; }
+
+        Version version = new Version(versionNumber);
+
+        // get the loader which lists the jar files of the old release
+        URLClassLoader ucl = (URLClassLoader) loader.getParent();
+        URL[] urls = ucl.getURLs();
+        int urlCount = urls.length;
+
+        StringBuilder buffer = new StringBuilder();
+        for (int idx = 0; idx < urlCount; idx++)
+        {
+            if (idx > 0) { buffer.append(File.pathSeparator); }
+            buffer.append(urls[idx].toString());
+        }
+
+        String classpath = buffer.toString();
+
+        // make the server access databases under the same
+        // directory as the embedded usage does.
+        // allow upgrade to the current (trunk) alpha version
+        String[] serverProperties = new String[]
+        {
+            Property.SYSTEM_HOME_PROPERTY + "=system",
+            Property.ALPHA_BETA_ALLOW_UPGRADE + "=true",
+        };
+
+        // network security manager settings are stricter
+        // on later versions of the JVM. turn off the security
+        // manager on the server.
+        ArrayList<String> startupArgList = new ArrayList<String>();
+        if (version.compareTo(Version.V_10_3_0_0) >= 0)
+        { startupArgList.add("-noSecurityManager"); }
+        String[] startupArgs = new String[startupArgList.size()];
+        startupArgList.toArray(startupArgs);
+
+        // boot the old release from the classpath: old releases don't support modules
+        return TestConfiguration.clientServerDecorator
+          (test, serverProperties, startupArgs, true, classpath, false, true);
+    }
     
     /**
      * Add the tests from the various Changes classes (sub-classes

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java Mon Sep 10 15:13:51 2018
@@ -39,6 +39,7 @@ public class Version implements Comparab
     //
     ///////////////////////////////////////////////////////////////////////////////////
 
+    public static final Version V_10_3_0_0 = new Version(10, 3, 0, 0);
     private static final int EXPECTED_LEG_COUNT = 4;
 
     ///////////////////////////////////////////////////////////////////////////////////

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/BaseTestCase.java Mon Sep 10 15:13:51 2018
@@ -649,8 +649,43 @@ public abstract class BaseTestCase
         String jvm, String cp, String[] cmd, final File dir, boolean addClassPath)
             throws IOException
     {
-        boolean isModuleAware = JVMInfo.isModuleAware();
+        boolean useModules = JVMInfo.isModuleAware();
 
+        return execJavaCmd(jvm, cp, cmd, dir, addClassPath, useModules);
+    }
+  
+	/**
+	 * Execute a java command and return the process.
+	 * The caller should decide what to do with the process, if anything,
+	 * typical activities would be to do a pr.waitFor, or to
+	 * get a getInputStream or getErrorStream
+	 * Note, that for verifying the output of a Java process, there is
+	 * assertExecJavaCmdAsExpected
+	 * 
+     * @param jvm the path to the java executable, or {@code null} to use
+     *            the default executable returned by
+     *            {@link #getJavaExecutableName()}
+     * @param cp  the classpath for the spawned process, or {@code null} to
+     *            inherit the classpath from the parent process
+	 * @param cmd array of java arguments for command
+     * @param dir working directory for the sub-process, or {@code null} to
+     *            run in the same directory as the main test process
+     * @param addClassPath if {@code true},add classpath
+     * @param useModulePath if {@code true}, use the modulepath rather than the classpath
+	 * @return the process that was started
+	 * @throws IOException
+	 */
+    public static Process execJavaCmd
+      (
+       String jvm,
+       String cp,
+       String[] cmd,
+       final File dir,
+       boolean addClassPath,
+       boolean useModulePath
+       )
+      throws IOException
+    {
         // Is this an invocation of a jar file with java -jar ...?
         final boolean isJarInvocation = cmd.length > 0 && cmd[0].equals("-jar");
 
@@ -716,7 +751,7 @@ public abstract class BaseTestCase
             setupForDebuggerAttach(cmdlist);
         }
 
-        if (isModuleAware)
+        if (useModulePath)
         {
             cmdlist.add("--add-modules");
             cmdlist.add(ModuleUtil.TESTING_MODULE_NAME + "," + DerbyConstants.JUNIT_MODULE_NAME);
@@ -731,10 +766,10 @@ public abstract class BaseTestCase
         } else if (addClassPath) {
             String myClasspath;
             if (cp != null) { myClasspath = cp; }
-            else if (isModuleAware) { myClasspath = JVMInfo.getSystemModulePath(); }
+            else if (useModulePath) { myClasspath = JVMInfo.getSystemModulePath(); }
             else { myClasspath = getSystemProperty("java.class.path"); }
 
-            if (isModuleAware) { cmdlist.add("-p"); }
+            if (useModulePath) { cmdlist.add("-p"); }
             else { cmdlist.add("-classpath"); }
             cmdlist.add(myClasspath);
         }

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/NetworkServerTestSetup.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/NetworkServerTestSetup.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/NetworkServerTestSetup.java Mon Sep 10 15:13:51 2018
@@ -87,6 +87,24 @@ final public class NetworkServerTestSetu
      * only when starting the server in a separate virtual machine.
      */
     private final String[]    systemProperties;
+  
+    /**
+     * Classpath or modulepath to use.
+     */
+    private final String      moduleOrClassPath;
+
+    /**
+     * If true, then use the modulepath. Otherwise, use the classpath.
+     */
+    private final boolean     useModules;
+
+    /**
+     * If true, then expected server diagnostics will be ignored
+     * and will not be printed to the console.
+     */
+    private final boolean     suppressServerDiagnostics;
+  
+  
     
     /**
      * Startup arguments for the command line
@@ -120,6 +138,10 @@ final public class NetworkServerTestSetu
         this.useSeparateProcess = false;
         this.serverShouldComeUp = true;
         this.startServerAtSetup = true;
+
+        this.moduleOrClassPath = null;
+        this.useModules = false;
+        this.suppressServerDiagnostics = false;
     }
 
     /**
@@ -151,6 +173,10 @@ final public class NetworkServerTestSetu
         this.serverShouldComeUp = true;
 
         this.startServerAtSetup = startServerAtSetup;
+
+        this.moduleOrClassPath = null;
+        this.useModules = false;
+        this.suppressServerDiagnostics = false;
     }
     
      /**
@@ -177,6 +203,36 @@ final public class NetworkServerTestSetu
          boolean serverShouldComeUp
         )
     {
+        this(test, systemProperties, startupArgs, serverShouldComeUp, null, JVMInfo.isModuleAware(), false);
+    }
+  
+     /**
+     * Decorator for starting up with specific command args
+     * and system properties. Server is always started up
+     * in a separate process with a separate virtual machine.
+     * <P>
+     * If the classes are being loaded from the classes
+     * folder instead of jar files then this will start
+     * the server up with no security manager using -noSecurityManager,
+     * unless the systemProperties or startupArgs set up any security
+     * manager.
+     * This is because the default policy
+     * installed by the network server only works from jar files.
+     * If this not desired then the test should skip the
+     * fixtures when loading from classes or
+     * install its own security manager.
+     */
+    public NetworkServerTestSetup
+      (
+       Test test,
+       String[] systemProperties,
+       String[] startupArgs,
+       boolean serverShouldComeUp,
+       String moduleOrClassPath,
+       boolean useModules,
+       boolean suppressServerDiagnostics
+       )
+    {
         super(test);
         
         this.asCommand = true;
@@ -186,6 +242,9 @@ final public class NetworkServerTestSetu
         this.useSeparateProcess = true;
         this.serverShouldComeUp = serverShouldComeUp;
         this.startServerAtSetup = true;
+        this.moduleOrClassPath = moduleOrClassPath;
+        this.useModules = useModules;
+        this.suppressServerDiagnostics = suppressServerDiagnostics;
     }
 
     /**
@@ -349,7 +408,6 @@ final public class NetworkServerTestSetu
 
     private SpawnedProcess startSeparateProcess() throws Exception
     {
-        boolean isModuleAware = JVMInfo.isModuleAware();
         BaseTestCase.println("Starting network server as a separate process:");
         ArrayList<String> al = new ArrayList<String>();
         boolean         skipHostName = false;
@@ -395,7 +453,7 @@ final public class NetworkServerTestSetu
         }
 
         String serverName = NetworkServerControl.class.getName();
-        if (isModuleAware)
+        if (useModules)
         {
             al.add("-m");
             al.add(ModuleUtil.SERVER_MODULE_NAME + "/" + serverName);
@@ -419,7 +477,8 @@ final public class NetworkServerTestSetu
         final   String[]  command = new String[ al.size() ];
         al.toArray(command);
 
-        Process serverProcess = BaseTestCase.execJavaCmd(command);
+        Process serverProcess = BaseTestCase.execJavaCmd
+          (null, moduleOrClassPath, command, null, true, useModules);
 
         return new SpawnedProcess(serverProcess, "SpawnedNetworkServer");
     }
@@ -453,7 +512,16 @@ final public class NetworkServerTestSetu
                     networkServerController.shutdown();
                 } catch (Throwable t)
                 {
-                    failedShutdown = t;
+                    String errorMessage = t.getMessage();
+                    //
+                    // The following error message is expected if we
+                    // are shutting down a server from an old Derby
+                    // codeline. That can happen during the upgrade tests.
+                    //
+                    if ((errorMessage == null) || !errorMessage.contains("DRDA_InvalidReplyHead"))
+                    {
+                        failedShutdown = t;
+                    }
                 }
             }
  
@@ -465,6 +533,7 @@ final public class NetworkServerTestSetu
                 // Destroy the process if a failed shutdown
                 // to avoid hangs running tests as the complete()
                 // waits for the process to complete.
+                if (suppressServerDiagnostics) { spawnedServer.suppressOutputOnComplete(); }
                 spawnedServer.complete(getWaitTime());
                 spawnedServer = null;
             }

Modified: db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/TestConfiguration.java?rev=1840470&r1=1840469&r2=1840470&view=diff
==============================================================================
--- db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/TestConfiguration.java (original)
+++ db/derby/code/trunk/java/org.apache.derby.tests/org/apache/derbyTesting/junit/TestConfiguration.java Mon Sep 10 15:13:51 2018
@@ -38,6 +38,7 @@ import junit.framework.Assert;
 import junit.framework.Test;
 import junit.framework.TestCase;
 
+import org.apache.derby.shared.common.info.JVMInfo;
 import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
 
 /**
@@ -498,6 +499,37 @@ public final class TestConfiguration {
             
         return defaultServerDecorator(test);
     }
+  
+    /**
+     * Return a decorator for the passed in tests that sets the
+     * configuration for the client to be Derby's JDBC client
+     * and to start the network server at setUp.
+     * <BR>
+     * The database configuration (name etc.) is based upon
+     * the previous configuration.
+     * <BR>
+     * The previous TestConfiguration is restored at tearDown and
+     * the network server is shutdown.
+     */
+    public static Test clientServerDecorator
+      (
+       Test suite,
+       String[] systemProperties,
+       String[] startupArgs,
+       boolean serverShouldComeUp,
+       String moduleOrClassPath,
+       boolean useModules,
+       boolean suppressServerDiagnostics
+       )
+    {
+        Test test = new NetworkServerTestSetup
+          (
+           suite, systemProperties, startupArgs, serverShouldComeUp,
+           moduleOrClassPath, useModules, suppressServerDiagnostics
+           );
+            
+        return defaultServerDecorator(test);
+    }
 
     /**
      * Return a decorator for the passed in tests that sets the