------------------------------------------------------------
revno: 135
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: ndbjmerge
timestamp: Fri 2007-06-29 17:22:29 -0700
message:
Got the rest of ndbj.InsertRetryTest ported. Not sure how useful it is without something
in the test to actually cause a TemporaryError. Any ideas?
modified:
java/testsuite/BaseTestCase.java basetestcase.java-20070523000102-ggam3j202kmrm4es-5
java/testsuite/ndbj/InsertRetryTest.java
insertretrytest.java-20070517181935-98huwjarzuh25b30-47
=== modified file 'java/testsuite/BaseTestCase.java'
--- a/java/testsuite/BaseTestCase.java 2007-06-29 19:49:43 +0000
+++ b/java/testsuite/BaseTestCase.java 2007-06-30 00:22:29 +0000
@@ -476,8 +476,7 @@
} catch (SQLException SQLE) {
;
}
- }
-/*
+ }/*
for (int i = 0; i < this.createdObjects.size(); i++) {
try {
String[] objectInfo = this.createdObjects.get(i);
@@ -486,8 +485,7 @@
} catch (SQLException SQLE) {
;
}
- }
-*/
+ }*/
if (this.stmt != null) {
try {
this.stmt.close();
=== modified file 'java/testsuite/ndbj/InsertRetryTest.java'
--- a/java/testsuite/ndbj/InsertRetryTest.java 2007-06-29 23:04:54 +0000
+++ b/java/testsuite/ndbj/InsertRetryTest.java 2007-06-30 00:22:29 +0000
@@ -35,14 +35,14 @@
super.setUp();
System.out.println("Creating table: " + tablename);
- this.createTable(tablename, "(id int, name varchar(56), primary key(id))
engine=ndbcluster");
+ this.createTable(tablename, "(id int, name varchar(56), primary key(id))
engine=ndbcluster default charset=utf8");
}
/*
* Test method for 'com.mysql.ndbapi.Ndb.destroy()'
*/
- public void testInsert() {
+ public void testInsert() throws java.sql.SQLException {
boolean done = false;
int numRetries = 0;
@@ -54,7 +54,6 @@
op.insertTuple();
op.equal(col1, i);
String setting = col2Val + Integer.toString(i);
- System.out.println("setting: " + setting);
op.setString(col2, setting);
}
@@ -77,9 +76,51 @@
if (trans != null)
trans.close();
}
-
- }
+ }
+ for (int i = 0; i < NUM_INSERTS; i++) {
+
+ String nameVal = (String)this.getSingleValue(tablename, "name", "where id=" +
Integer.toString(i));
+ assertEquals(nameVal,col2Val + Integer.toString(i));
+ }
+ }
+
+ public void testRead() {
+ // TODO: Replace this with JDBC inserting of data
+ boolean done = false;
+ int numRetries = 0;
+ while (numRetries < MAX_RETRIES && !done) {
+ try {
+ trans = ndb.startTransaction(tablename,tablename);
+ for (int i = 0; i < NUM_INSERTS; i++) {
+ NdbOperation op = trans.getNdbOperation(tablename);
+ op.insertTuple();
+ op.equal(col1, i);
+ String setting = col2Val + Integer.toString(i);
+ op.setString(col2, setting);
+ }
+
+ trans.execute(NdbTransaction.ExecType.Commit,
+ NdbTransaction.AbortOption.AbortOnError, true);
+
+ done = true;
+ assertTrue(true);
+ } catch (NdbApiTemporaryException e) {
+ numRetries++;
+ System.out
+ .println("Temporary error. Retrying insert. Num Retries == "
+ + numRetries + " error msg:" + e.getMessage());
+ } catch (NdbApiException e) {
+ System.out.println("Caught NdbApiException in Insert:\t"
+ + e.getMessage());
+ assertTrue(false);
+ done = true;
+ } finally {
+ if (trans != null)
+ trans.close();
+ }
+ }
+
try {
System.out.println("Reading the inserted rows");
trans = ndb.startTransaction();
@@ -122,13 +163,48 @@
}
- /*public void testDelete() {
+ public void testDelete() throws java.sql.SQLException {
+
+ // TODO: Repleace with JDBC data insert
+ boolean done = false;
+ int numRetries = 0;
+ while (numRetries < MAX_RETRIES && !done) {
+ try {
+ trans = ndb.startTransaction(tablename,tablename);
+ for (int i = 0; i < NUM_INSERTS; i++) {
+ NdbOperation op = trans.getNdbOperation(tablename);
+ op.insertTuple();
+ op.equal(col1, i);
+ String setting = col2Val + Integer.toString(i);
+ op.setString(col2, setting);
+ }
+
+ trans.execute(NdbTransaction.ExecType.Commit,
+ NdbTransaction.AbortOption.AbortOnError, true);
+
+ done = true;
+ assertTrue(true);
+ } catch (NdbApiTemporaryException e) {
+ numRetries++;
+ System.out
+ .println("Temporary error. Retrying insert. Num Retries == "
+ + numRetries + " error msg:" + e.getMessage());
+ } catch (NdbApiException e) {
+ System.out.println("Caught NdbApiException in Insert:\t"
+ + e.getMessage());
+ assertTrue(false);
+ done = true;
+ } finally {
+ if (trans != null)
+ trans.close();
+ }
+ }
try {
System.out.println("Deleting the inserted rows");
trans = ndb.startTransaction();
for (int i = 0; i < NUM_INSERTS; i++) {
- NdbOperation op = trans.getNdbOperation(BaseNdbjTestCase.TABLE_NAME);
+ NdbOperation op = trans.getNdbOperation(tablename);
op.deleteTuple();
op.equal(col1, i);
}
@@ -150,7 +226,9 @@
if (trans != null)
trans.close();
}
+ int rowcount = this.getRowCount(tablename);
+ assertEquals(rowcount,0);
- }*/
+ }
}
| Thread |
|---|
| • Rev 135: Got the rest of ndbj.InsertRetryTest ported. Not sure how useful it is without something in the test to actually cause a TemporaryError. Any ... | Monty Taylor | 30 Jun |