List:Commits« Previous MessageNext Message »
From:Jorgen Austvik Date:November 26 2009 8:42pm
Subject:bzr push into mysql-5.1-telco-6.3-ndbjtie branch (jorgen.austvik:3144
to 3145)
View as plain text  
 3145 Jorgen Austvik	2009-11-26
      Add MTR test for cluster/J

    added:
      mysql-test/include/have_connectorj.inc
      mysql-test/include/have_junit.inc
      mysql-test/include/run_java.inc
      mysql-test/suite/ndb/include/have_clusterj.inc
      mysql-test/suite/ndb/t/clusterj.test
      storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/AllTests.java
    modified:
      mysql-test/include/default_ndbd.cnf
      mysql-test/include/run_junit.inc
      mysql-test/suite/ndb/t/ndb_jtie.test
      storage/ndb/clusterj/clusterj-test/Makefile.am
 3144 Bernhard Ocklin	2009-11-26
      remove explicit ndbclient load from test

    modified:
      storage/ndb/ndbjtie/test/test/NdbJTieSmokeTest.java
=== modified file 'mysql-test/include/default_ndbd.cnf'
--- a/mysql-test/include/default_ndbd.cnf	2009-02-27 13:42:00 +0000
+++ b/mysql-test/include/default_ndbd.cnf	2009-11-26 20:41:49 +0000
@@ -4,10 +4,10 @@ MaxNoOfSavedMessages=          1000
 MaxNoOfConcurrentTransactions= 2048
 MaxNoOfConcurrentOperations=   10000
 DataMemory=                    20M
-IndexMemory=                   1M
+IndexMemory=                   3M
 Diskless=                      0
 TimeBetweenWatchDogCheck=      30000
-MaxNoOfOrderedIndexes=         32
+MaxNoOfOrderedIndexes=         128
 MaxNoOfAttributes=             2048
 TimeBetweenGlobalCheckpoints=  3000
 TimeBetweenEpochs=             100

=== added file 'mysql-test/include/have_connectorj.inc'
--- a/mysql-test/include/have_connectorj.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/have_connectorj.inc	2009-11-26 20:41:49 +0000
@@ -0,0 +1,26 @@
+--perl
+use strict;
+use IO::File;
+
+#
+# Looks for MySQL Connector/J JAR file
+# - MTR_CONNECTOR_J environment variable
+#
+# If Connector/J JAR file is found, CONNECTORJ_JAR will be set to reflect this location
+#
+
+my $connectorj_jar = $ENV{'MTR_CONNECTORJ_JAR'};
+
+my $vardir = $ENV{MYSQLTEST_VARDIR} or die "Need MYSQLTEST_VARDIR";
+my $F = IO::File->new("$vardir/tmp/have_connectorj_result.inc", "w") or die;
+if ($connectorj_jar eq '') {
+  print $F "--skip Could not find Connector/J JAR file, please set MTR_CONNECTORJ_JAR env variable\n";
+} else {
+  print $F "--let \$CONNECTORJ_JAR= $connectorj_jar\n";
+  print $F "--echo Found Connector/J JAR: '\$CONNECTORJ_JAR'\n";
+}
+$F->close();
+
+EOF
+
+--source $MYSQLTEST_VARDIR/tmp/have_connectorj_result.inc

=== added file 'mysql-test/include/have_junit.inc'
--- a/mysql-test/include/have_junit.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/have_junit.inc	2009-11-26 20:41:49 +0000
@@ -0,0 +1,26 @@
+--perl
+use strict;
+use IO::File;
+
+#
+# Looks for JUnit JAR file
+# - MTR_JUNIT_JAR environment variable
+#
+# If jar file is found, JUNIT_JAR will be set to reflect this location.
+#
+
+my $junit_jar = $ENV{'MTR_JUNIT_JAR'};
+
+my $vardir = $ENV{MYSQLTEST_VARDIR} or die "Need MYSQLTEST_VARDIR";
+my $F = IO::File->new("$vardir/tmp/have_junit_result.inc", "w") or die;
+if ($junit_jar eq '') {
+  print $F "--skip Could not find JUnit JAR file, please set MTR_JUNIT_JAR env variable\n";
+} else {
+  print $F "--let \$JUNIT_JAR= $junit_jar\n";
+  print $F "--echo Found JUnit JAR: '\$JUNIT_JAR'\n";
+}
+$F->close();
+
+EOF
+
+--source $MYSQLTEST_VARDIR/tmp/have_junit_result.inc

