Commit b7266326 authored by unknown's avatar unknown

ndb - Testcase for bug#10669

      --database option to hugo tools


ndb/test/ndbapi/testNdbApi.cpp:
  Testcase for bug#10669
ndb/test/tools/hugoLoad.cpp:
  Add --database=<name> to hugo tools
ndb/test/tools/hugoPkUpdate.cpp:
  Add --database=<name> to hugo tools
ndb/test/tools/hugoScanRead.cpp:
  Add --database=<name> to hugo tools
ndb/test/tools/hugoScanUpdate.cpp:
  Add --database=<name> to hugo tools
parent 0c847c1c
......@@ -877,6 +877,81 @@ int runUpdateWithoutKeys(NDBT_Context* ctx, NDBT_Step* step){
return result;
}
int runReadWithoutGetValue(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK;
const NdbDictionary::Table* pTab = ctx->getTab();
HugoOperations hugoOps(*pTab);
Ndb* pNdb = new Ndb(&ctx->m_cluster_connection, "TEST_DB");
if (pNdb == NULL){
ndbout << "pNdb == NULL" << endl;
return NDBT_FAILED;
}
if (pNdb->init()){
ERR(pNdb->getNdbError());
delete pNdb;
return NDBT_FAILED;
}
for(Uint32 cm= 0; cm < 2; cm++)
{
for(Uint32 lm= 0; lm <= NdbOperation::LM_CommittedRead; lm++)
{
NdbConnection* pCon = pNdb->startTransaction();
if (pCon == NULL){
pNdb->closeTransaction(pCon);
delete pNdb;
return NDBT_FAILED;
}
NdbOperation* pOp = pCon->getNdbOperation(pTab->getName());
if (pOp == NULL){
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
delete pNdb;
return NDBT_FAILED;
}
if (pOp->readTuple((NdbOperation::LockMode)lm) != 0){
pNdb->closeTransaction(pCon);
ERR(pOp->getNdbError());
delete pNdb;
return NDBT_FAILED;
}
for(int a = 0; a<pTab->getNoOfColumns(); a++){
if (pTab->getColumn(a)->getPrimaryKey() == true){
if(hugoOps.equalForAttr(pOp, a, 1) != 0){
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
delete pNdb;
return NDBT_FAILED;
}
}
}
// Dont' call any getValues
// Execute should work
int check = pCon->execute(cm == 0 ? NoCommit : Commit);
if (check == 0){
ndbout << "execute worked" << endl;
} else {
ERR(pCon->getNdbError());
result = NDBT_FAILED;
}
pNdb->closeTransaction(pCon);
}
}
delete pNdb;
return result;
}
int runCheckGetNdbErrorOperation(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK;
const NdbDictionary::Table* pTab = ctx->getTab();
......@@ -1011,6 +1086,12 @@ TESTCASE("NdbErrorOperation",
"Test that NdbErrorOperation is properly set"){
INITIALIZER(runCheckGetNdbErrorOperation);
}
TESTCASE("ReadWithoutGetValue",
"Test that it's possible to perform read wo/ getvalue's\n"){
INITIALIZER(runLoadTable);
INITIALIZER(runReadWithoutGetValue);
FINALIZER(runClearTable);
}
NDBT_TESTSUITE_END(testNdbApi);
int main(int argc, const char** argv){
......
......@@ -30,10 +30,12 @@ int main(int argc, const char** argv){
const char* _tabname = NULL;
int _help = 0;
int _batch = 512;
const char* db = 0;
struct getargs args[] = {
{ "records", 'r', arg_integer, &_records, "Number of records", "recs" },
{ "batch", 'b', arg_integer, &_batch, "Number of operations in each transaction", "batch" },
{ "database", 'd', arg_string, &db, "Database", "" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
......@@ -54,7 +56,7 @@ int main(int argc, const char** argv){
_tabname = argv[optind];
// Connect to Ndb
Ndb MyNdb( "TEST_DB" );
Ndb MyNdb( db ? db : "TEST_DB" );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
......
......@@ -33,7 +33,7 @@ int main(int argc, const char** argv){
int _loops = 1;
int _abort = 0;
int _batch = 0;
const char* _tabname = NULL;
const char* _tabname = NULL, *db = 0;
int _help = 0;
struct getargs args[] = {
......@@ -41,7 +41,8 @@ int main(int argc, const char** argv){
{ "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" },
// { "batch", 'b', arg_integer, &_batch, "batch value", "batch" },
{ "records", 'r', arg_integer, &_records, "Number of records", "records" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
{ "usage", '?', arg_flag, &_help, "Print help", "" },
{ "database", 'd', arg_string, &db, "Database", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
......@@ -57,7 +58,7 @@ int main(int argc, const char** argv){
_tabname = argv[optind];
// Connect to Ndb
Ndb MyNdb( "TEST_DB" );
Ndb MyNdb( db ? db : "TEST_DB" );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
......
......@@ -33,7 +33,7 @@ int main(int argc, const char** argv){
int _loops = 1;
int _abort = 0;
int _parallelism = 1;
const char* _tabname = NULL;
const char* _tabname = NULL, *db = 0;
int _help = 0;
int lock = NdbOperation::LM_Read;
int sorted = 0;
......@@ -45,7 +45,8 @@ int main(int argc, const char** argv){
{ "records", 'r', arg_integer, &_records, "Number of records", "recs" },
{ "usage", '?', arg_flag, &_help, "Print help", "" },
{ "lock", 'm', arg_integer, &lock, "lock mode", "" },
{ "sorted", 's', arg_flag, &sorted, "sorted", "" }
{ "sorted", 's', arg_flag, &sorted, "sorted", "" },
{ "database", 'd', arg_string, &db, "Database", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
......@@ -61,7 +62,7 @@ int main(int argc, const char** argv){
_tabname = argv[optind];
// Connect to Ndb
Ndb MyNdb( "TEST_DB" );
Ndb MyNdb( db ? db : "TEST_DB" );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
......
......@@ -33,7 +33,7 @@ int main(int argc, const char** argv){
int _loops = 1;
int _parallelism = 1;
int _ver2 = 0;
const char* _tabname = NULL;
const char* _tabname = NULL, *db = 0;
int _help = 0;
struct getargs args[] = {
......@@ -42,7 +42,8 @@ int main(int argc, const char** argv){
{ "records", 'r', arg_integer, &_records, "Number of records", "recs" },
{ "ver2", '2', arg_flag, &_ver2, "Use version 2 of scanUpdateRecords", "" },
{ "ver2", '1', arg_negative_flag, &_ver2, "Use version 1 of scanUpdateRecords (default)", "" },
{ "usage", '?', arg_flag, &_help, "Print help", "" }
{ "usage", '?', arg_flag, &_help, "Print help", "" },
{ "database", 'd', arg_string, &db, "Database", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
int optind = 0;
......@@ -58,7 +59,7 @@ int main(int argc, const char** argv){
_tabname = argv[optind];
// Connect to Ndb
Ndb MyNdb( "TEST_DB" );
Ndb MyNdb( db ? db : "TEST_DB" );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
......@@ -95,6 +96,7 @@ int main(int argc, const char** argv){
return NDBT_ProgramExit(NDBT_FAILED);
}
i++;
//NdbSleep_MilliSleep(300);
}
return NDBT_ProgramExit(NDBT_OK);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment