From: magnus.blaudd Date: April 16 2012 10:42am Subject: bzr push into mysql-5.5-cluster-7.3 branch (magnus.blaudd:3881 to 3882) List-Archive: http://lists.mysql.com/commits/143583 Message-Id: <201204161042.q3GAgh14015795@acsmt357.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3882 magnus.blaudd@stripped 2012-04-16 [merge] Merge 7.2 -> 7.3 added: mysql-test/suite/ndb_memcache/r/math3.result mysql-test/suite/ndb_memcache/t/math3.test storage/ndb/clusterj/clusterj-unit/ storage/ndb/clusterj/clusterj-unit/pom.xml storage/ndb/clusterj/clusterj-unit/src/ storage/ndb/clusterj/clusterj-unit/src/main/ storage/ndb/clusterj/clusterj-unit/src/main/java/ storage/ndb/clusterj/clusterj-unit/src/main/java/junit/ storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/ storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/AssertionFailedError.java storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/Test.java storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestCase.java storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestListener.java storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestResult.java storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestSuite.java storage/ndb/clusterj/clusterj-unit/src/main/java/junit/textui/ storage/ndb/clusterj/clusterj-unit/src/main/java/junit/textui/TestRunner.java storage/ndb/clusterj/clusterj-unit/src/main/java/org/ storage/ndb/clusterj/clusterj-unit/src/main/java/org/junit/ storage/ndb/clusterj/clusterj-unit/src/main/java/org/junit/Ignore.java storage/ndb/memcache/unit/sequence.pl modified: mysql-test/lib/My/Memcache.pm storage/ndb/clusterj/clusterj-api/pom.xml storage/ndb/clusterj/clusterj-core/pom.xml storage/ndb/clusterj/clusterj-jdbc/pom.xml storage/ndb/clusterj/clusterj-jpatest/pom.xml storage/ndb/clusterj/clusterj-openjpa/pom.xml storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/OneToManyRelationshipTest.java storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/TestBadPersistenceUnitNoConnectString.java storage/ndb/clusterj/clusterj-test/pom.xml storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/AbstractQueryTest.java storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/QueryMultiColumnIndexInTest.java storage/ndb/clusterj/clusterj-tie/pom.xml storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/ConnectionPoolTest.java storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/StressTest.java storage/ndb/clusterj/pom.xml storage/ndb/memcache/include/QueryPlan.h storage/ndb/memcache/src/Record.cc storage/ndb/memcache/src/ndb_worker.cc storage/ndb/src/mgmsrv/ConfigInfo.cpp 3881 magnus.blaudd@stripped 2012-04-13 [merge] Merge 7.2 -> 7.3 modified: storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/DeleteAllByClassTest.java storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/ObjectNotFoundTest.java storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/QueryExplainTest.java === modified file 'mysql-test/lib/My/Memcache.pm' --- a/mysql-test/lib/My/Memcache.pm 2011-12-11 01:09:34 +0000 +++ b/mysql-test/lib/My/Memcache.pm 2012-04-14 00:53:04 +0000 @@ -34,7 +34,9 @@ ### $mc->delete(key) returns 1 on success, 0 on failure ### $mc->stats(stat_key) get stats; returns a hash ### $mc->incr(key, amount) returns the new value or undef -### $mc->decr(key, amount) like incr +### $mc->decr(key, amount) like incr. (Note: In the Binary protocol +### only, incr and decr can take a 3rd +### argument, the initial value). ### $mc->flush() flush_all ### ### $mc->set_expires(sec) Set TTL for all store operations @@ -461,7 +463,11 @@ sub get_binary_response { sub bin_math { my $self = shift; - my ($cmd, $key, $delta, $initial, $expires) = @_; + my ($cmd, $key, $delta, $initial) = @_; + my $expires = 0xffffffff; # 0xffffffff means the create flag is NOT set + if(defined($initial)) { $expires = $self->{exptime}; } + else { $initial = 0; } + my $value = undef; my $extra_header = pack "NNNNN", ($delta / (2 ** 32)), # delta hi @@ -469,9 +475,14 @@ sub bin_math { ($initial / (2 ** 32)), # initial hi ($initial % (2 ** 32)), # initial lo $expires; - $self->send_binary_request($cmd, $key, '', $extra_header); - my ($status, $value) = $self->get_binary_response(); - return ($status == 0) ? $value : undef; + $self->send_binary_request($cmd, $key, '', $extra_header); + + my ($status, $packed_val) = $self->get_binary_response(); + if($status == 0) { + my ($val_hi, $val_lo) = unpack("NN", $packed_val); + $value = ($val_hi * (2 ** 32)) + $val_lo; + } + return $value; } @@ -558,13 +569,13 @@ sub delete { } sub incr { - my ($self, $key, $delta) = @_; - return $self->bin_math(BIN_CMD_INCR, $key, $delta, 0, 0xffffffff); + my ($self, $key, $delta, $initial) = @_; + return $self->bin_math(BIN_CMD_INCR, $key, $delta, $initial); } sub decr { - my ($self, $key, $delta) = @_; - return $self->bin_math(BIN_CMD_DECR, $key, $delta, 0, 0xffffffff); + my ($self, $key, $delta, $initial) = @_; + return $self->bin_math(BIN_CMD_DECR, $key, $delta, $initial); } === added file 'mysql-test/suite/ndb_memcache/r/math3.result' --- a/mysql-test/suite/ndb_memcache/r/math3.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/ndb_memcache/r/math3.result 2012-04-14 00:53:04 +0000 @@ -0,0 +1,6 @@ +SELECT mkey, math_value +FROM ndbmemcache.demo_table where mkey like 'math_test_3%' +ORDER BY mkey; +mkey math_value +math_test_3a 1506 +math_test_3b 0 === added file 'mysql-test/suite/ndb_memcache/t/math3.test' --- a/mysql-test/suite/ndb_memcache/t/math3.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/ndb_memcache/t/math3.test 2012-04-14 00:53:04 +0000 @@ -0,0 +1,44 @@ + +--source suite/ndb_memcache/include/have_memcache.inc + + +# Test INCR and DECR with binary protocol + +--perl + +use strict; +use lib "lib/"; +use My::Memcache; + +my $mc = My::Memcache::Binary->new(); +my $port = $ENV{MTR_BUILD_THREAD} * 10 + 10000 + 8; + +my $r = $mc->connect("localhost",$port); + +if($r == 0) { + print STDERR "DID NOT CONNECT TO MEMCACHE AT PORT $port \n"; +} +else { + my $r; + $r = $mc->incr("math_test_3a", 1, 1500); # initialize at 1500 + ($r == 1500) || Carp::confess("wrong result"); + + $r = $mc->incr("math_test_3a", 6); # increment to 1506 + ($r == 1506) || Carp::confess("wrong result"); + + $r = $mc->decr("math_test_3b", 1, 1); # initialize at 1 + ($r == 1) || Carp::confess("wrong result"); + + $r = $mc->decr("math_test_3b", 1); # decr to 0 + ($r == 0) || Carp::confess("wrong result"); + + $r = $mc->decr("math_test_3b", 1); # should not wrap below 0. + ($r == 0) || Carp::confess("wrong result"); +} + +EOF + +SELECT mkey, math_value +FROM ndbmemcache.demo_table where mkey like 'math_test_3%' +ORDER BY mkey; + === modified file 'storage/ndb/clusterj/clusterj-api/pom.xml' --- a/storage/ndb/clusterj/clusterj-api/pom.xml 2012-03-29 17:42:19 +0000 +++ b/storage/ndb/clusterj/clusterj-api/pom.xml 2012-04-15 03:45:31 +0000 @@ -53,13 +53,6 @@ - - - junit - junit - test - - false === modified file 'storage/ndb/clusterj/clusterj-core/pom.xml' --- a/storage/ndb/clusterj/clusterj-core/pom.xml 2012-03-29 17:42:19 +0000 +++ b/storage/ndb/clusterj/clusterj-core/pom.xml 2012-04-15 03:45:31 +0000 @@ -96,8 +96,8 @@ compile - junit - junit + com.mysql.clusterj + clusterj-unit test === modified file 'storage/ndb/clusterj/clusterj-jdbc/pom.xml' --- a/storage/ndb/clusterj/clusterj-jdbc/pom.xml 2012-03-29 17:42:19 +0000 +++ b/storage/ndb/clusterj/clusterj-jdbc/pom.xml 2012-04-15 03:45:31 +0000 @@ -28,8 +28,8 @@ 7.1.22-SNAPSHOT - junit - junit + com.mysql.clusterj + clusterj-unit test === modified file 'storage/ndb/clusterj/clusterj-jpatest/pom.xml' --- a/storage/ndb/clusterj/clusterj-jpatest/pom.xml 2012-03-29 17:42:19 +0000 +++ b/storage/ndb/clusterj/clusterj-jpatest/pom.xml 2012-04-15 03:45:31 +0000 @@ -107,8 +107,8 @@ openjpa - junit - junit + com.mysql.clusterj + clusterj-unit compile === modified file 'storage/ndb/clusterj/clusterj-openjpa/pom.xml' --- a/storage/ndb/clusterj/clusterj-openjpa/pom.xml 2012-03-29 17:42:19 +0000 +++ b/storage/ndb/clusterj/clusterj-openjpa/pom.xml 2012-04-15 03:45:31 +0000 @@ -129,6 +129,11 @@ com.mysql.clusterj + clusterj-unit + test + + + com.mysql.clusterj clusterj-api compile === modified file 'storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/OneToManyRelationshipTest.java' --- a/storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/OneToManyRelationshipTest.java 2011-07-05 12:46:07 +0000 +++ b/storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/OneToManyRelationshipTest.java 2012-04-16 10:34:32 +0000 @@ -125,16 +125,16 @@ public class OneToManyRelationshipTest e B0 b = em.find(B0.class, i); print(b.toString()); if (0 == i%2) { - assertEquals("Mismatch in relationship a", as.get(0), b.getA()); - assertTrue("A.b0s should contain b", as.get(0).getB0s().contains(b)); + errorIfNotEqual("Mismatch in relationship a", as.get(0), b.getA()); + errorIfNotEqual("A.b0s should contain b", true, as.get(0).getB0s().contains(b)); } else { - assertEquals("Mismatch in relationship a", as.get(1), b.getA()); - assertTrue("A.b0s should contain b", as.get(1).getB0s().contains(b)); + errorIfNotEqual("Mismatch in relationship a", as.get(1), b.getA()); + errorIfNotEqual("A.b0s should contain b", true, as.get(1).getB0s().contains(b)); } } commit(); em.close(); - + failOnError(); } private void print(String string) { === modified file 'storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/TestBadPersistenceUnitNoConnectString.java' --- a/storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/TestBadPersistenceUnitNoConnectString.java 2011-07-05 12:46:07 +0000 +++ b/storage/ndb/clusterj/clusterj-openjpa/src/test/java/com/mysql/clusterj/openjpatest/TestBadPersistenceUnitNoConnectString.java 2012-04-16 10:34:32 +0000 @@ -36,7 +36,10 @@ public class TestBadPersistenceUnitNoCon EntityManagerFactory emf = Persistence.createEntityManagerFactory( getPersistenceUnitName()); emf.createEntityManager(); - assertNull("Unexpected emf for null connectString", emf); + if(emf != null) { + fail("Unexpected emf for null connectString"); + } + } catch (RuntimeException ex) { // see if it has the connectString message if (!(ex.getMessage().contains("connectString"))) { === modified file 'storage/ndb/clusterj/clusterj-test/pom.xml' --- a/storage/ndb/clusterj/clusterj-test/pom.xml 2012-03-29 17:42:19 +0000 +++ b/storage/ndb/clusterj/clusterj-test/pom.xml 2012-04-15 03:45:31 +0000 @@ -102,8 +102,8 @@ clusterj-core - junit - junit + com.mysql.clusterj + clusterj-unit compile === modified file 'storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/AbstractQueryTest.java' --- a/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/AbstractQueryTest.java 2011-10-02 21:20:50 +0000 +++ b/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/AbstractQueryTest.java 2012-04-15 03:43:47 +0000 @@ -457,6 +457,11 @@ abstract public class AbstractQueryTest public void inQuery(String propertyName, Object parameterValue1, String expectedIndex, int... expected) { + inQuery("", propertyName, parameterValue1, expectedIndex, expected); + } + + public void inQuery(String extraInfo, String propertyName, Object parameterValue1, + String expectedIndex, int... expected) { tx.begin(); QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); // specify the where clause @@ -467,7 +472,7 @@ abstract public class AbstractQueryTest holder.setParameterIn(parameterValue1); // get the results holder.setExpectedResultIds(expected); - holder.checkResults(propertyName + " in"); + holder.checkResults(extraInfo + propertyName + " in"); tx.commit(); } === modified file 'storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/QueryMultiColumnIndexInTest.java' --- a/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/QueryMultiColumnIndexInTest.java 2012-04-04 06:46:06 +0000 +++ b/storage/ndb/clusterj/clusterj-test/src/main/java/testsuite/clusterj/QueryMultiColumnIndexInTest.java 2012-04-15 03:43:47 +0000 @@ -30,6 +30,7 @@ import testsuite.clusterj.model.LongIntS * This test is based on AbstractQueryTest. */ public class QueryMultiColumnIndexInTest extends AbstractQueryTest { + /* drop table if exists longintstringix; create table longintstringix ( @@ -49,6 +50,9 @@ create table longintstringix ( return LongIntStringIndex.class; } + /** The number of iterations of the multi-range IN test */ + private static final int MULTI_RANGE_IN_ITERATIONS = 1; + protected int PK_MODULUS = 3; protected long PRETTY_BIG_NUMBER = 1000000000000000L; @@ -103,13 +107,15 @@ create table longintstringix ( } public void testPrettyBigIn() { - int arraySize = 20; + int arraySize = 4096; Integer[] keys = new Integer[arraySize]; for (int i = 0; i < arraySize; ++i) { keys[i] = i; } int[] expectedKeys = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - inQuery("id", keys, "PRIMARY", expectedKeys); + for (int i = 0; i < MULTI_RANGE_IN_ITERATIONS; ++i) { + inQuery("iteration " + Integer.toString(i) + " ", "id", keys, "PRIMARY", expectedKeys); + } failOnError(); } === modified file 'storage/ndb/clusterj/clusterj-tie/pom.xml' --- a/storage/ndb/clusterj/clusterj-tie/pom.xml 2012-03-29 17:42:19 +0000 +++ b/storage/ndb/clusterj/clusterj-tie/pom.xml 2012-04-15 03:45:31 +0000 @@ -141,8 +141,8 @@ compile - junit - junit + com.mysql.clusterj + clusterj-unit test === modified file 'storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/ConnectionPoolTest.java' --- a/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/ConnectionPoolTest.java 2012-03-05 22:28:15 +0000 +++ b/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/ConnectionPoolTest.java 2012-04-15 03:42:07 +0000 @@ -17,8 +17,7 @@ package testsuite.clusterj.tie; -import org.junit.Ignore; - +@stripped public class ConnectionPoolTest extends testsuite.clusterj.ConnectionPoolTest { } === modified file 'storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/StressTest.java' --- a/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/StressTest.java 2012-02-08 17:27:45 +0000 +++ b/storage/ndb/clusterj/clusterj-tie/src/test/java/testsuite/clusterj/tie/StressTest.java 2012-04-15 03:42:07 +0000 @@ -17,6 +17,7 @@ package testsuite.clusterj.tie; +@stripped public class StressTest extends testsuite.clusterj.StressTest { } === added directory 'storage/ndb/clusterj/clusterj-unit' === added file 'storage/ndb/clusterj/clusterj-unit/pom.xml' --- a/storage/ndb/clusterj/clusterj-unit/pom.xml 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-unit/pom.xml 2012-04-14 21:37:35 +0000 @@ -0,0 +1,52 @@ + + + + + + com.mysql.clusterj + clusterj-aggregate + 7.1.22-SNAPSHOT + + 4.0.0 + com.mysql.clusterj + clusterj-unit + jar + 7.1.22-SNAPSHOT + ClusterJ Unit Test Framework + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + + false + + + + GPLv2 + http://www.gnu.org/licenses/gpl-2.0.txt + + + === added directory 'storage/ndb/clusterj/clusterj-unit/src' === added directory 'storage/ndb/clusterj/clusterj-unit/src/main' === added directory 'storage/ndb/clusterj/clusterj-unit/src/main/java' === added directory 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit' === added directory 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework' === added file 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/AssertionFailedError.java' --- a/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/AssertionFailedError.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/AssertionFailedError.java 2012-04-14 21:37:35 +0000 @@ -0,0 +1,50 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This assortment of classes is a mock http://en.wikipedia.org/wiki/Mock_object + * implementation of junit http://en.wikipedia.org/wiki/Junit. It contains annotations, + * classes, and interfaces that mock junit for use with test classes + * that use a subset of junit functionality. + *

