db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r431395 - in /db/derby/code/trunk/java/testing: ./ org/apache/derbyTesting/functionTests/tests/perf/ org/apache/derbyTesting/functionTests/util/
Date Mon, 14 Aug 2006 18:17:57 GMT
Author: davidvc
Date: Mon Aug 14 11:17:57 2006
New Revision: 431395

URL: http://svn.apache.org/viewvc?rev=431395&view=rev
Log:
DERBY-1664: (Partial) This is the first pass at a test that can be used
to gauge how long it takes to do each part of the startup process.  
This could likely be extended to also test how long it takes to create
tables of different size, how long it takes to insert rows, etc.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest_app.properties
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/build.xml
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/copyfiles.ant
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/existingDb.jar
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/JarUtil.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/build.xml

Modified: db/derby/code/trunk/java/testing/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/build.xml?rev=431395&r1=431394&r2=431395&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/build.xml (original)
+++ db/derby/code/trunk/java/testing/build.xml Mon Aug 14 11:17:57 2006
@@ -73,6 +73,7 @@
     <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/unit"/>

     <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/i18n"/>

     <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/jdbc4"/>

+    <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/perf"/>

   	<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/upgradeTests"/>

     <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/largedata"/>

     <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/multi/stress"/>


Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java?rev=431395&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java
Mon Aug 14 11:17:57 2006
@@ -0,0 +1,75 @@
+/*
+ 
+   Derby - Class org.apache.derbyTesting.functionTests.test.perf.StartupTest
+ 
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+ 
+     http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+ */
+
+package org.apache.derbyTesting.functionTests.tests.perf;
+
+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+import org.apache.derbyTesting.functionTests.util.JarUtil;
+
+import java.sql.*;
+
+/**
+ * This test test the timing of starting up Derby.  It tries to divide the
+ * total time up into reasonable chunks.  It's written as a JUnit test but
+ * really can't be automated because the timings are so dependent upon
+ * the exact hardware, operating system and software environment the test
+ * is running in.  I just use JUnit because of the convenient framework
+ * it gives me...
+ */
+public class StartupExistingDBTest extends BaseJDBCTestCase {
+    public StartupExistingDBTest(String name) {
+        super(name);
+    }
+    
+    
+    
+    public void testExistingDB() throws Exception {
+        JarUtil.unjar("existingDb.jar", null);
+        
+        long startTime = System.currentTimeMillis();
+        System.out.println("Testing startup with an EXISTING database... " +
+            "All measurements are in milliseconds.");
+        
+        // Load the driver
+        Class driver = Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+        long currentTime = System.currentTimeMillis();
+        System.out.println("Loading driver:  " + (currentTime - startTime));
+
+        // Use an existing DB.  This is copied over by the harness
+        startTime = System.currentTimeMillis();
+        Connection conn = 
+            DriverManager.getConnection("jdbc:derby:../existingDb");
+        currentTime = System.currentTimeMillis();
+        System.out.println("Open connection with existing database:  " 
+            + (currentTime - startTime));
+
+        // Create a table
+        startTime = System.currentTimeMillis();
+        Statement stmt = conn.createStatement();
+        stmt.execute("CREATE TABLE test_table(id integer primary key, " +
+            "last_name varchar(80), first_name varchar(80), " +
+            "mi char(1), address varchar(100), city varchar(80))");
+        currentTime = System.currentTimeMillis();
+        System.out.println("Creating a table:  " 
+            + (currentTime - startTime));
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest_app.properties?rev=431395&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest_app.properties
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest_app.properties
Mon Aug 14 11:17:57 2006
@@ -0,0 +1,4 @@
+supportfiles=tests/perf/existingDb.jar
+# Need to unjar an existing database, need access to file system and user.dir
+# system property
+noSecurityManager=true
\ No newline at end of file

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupExistingDBTest_app.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java?rev=431395&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java
Mon Aug 14 11:17:57 2006
@@ -0,0 +1,70 @@
+/*
+ 
+   Derby - Class org.apache.derbyTesting.functionTests.test.perf.StartupTest
+ 
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+ 
+     http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+ */
+
+package org.apache.derbyTesting.functionTests.tests.perf;
+
+import org.apache.derbyTesting.functionTests.util.BaseJDBCTestCase;
+
+import java.sql.*;
+
+/**
+ * This test test the timing of starting up Derby.  It tries to divide the
+ * total time up into reasonable chunks.  It's written as a JUnit test but
+ * really can't be automated because the timings are so dependent upon
+ * the exact hardware, operating system and software environment the test
+ * is running in.  I just use JUnit because of the convenient framework
+ * it gives me...
+ */
+public class StartupNewDBTest extends BaseJDBCTestCase {
+    public StartupNewDBTest(String name) {
+        super(name);
+    }
+    
+    public void testNewDB() throws Exception {
+        long startTime = System.currentTimeMillis();
+        System.out.println("Testing startup with a NEW database... " +
+            "All measurements are in milliseconds.");
+        
+        // Load the driver
+        Class driver = Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+        long currentTime = System.currentTimeMillis();
+        System.out.println("Loading driver:  " + (currentTime - startTime));
+        
+        // Create a database                
+        startTime = System.currentTimeMillis();
+        Connection conn = 
+            DriverManager.getConnection("jdbc:derby:newdb;create=true");
+        currentTime = System.currentTimeMillis();
+        System.out.println("Open connection with creating new database:  " 
+            + (currentTime - startTime));
+                
+        // Create a table
+        startTime = System.currentTimeMillis();
+        Statement stmt = conn.createStatement();
+        stmt.execute("CREATE TABLE test_table(id integer primary key, " +
+            "last_name varchar(80), first_name varchar(80), " +
+            "mi char(1), address varchar(100), city varchar(80))");
+        currentTime = System.currentTimeMillis();
+        System.out.println("Creating a table:  " 
+            + (currentTime - startTime));
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/StartupNewDBTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/build.xml?rev=431395&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/build.xml
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/build.xml
Mon Aug 14 11:17:57 2006
@@ -0,0 +1,102 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to you under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- ==================================================================== -->
+<!--                       Derby build file                          -->
+<!-- ==================================================================== -->
+
+<project default="FTOtestsubdir" basedir="../../../../../../../.." >
+
+<!-- ==================================================================== -->
+<!--                           Set properties                             -->
+<!-- ==================================================================== -->
+
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+
+  <!-- Set property lib dir -->
+  <property name="properties.dir" value="tools/ant/properties" />
+
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+  <property file="${properties.dir}/derbytesting.properties"/>
+
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/sane${sanity}.properties"/>
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+
+  <!-- Parser properties -->
+  <!--property file="${properties.dir}/parser.properties"/-->
+
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+
+  <!-- Release and Version info -->
+  <property file="${properties.dir}/release.properties"/>
+
+  <!-- derby testing specific properties files -->
+  <property file="${ant.home}/properties/derbytesting.properties"/>
+  <property file="${user.home}/properties/derbytesting.properties"/>
+  <property name="this.dir" value="${derby.testing.functest.dir}/tests/perf"/>
+
+<!--             ============ Begin Targets ==============                -->
+ 
+  <target name="FTOtestsubdir" depends="compile,copyfiles"/>
+
+  <!-- mkdir / init target should not be necessary, just here for reference... -->
+  <target name="init">
+    <mkdir dir="${out.dir}/${derby.testing.functest.dir}/tests/perf"/>
+  </target>
+
+  <target name="compile">
+    <javac
+      source="1.4"
+      target="1.4"
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="${debug}"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}" 
+      srcdir="${derby.testing.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+        <!--pathelement location="${oro}"/-->
+        <pathelement path="${compile.classpath}"/>
+        <pathelement path="${junit}"/>
+      </classpath>
+      <include name="${this.dir}/*.java"/>
+    </javac>
+  </target>
+    <target name="copyfiles">
+    <copy todir="${out.dir}/${derby.testing.functest.dir}/tests/perf">
+      <fileset dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/perf"

+        includesfile="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/perf/copyfiles.ant"/>
 
+    </copy>
+  </target> 
+
+<!--             ============= End Targets ==============                -->
+
+<!--             ============= End Project ==============                -->
+
+</project>
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/copyfiles.ant
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/copyfiles.ant?rev=431395&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/copyfiles.ant
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/copyfiles.ant
Mon Aug 14 11:17:57 2006
@@ -0,0 +1,2 @@
+StartupExistingDBTest_app.properties
+existingDb.jar

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/existingDb.jar
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/existingDb.jar?rev=431395&view=auto
==============================================================================
Binary file - no diff available.

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/perf/existingDb.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/JarUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/JarUtil.java?rev=431395&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/JarUtil.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/JarUtil.java
Mon Aug 14 11:17:57 2006
@@ -0,0 +1,73 @@
+/*
+ 
+   Derby - Class org.apache.derbyTesting.functionTests.util.JartUtil
+ 
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+ 
+     http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.
+ */
+
+package org.apache.derbyTesting.functionTests.util;
+import java.io.*;
+
+
+/**
+ *
+ * <Put Class Comments Here>
+ */
+public class JarUtil {
+
+    /** 
+     * Unjar a file into the specified directory.  This runs in a separate
+     * process.  Note, your test needs security permissions to read user.dir
+     * and to start a process for this to work.
+     * 
+     * @param jarpath - Path to jar file
+     *
+     * @param outputdir - The directory to unjar to.  If this is null,
+     *    we user user.dir (the current directory)
+     *
+     */
+    public static void unjar(String jarpath, String outputdir)
+        throws ClassNotFoundException, IOException, InterruptedException
+    {                
+        if ( outputdir == null ) {
+            outputdir = System.getProperty("user.dir");
+        }
+        File jarFile = new File((new File(outputdir, jarpath)).getCanonicalPath());
+
+        // Now unjar the file
+        String jarCmd = "jar xf " + jarFile.getPath();
+        // Now execute the jar command
+        Process pr = null;
+        try
+        {
+            //System.out.println("Use process to execute: " + jarCmd);
+            pr = Runtime.getRuntime().exec(jarCmd);
+
+            pr.waitFor();
+            //System.out.println("Process done.");
+            pr.destroy();
+        }
+        finally {
+            if (pr != null)
+            {
+                pr.destroy();
+                pr = null;
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/JarUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message