=== added file 'mysql-test/include/run_java.inc'
--- a/mysql-test/include/run_java.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/run_java.inc	2009-11-26 20:41:49 +0000
@@ -0,0 +1,30 @@
+##
+## run_java.inc - include script to run Java
+##
+## Parameters
+##   $MTR_JAVA: Java which should be used
+##   $JAVA_CLASS: Class file to run
+##   $JAVA_CLASSPATH: Class path to use when running test
+##   $JAVA_JVM_OPTS: Optional parameters to the JVM
+##
+##
+## Usage:
+##
+## --source include/have_java.inc
+##
+## let $JAVA_CLASSPATH=.:/some/path;
+## let $JAVA_JVM_OPTS=-Dsome.setting=123 -ea -Xcheck:jni;
+##
+## let $JAVA_CLASS=test/SomeTest.class;
+## --source include/run_java.inc
+##
+## let $JAVA_CLASS=test/SomeOtherTest.class;
+## --source include/run_java.inc
+##
+
+--let $COMMAND= $MTR_JAVA
+--let $COMMAND= $COMMAND $JAVA_JVM_OPTS
+--let $COMMAND= $COMMAND -classpath $JAVA_CLASSPATH
+--let $COMMAND= $COMMAND $JAVA_CLASS $JAVA_ARGUMENTS
+
+--exec $COMMAND 2>&1

=== modified file 'mysql-test/include/run_junit.inc'
--- a/mysql-test/include/run_junit.inc	2009-11-17 11:20:11 +0000
+++ b/mysql-test/include/run_junit.inc	2009-11-26 20:41:49 +0000
@@ -21,10 +21,10 @@
 ## let $JUNIT_CLASS=test/SomeOtherTest.class;
 ## --source include/run_junit.inc
 ##
-
+--let $RUNNER=org.junit.runner.JUnitCore
 --let $COMMAND= $MTR_JAVA
 --let $COMMAND= $COMMAND $JUNIT_JVM_OPTS
 --let $COMMAND= $COMMAND -classpath $JUNIT_CLASSPATH
---let $COMMAND= $COMMAND $JUNIT_CLASS
+--let $COMMAND= $COMMAND $RUNNER $JUNIT_CLASS
 
 --exec $COMMAND 2>&1

=== added file 'mysql-test/suite/ndb/include/have_clusterj.inc'
--- a/mysql-test/suite/ndb/include/have_clusterj.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/include/have_clusterj.inc	2009-11-26 20:41:49 +0000
@@ -0,0 +1,72 @@
+--perl
+use strict;
+
+use File::Basename;
+use IO::File;
+use lib "lib/";
+use My::Find;
+
+#
+# Look for Cluster/J library, if not found: skip test.
+#
+
+#
+# Set up paths
+#
+my $vardir = $ENV{MYSQLTEST_VARDIR} or die "Need MYSQLTEST_VARDIR";
+my $mysql_test_dir = $ENV{MYSQL_TEST_DIR} or die "Need MYSQL_TEST_DIR";
+my $basedir = dirname($mysql_test_dir);
+
+#
+# Check if the needed jars are available
+#
+my $clusterj_jar = my_find_file($basedir,
+                                ["storage/ndb/clusterj", "share/mysql/java"],
+                                "mysql-cluster-connector-j.jar", NOT_REQUIRED);
+
+my $clusterj_test_jar = my_find_file($basedir,
+                                    ["storage/ndb/clusterj/clusterj-test", "share/mysql/java"],
+                                    "clusterj-test.jar", NOT_REQUIRED);
+
+my $F = IO::File->new("$vardir/tmp/have_clusterj_result.inc", 'w') or die;
+if ($clusterj_jar) {
+  write_properties();
+  print $F "--let \$CLUSTERJ_JAR= $clusterj_jar\n"; 
+  print $F "--let \$CLUSTERJ_TEST_JAR= $clusterj_test_jar\n"; 
+  print $F "--echo Found clusterj.jar: '\$CLUSTERJ_JAR'\n"
+} else {
+  print $F "skip Could not find NDB JTie jar file\n";
+}
+$F->close();
+
+sub add {
+   my $F = shift;
+   my $prop = shift;
+   my $val = shift;
+   print $F "com.mysql.clusterj.$prop=$val\n";
+}
+
+sub write_properties {
+  my $db = 'test';
+  my $user = 'root';
+  my $F = IO::File->new("$vardir/tmp/clusterj.properties", 'w') or die;
+  add($F, 'connectstring', $ENV{'NDB_CONNECTSTRING'});
+  add($F, 'connect.retries', '4');
+  add($F, 'connect.delay', '5');
+  add($F, 'connect.verbose', '1');
+  add($F, 'connect.timeout.before', '30');
+  add($F, 'connect.timeout.after', '20');
+  add($F, 'jdbc.url', "jdbc:mysql://localhost:$ENV{MASTER_MYPORT}/$db");
+  add($F, 'jdbc.driver', 'com.mysql.jdbc.Driver');
+  add($F, 'jdbc.username', $user);
+  add($F, 'jdbc.password', '');
+  add($F, 'username', '');
+  add($F, 'password', '');
+  add($F, 'database', $db);
+  add($F, 'max.transactions', '1024');
+  $F->close();
+}
+
+EOF
+
+--source $MYSQLTEST_VARDIR/tmp/have_clusterj_result.inc