+ * In clusterj, test classes can use either the real junit or this mock junit. + * The mock can be used stand-alone or invoked by the maven surefire junit plugin. + * Other test runners and harnesses might not have been tested and might not work. + *

+ * There is no code copied from Junit itself. Only concepts and names of + * annotations, interfaces, classes, and methods are copied, which must exactly match + * the corresponding items from junit in order to be mocked. + */ + +package junit.framework; + +public class AssertionFailedError extends AssertionError { + + private static final long serialVersionUID= 1L; + + /** Construct an AssertionFailedError with no failure message (highly unusual). + */ + public AssertionFailedError() { + } + + /** Construct an AssertionFailedError with the failure message. + * @param message the message + */ + public AssertionFailedError(String message) { + super(message); + } +} === added file 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/Test.java' --- a/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/Test.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/Test.java 2012-04-14 21:37:35 +0000 @@ -0,0 +1,39 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This assortment of classes is a mock http://en.wikipedia.org/wiki/Mock_object + * implementation of junit http://en.wikipedia.org/wiki/Junit. It contains annotations, + * classes, and interfaces that mock junit for use with test classes + * that use a subset of junit functionality. + *

+ * In clusterj, test classes can use either the real junit or this mock junit. + * The mock can be used stand-alone or invoked by the maven surefire junit plugin. + * Other test runners and harnesses might not have been tested and might not work. + *

+ * There is no code copied from Junit itself. Only concepts and names of + * annotations, interfaces, classes, and methods are copied, which must exactly match + * the corresponding items from junit in order to be mocked. + */ + +package junit.framework; + +/** This interface is implemented by a TestCase class. + */ +public interface Test { + void run(TestResult result); +} === added file 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestCase.java' --- a/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestCase.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestCase.java 2012-04-14 21:37:35 +0000 @@ -0,0 +1,92 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This assortment of classes is a mock http://en.wikipedia.org/wiki/Mock_object + * implementation of junit http://en.wikipedia.org/wiki/Junit. It contains annotations, + * classes, and interfaces that mock junit for use with test classes + * that use a subset of junit functionality. + *

+ * In clusterj, test classes can use either the real junit or this mock junit. + * The mock can be used stand-alone or invoked by the maven surefire junit plugin. + * Other test runners and harnesses might not have been tested and might not work. + *

+ * There is no code copied from Junit itself. Only concepts and names of + * annotations, interfaces, classes, and methods are copied, which must exactly match + * the corresponding items from junit in order to be mocked. + */ + +package junit.framework; + +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; + +public abstract class TestCase implements Test { + public String name; + public Method method; + + /** Run a single test case (method). If the test case fails an assertion + * via the fail(String) method, add the test to result.failures. + * If the test case fails by throwing an exception, or + * if the test case fails in setUp or tearDown, add the test case + * to result.errors. + */ + public void run(TestResult result) { +// System.out.println("--> TestCase.run(TestResult): " + name); + TestListener listener = result.listener; + listener.startTest(this); + try { + setUp(); + try { + method.invoke(this); + result.successes.add(name); + } catch (InvocationTargetException e) { + Throwable t = e.getCause(); + if (t instanceof AssertionFailedError) { + result.failures.add(name); + listener.addFailure(this, (AssertionFailedError)t); + } else { + result.throwables.add(t); + listener.addError(this, t); + } + } finally { + tearDown(); + } + } catch (Throwable t) { + result.throwables.add(t); + listener.addError(this, t); + } + listener.endTest(this); +// System.out.println("<-- TestCase.run(TestResult): " + name); + } + + /** The test case failed due to a failed assertion. + * @param message the failure message + */ + static public void fail(String message) { + throw new AssertionFailedError(message); + } + + protected void setUp() throws Exception {} + + protected void tearDown() throws Exception {} + + public int countTestCases() { + return 0; + } + +} === added file 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestListener.java' --- a/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestListener.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestListener.java 2012-04-14 21:37:35 +0000 @@ -0,0 +1,55 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This assortment of classes is a mock http://en.wikipedia.org/wiki/Mock_object + * implementation of junit http://en.wikipedia.org/wiki/Junit. It contains annotations, + * classes, and interfaces that mock junit for use with test classes + * that use a subset of junit functionality. + *

+ * In clusterj, test classes can use either the real junit or this mock junit. + * The mock can be used stand-alone or invoked by the maven surefire junit plugin. + * Other test runners and harnesses might not have been tested and might not work. + *

+ * There is no code copied from Junit itself. Only concepts and names of + * annotations, interfaces, classes, and methods are copied, which must exactly match + * the corresponding items from junit in order to be mocked. + */ + +package junit.framework; + +/** This interface is used to monitor the execution of tests and track errors and failures. + * It is implemented as part of the test runner framework. + */ +public interface TestListener { + + /** An error (exception) occurred during the execution of the test. + */ + public void addError(Test test, Throwable t); + + /** A failure (assertion) occurred during the execution of the test. + */ + public void addFailure(Test test, AssertionFailedError t); + + /** A test ended. + */ + public void endTest(Test test); + + /** A test started. + */ + public void startTest(Test test); +} === added file 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestResult.java' --- a/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestResult.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestResult.java 2012-04-14 21:37:35 +0000 @@ -0,0 +1,54 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This assortment of classes is a mock http://en.wikipedia.org/wiki/Mock_object + * implementation of junit http://en.wikipedia.org/wiki/Junit. It contains annotations, + * classes, and interfaces that mock junit for use with test classes + * that use a subset of junit functionality. + *

+ * In clusterj, test classes can use either the real junit or this mock junit. + * The mock can be used stand-alone or invoked by the maven surefire junit plugin. + * Other test runners and harnesses might not have been tested and might not work. + *

+ * There is no code copied from Junit itself. Only concepts and names of + * annotations, interfaces, classes, and methods are copied, which must exactly match + * the corresponding items from junit in order to be mocked. + */ + +package junit.framework; + +import java.util.List; +import java.util.ArrayList; + +/** This class maintains the results of running a series of tests. It is the primary + * way for a test class to return results of tests. + */ +public class TestResult { + public final List successes = new ArrayList(); + public final List failures = new ArrayList(); + public final List throwables = new ArrayList(); + public TestListener listener; + + public void addListener(TestListener listener) { + this.listener = listener; + } + + public synchronized boolean wasSuccessful() { + return failures.isEmpty(); + } +} === added file 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestSuite.java' --- a/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestSuite.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/framework/TestSuite.java 2012-04-14 21:37:35 +0000 @@ -0,0 +1,130 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This assortment of classes is a mock http://en.wikipedia.org/wiki/Mock_object + * implementation of junit http://en.wikipedia.org/wiki/Junit. It contains annotations, + * classes, and interfaces that mock junit for use with test classes + * that use a subset of junit functionality. + *

+ * In clusterj, test classes can use either the real junit or this mock junit. + * The mock can be used stand-alone or invoked by the maven surefire junit plugin. + * Other test runners and harnesses might not have been tested and might not work. + *

+ * There is no code copied from Junit itself. Only concepts and names of + * annotations, interfaces, classes, and methods are copied, which must exactly match + * the corresponding items from junit in order to be mocked. + */ + +package junit.framework; + +import java.util.List; +import java.util.ArrayList; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +import org.junit.Ignore; + +public class TestSuite implements Test { + public final String name; + public final List testClasses = new ArrayList(); + public final List tests = new ArrayList(); + + public Ignore ignoreTypeAnnotation = null; + public String ignoreTypeReason = null; + + /** Create a new test suite; add tests later. + * @param name the name of the test suite + */ + public TestSuite(String name) { + this.name = name; + } + + /** Create a new test suite with a single test class. + * @param cls the test class + */ + @SuppressWarnings("unchecked") // addTestSuite((Class) cls); + public TestSuite(Class cls) { + this.name = cls.getName(); + if (TestCase.class.isAssignableFrom(cls)) { + addTestSuite((Class) cls); + } else { + throw new RuntimeException("TestSuite: " + cls.getName()); + } + } + + /** Add a test class to this suite. If the class is annotated with @Ignore, + * skip running any test methods. If a method is annotated with @Ignore, + * skip running that test. + * @param testClass the test class + */ + public void addTestSuite(Class testClass) { + ignoreTypeAnnotation = testClass.getAnnotation(Ignore.class); + ignoreTypeReason = ignoreTypeAnnotation == null? null: ignoreTypeAnnotation.value(); + testClasses.add(testClass.getName()); + final Method[] methods = testClass.getMethods(); + Ignore ignoreMethodAnnotation = null; + String ignoreMethodReason = null; + for (Method m : methods) { + ignoreMethodAnnotation = m.getAnnotation(Ignore.class); + ignoreMethodReason = ignoreMethodAnnotation == null? null: ignoreMethodAnnotation.value(); + // public void methods that begin with "test" and have no parameters are considered to be tests + if (m.getName().startsWith("test") + && m.getParameterTypes().length == 0 + && m.getReturnType().equals(Void.TYPE) + && Modifier.isPublic(m.getModifiers())) { + try { +// System.out.println("TestSuite found " + m.getName()); + if (ignoreTypeAnnotation != null || ignoreMethodAnnotation != null) { + System.out.println(m.getName() + + " @Ignore: " + ignoreTypeReason + ":" + ignoreMethodReason); + } else { + TestCase t = testClass.newInstance(); + t.name = testClass.getSimpleName() + "." + m.getName(); + t.method = m; + tests.add(t); + } + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + } + } + + public int testCount() { + return tests.size(); + } + + public int countTestCases() { + return tests.size(); + } + + /** Run all tests in this suite. For each test, call the run method. + * @param result the result to receive the outcome of the test + */ + public void run(TestResult result) { +// System.out.println("--> TestSuite.run(TestResult)"); +// System.out.println(" test suite: " + name); +// System.out.println(" test classes: " + testClasses.size()); +// System.out.println(" test cases: " + tests.size()); + for (TestCase test : tests) { + test.run(result); + } +// System.out.println("<-- TestSuite.run(TestResult)"); + } + +} === added directory 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit/textui' === added file 'storage/ndb/clusterj/clusterj-unit/src/main/java/junit/textui/TestRunner.java' --- a/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/textui/TestRunner.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-unit/src/main/java/junit/textui/TestRunner.java 2012-04-14 21:37:35 +0000 @@ -0,0 +1,47 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This assortment of classes is a mock http://en.wikipedia.org/wiki/Mock_object + * implementation of junit http://en.wikipedia.org/wiki/Junit. It contains annotations, + * classes, and interfaces that mock junit for use with test classes + * that use a subset of junit functionality. + *

+ * In clusterj, test classes can use either the real junit or this mock junit. + * The mock can be used stand-alone or invoked by the maven surefire junit plugin. + * Other test runners and harnesses might not have been tested and might not work. + *

+ * There is no code copied from Junit itself. Only concepts and names of + * annotations, interfaces, classes, and methods are copied, which must exactly match + * the corresponding items from junit in order to be mocked. + */ + +package junit.textui; + +import junit.framework.Test; +import junit.framework.TestResult; + +/** Run a single test and return the result. Construct an instance of TestResult, + * pass it to the Test, and return it when the test completes. + */ +public class TestRunner { + static public TestResult run(Test test) { + final TestResult result = new TestResult(); + test.run(result); + return result; + } +} === added directory 'storage/ndb/clusterj/clusterj-unit/src/main/java/org' === added directory 'storage/ndb/clusterj/clusterj-unit/src/main/java/org/junit' === added file 'storage/ndb/clusterj/clusterj-unit/src/main/java/org/junit/Ignore.java' --- a/storage/ndb/clusterj/clusterj-unit/src/main/java/org/junit/Ignore.java 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/clusterj/clusterj-unit/src/main/java/org/junit/Ignore.java 2012-04-14 21:37:35 +0000 @@ -0,0 +1,50 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * This assortment of classes is a mock http://en.wikipedia.org/wiki/Mock_object + * implementation of junit http://en.wikipedia.org/wiki/Junit. It contains annotations, + * classes, and interfaces that mock junit for use with test classes + * that use a subset of junit functionality. + *

+ * In clusterj, test classes can use either the real junit or this mock junit. + * The mock can be used stand-alone or invoked by the maven surefire junit plugin. + * Other test runners and harnesses might not have been tested and might not work. + *

+ * There is no code copied from Junit itself. Only concepts and names of + * annotations, interfaces, classes, and methods are copied, which must exactly match + * the corresponding items from junit in order to be mocked. + */ + +package org.junit; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** This annotation can be used either on a test class to skip all tests contained + * within, or on a test method to skip a specific test method. The optional value() + * can be used to document why a test class or test method should not be run. + *

+ * For example: @Ignore("test uses excessive cpu") + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.TYPE}) +public @interface Ignore { + String value() default ""; +} === modified file 'storage/ndb/clusterj/pom.xml' --- a/storage/ndb/clusterj/pom.xml 2012-03-29 17:42:19 +0000 +++ b/storage/ndb/clusterj/pom.xml 2012-04-15 03:45:31 +0000 @@ -35,6 +35,7 @@ clusterj-jdbc clusterj-jpatest clusterj-openjpa + clusterj-unit @@ -63,12 +64,6 @@ - junit - junit - 4.7 - test - - org.antlr antlr 3.2 @@ -114,6 +109,12 @@ ndbjtie 7.1.22-SNAPSHOT + + com.mysql.clusterj + clusterj-unit + 7.1.22-SNAPSHOT + test + === modified file 'storage/ndb/memcache/include/QueryPlan.h' --- a/storage/ndb/memcache/include/QueryPlan.h 2012-03-22 22:18:19 +0000 +++ b/storage/ndb/memcache/include/QueryPlan.h 2012-04-14 00:53:04 +0000 @@ -56,7 +56,8 @@ class QueryPlan { Uint64 getAutoIncrement() const; void debug_dump() const; bool hasDataOnDisk() const; - + bool hasMathColumn() const; + /* public instance variables */ bool initialized; bool dup_numbers; /* dup_numbers mode for ascii incr/decr */ @@ -88,6 +89,9 @@ class QueryPlan { bool has_disk_storage; }; +inline bool QueryPlan::hasMathColumn() const { + return spec->math_column; +} inline bool QueryPlan::shouldExternalizeValue(size_t length) const { if(extern_store && val_record->value_length) === modified file 'storage/ndb/memcache/src/Record.cc' --- a/storage/ndb/memcache/src/Record.cc 2011-12-16 10:04:43 +0000 +++ b/storage/ndb/memcache/src/Record.cc 2012-04-14 00:53:04 +0000 @@ -30,7 +30,8 @@ extern EXTENSION_LOGGER_DESCRIPTOR *logger; -Record::Record(int ncol) : ncolumns(ncol), rec_size(0), nkeys(0), nvalues(0), +Record::Record(int ncol) : ncolumns(ncol), rec_size(0), ndb_record(0), + nkeys(0), nvalues(0), value_length(0), index(0), n_nullable(0), @@ -44,7 +45,8 @@ Record::Record(int ncol) : ncolumns(ncol }; Record::~Record() { - m_dict->releaseRecord(ndb_record); + if(ndb_record) + m_dict->releaseRecord(ndb_record); delete[] handlers; delete[] specs; }; === modified file 'storage/ndb/memcache/src/ndb_worker.cc' --- a/storage/ndb/memcache/src/ndb_worker.cc 2012-04-05 21:37:02 +0000 +++ b/storage/ndb/memcache/src/ndb_worker.cc 2012-04-14 00:53:04 +0000 @@ -1089,9 +1089,13 @@ void build_hash_item(workitem *wqitem, O memcpy(hash_item_get_key(item), wqitem->key, wqitem->base.nkey); // the key char * data_ptr = hash_item_get_data(item); - if(wqitem->plan->dup_numbers && op.isNull(COL_STORE_VALUE) - && ! (op.isNull(COL_STORE_MATH))) { - /* in dup_numbers mode, copy the math value */ + /* Maybe use the math column as the value */ + if( wqitem->plan->hasMathColumn() + && (! op.isNull(COL_STORE_MATH)) + && ( (op.nValues() == 0) + || (wqitem->plan->dup_numbers && op.isNull(COL_STORE_VALUE)) + ) + ) { ncopied = op.copyValue(COL_STORE_MATH, data_ptr); } else { === added file 'storage/ndb/memcache/unit/sequence.pl' --- a/storage/ndb/memcache/unit/sequence.pl 1970-01-01 00:00:00 +0000 +++ b/storage/ndb/memcache/unit/sequence.pl 2012-04-14 00:53:04 +0000 @@ -0,0 +1,98 @@ +#!/usr/bin/perl + +use strict; +use lib "../../../../mysql-test/lib/"; +use My::Memcache; +use Getopt::Long; +use Carp; +use DBI; + +my $do_flush = ''; +my $do_test = ''; +my $do_all = ''; +my $create = ''; +my $drop = ''; +my $reconf = ''; + +GetOptions("flush" => \$do_flush, +"all" => \$do_all, +"test=s" => \$do_test, +"create" => \$create, "drop" => \$drop, "reconf" => \$reconf +); + + +if($create || $drop || $reconf) { + my $dsn = "DBI:mysql:database=ndbmemcache;host=localhost;port=3306"; + my $dbh = DBI->connect($dsn, "root", ""); + + if($drop) { + $dbh->do("DROP TABLE test_sequence"); + $dbh->do("DELETE FROM containers where db_table = 'test_sequence'"); + $dbh->do("DELETE FROM key_prefixes where key_prefix = 'seq:'"); + } + + if($create) { + $dbh->do("CREATE TABLE test_sequence ( " . + " name varchar(12) PRIMARY KEY NOT NULL, " . + " value bigint unsigned ) ENGINE=ndbcluster"); + + $dbh->do("INSERT INTO containers SET " . + " name = 'seq_tab', db_schema = 'ndbmemcache', " . + " db_table = 'test_sequence', ". + " key_columns = 'name', increment_column = 'value' " ); + + $dbh->do("INSERT INTO key_prefixes " . + " VALUES(0, 'seq:', 0, 'ndb-test', 'seq_tab') "); + } + + if($reconf) { + $dbh->do("UPDATE memcache_server_roles " . + " SET update_timestamp = now() where role_id = 0"); + } +} + +if ($do_all || $do_test || $do_flush) { + + my $mc = My::Memcache::Binary->new(); + my $port = 11211; + + my $r = $mc->connect("localhost",$port); + + if($r == 0) { + print STDERR "DID NOT CONNECT TO MEMCACHE AT PORT $port \n"; + } + + + # Flush all + if($do_flush) { + $mc->flush(); + } + + + ###### TEST 1: INCR + CREATE + if($do_all || $do_test == '1') { + my $a = $mc->incr("seq:a", 1, 0); + defined($a) || Carp::croak("no return from incr"); + print "$a \n"; + } + + + ###### TEST 2: GET + if($do_all || $do_test == '2') { + my $a = $mc->get("seq:a") . "\n"; + print "$a \n"; + } + + ###### TEST 3: INCR + CREATE + if($do_all || $do_test == '3') { + my $a = $mc->incr("seq:b", 1, 0); + defined($a) || Carp::croak("no return from incr"); + print "$a \n"; + } + + ###### TEST 4: INCR without create -- should be undefined + if($do_all || $do_test == '4') { + my $a = $mc->incr("seq:c", 1); + defined($a) && Carp::croak("should be undefined!"); + } +} === modified file 'storage/ndb/src/mgmsrv/ConfigInfo.cpp' --- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp 2012-03-12 09:57:10 +0000 +++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp 2012-04-16 10:34:32 +0000 @@ -3955,7 +3955,8 @@ public: pairs.put("name", param_name); pairs.put("comment", info.getDescription(section, param_name)); - switch (info.getType(section, param_name)) { + const ConfigInfo::Type param_type = info.getType(section, param_name); + switch (param_type) { case ConfigInfo::CI_BOOL: pairs.put("type", "bool"); @@ -3996,6 +3997,13 @@ public: pairs.put("mandatory", "true"); else if (info.hasDefault(section, param_name)) pairs.put("default", info.getDefaultString(section, param_name)); + + if (param_type == ConfigInfo::CI_ENUM) + { + // Concatenate the allowed enum values to a space separated string + info.get_enum_values(section, param_name, buf); + require(pairs.put("allowed_values", buf.c_str())); + } break; case ConfigInfo::CI_SECTION: No bundle (reason: useless for push emails).