=== added file 'mysql-test/suite/ndb/t/clusterj.test'
--- a/mysql-test/suite/ndb/t/clusterj.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/t/clusterj.test	2009-11-26 20:41:49 +0000
@@ -0,0 +1,46 @@
+#
+# Run the Cluster/J JUnit tests from MTR
+#
+--source include/have_ndb.inc
+--source include/have_java.inc
+--source include/have_connectorj.inc
+--source include/have_junit.inc
+--source suite/ndb/include/have_ndbjtie.inc
+--source suite/clusterj/have_clusterj.inc
+
+--let $JAVA_CLASSPATH=$CLUSTERJ_TEST_JAR:$CLUSTERJ_JAR:$CONNECTORJ_JAR:$NDBJTIE_JAR:$JUNIT_JAR
+--let $JAVA_JVM_OPTS= -ea -Xcheck:jni -Dclusterj.properties=$MYSQLTEST_VARDIR/tmp/clusterj.properties
+--let $JAVA_JVM_OPTS= $JAVA_JVM_OPTS -Djava.library.path="$NDBCLIENT_LIB_DIR:$NDBJTIE_LIB_DIR"
+--let $JAVA_CLASS= testsuite.clusterj.AllTests
+--let $JAVA_ARGUMENTS= $CLUSTERJ_TEST_JAR
+
+--source include/run_java.inc
+
+--echo Clean up tables used in the JUnit tests.
+DROP TABLE a;
+DROP TABLE allprimitives;
+DROP TABLE b0;
+DROP TABLE binarytypes;
+DROP TABLE bittypes;
+DROP TABLE blobtypes;
+DROP TABLE bytestype;
+DROP TABLE charsetlatin1;
+DROP TABLE charsetutf8;
+DROP TABLE datetimetypes;
+DROP TABLE datetypes;
+DROP TABLE decimaltypes;
+DROP TABLE dn2id;
+DROP TABLE doubletypes;
+DROP TABLE floattypes;
+DROP TABLE longintstringfk;
+DROP TABLE longintstringpk;
+DROP TABLE longlongstringfk;
+DROP TABLE longlongstringpk;
+DROP TABLE nullvalues;
+DROP TABLE stringtype;
+DROP TABLE t_basic;
+DROP TABLE timestamptypes;
+DROP TABLE timetypes;
+DROP TABLE yeartypes;
+
+exit;
\ No newline at end of file

=== modified file 'mysql-test/suite/ndb/t/ndb_jtie.test'
--- a/mysql-test/suite/ndb/t/ndb_jtie.test	2009-11-10 09:19:08 +0000
+++ b/mysql-test/suite/ndb/t/ndb_jtie.test	2009-11-26 20:41:49 +0000
@@ -10,14 +10,14 @@
 --let $JUNIT_JVM_OPTS= -ea -Xcheck:jni -Djtie.unit.ndb.connectstring=$NDB_CONNECTSTRING
 --let $JUNIT_JVM_OPTS= $JUNIT_JVM_OPTS -Djava.library.path="$NDBCLIENT_LIB_DIR:$NDBJTIE_LIB_DIR"
 
---let JUNIT_CLASS=test.NdbJTieSmokeTest
---source include/run_junit.inc
+--let JAVA_CLASS=test.NdbJTieSmokeTest
+--source include/run_java.inc
 
 --let $JUNIT_JVM_OPTS= $JUNIT_JVM_OPTS -Dcom.mysql.jtie.test.MyLoadUnloadTest.target_package_prefixes="test.,com.mysql.ndbjtie."
 --let $JUNIT_JVM_OPTS= $JUNIT_JVM_OPTS -Dcom.mysql.jtie.test.MyLoadUnloadTest.target_class_name="test.NdbJTieSmokeTest"
 --let $JUNIT_JVM_OPTS= $JUNIT_JVM_OPTS -Dcom.mysql.jtie.test.MyLoadUnloadTest.target_method_name="test"
 
---let JUNIT_CLASS=test.MyLoadUnloadTest
---source include/run_junit.inc
+--let JAVA_CLASS=test.MyLoadUnloadTest
+--source include/run_java.inc
 
 exit;
\ No newline at end of file

=== modified file 'storage/ndb/clusterj/clusterj-test/Makefile.am'
--- a/storage/ndb/clusterj/clusterj-test/Makefile.am	2009-11-18 10:21:55 +0000
+++ b/storage/ndb/clusterj/clusterj-test/Makefile.am	2009-11-26 20:41:49 +0000
@@ -32,6 +32,7 @@ clusterj_test_jar = clusterj-test.jar
 clusterj_test_DATA = $(clusterj_test_jar) 
 
 clusterj_test_classes = \
+  $(clusterj_test_src)/testsuite/clusterj/AllTests.class \
   $(clusterj_test_src)/testsuite/clusterj/AbstractClusterJModelTest.class \
   $(clusterj_test_src)/testsuite/clusterj/AbstractClusterJTest.class \
   $(clusterj_test_src)/testsuite/clusterj/AbstractQueryTest.class \

=== added file 'storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/AllTests.java'
--- a/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/AllTests.java	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/AllTests.java	2009-11-26 20:41:49 +0000
@@ -0,0 +1,100 @@
+package testsuite.clusterj;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+/**
+ * Run all JUnit tests in a jar file.
+ */
+public class AllTests {
+
+    private static String jarFile = "";
+
+    private static void usage() {
+        System.out.println("Usage: java -cp <jar file>:... AllTests <jar file>");
+        System.out.println("Will run all tests in the given jar file.");
+        System.exit(2);
+    }
+
+    private static boolean isPossibleTestClass(String fileName) {
+        return fileName.endsWith("Test.class");
+    }
+
+    private static boolean isTestClass(Class klass) {
+        // TODO: Could check if klass inherits junit.framework.Test in some way,
+        //       but this will also be cought in the cast later
+        return klass.getName().endsWith("Test")
+            && !klass.getName().contains("Abstract");
+    }
+
+    private static List<Class> getClasses(File jarFile) throws IOException, ClassNotFoundException {
+        List<Class> classes = new ArrayList<Class>();
+
+        JarInputStream jarStream = new JarInputStream(new FileInputStream(jarFile));
+        try {
+            JarEntry jarEntry = jarStream.getNextJarEntry();
+            while (jarEntry != null) {
+                try {
+                    String fileName = jarEntry.getName();
+                    if (isPossibleTestClass(fileName)) {
+                        String className = fileName.replaceAll("/", "\\.");
+                        className = className.substring(0, className.length() - ".class".length());
+                        // System.out.println("Found possible test class: '" + className + "'");
+                        Class testClass = Class.forName(className);
+                        classes.add(testClass);
+                    }
+                } finally {
+                    jarStream.closeEntry();
+                }
+                jarEntry = jarStream.getNextJarEntry();
+            }
+        } finally {
+            jarStream.close();
+        }
+
+        return classes;
+    }
+
+    public static Test suite() throws IllegalAccessException, IOException, ClassNotFoundException {
+        TestSuite suite = new TestSuite("Cluster/J");
+
+        if (jarFile.equals("")) {
+            throw new IOException("Jar file to look for not given");
+        }
+
+        List<Class> classes = getClasses(new File(jarFile));
+        for (Class klass : classes) {
+	    if (isTestClass(klass)) {
+		suite.addTestSuite(klass);
+	    }
+        }
+        return suite;
+    }
+
+    /**
+     * Usage: java -cp ... AllTests file.jar
+     *
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception {
+        if (args.length == 1) {
+            jarFile = args[0];
+            System.out.println("Running all tests in '" + jarFile + "'");
+	    TestSuite suite = (TestSuite) suite();
+            System.out.println("Found '" + suite.testCount() + "' tests in jar file.");
+            TestResult res = junit.textui.TestRunner.run(suite);
+            System.exit(res.wasSuccessful() ? 0 : 1);
+        } else {
+            usage();
+        }
+    }
+}


Attachment: [text/bzr-bundle] bzr/jorgen.austvik@sun.com-20091126204149-ady008adu7zbjecb.bundle
Thread
bzr push into mysql-5.1-telco-6.3-ndbjtie branch (jorgen.austvik:3144to 3145)Jorgen Austvik26 Nov