18 #include <ndb_global.h>
22 #include "NDBT_Test.hpp"
25 : m_cluster_connection(con)
33 propertyMutexPtr = NdbMutex_Create();
34 propertyCondPtr = NdbCondition_Create();
38 NDBT_Context::~NDBT_Context(){
39 NdbCondition_Destroy(propertyCondPtr);
40 NdbMutex_Destroy(propertyMutexPtr);
44 assert(tables.size());
49 assert(suite != NULL);
58 const char* NDBT_Context::getTableName(
int n)
const
60 assert(suite != NULL);
61 return suite->m_tables_in_test[
n].c_str();
64 int NDBT_Context::getNumTables()
const
66 assert(suite != NULL);
67 return suite->m_tables_in_test.size();
70 int NDBT_Context::getNumRecords()
const{
74 int NDBT_Context::getNumLoops()
const{
79 return testcase->getNoOfRunningSteps();
82 int NDBT_Context::getNoOfCompletedSteps()
const {
83 return testcase->getNoOfCompletedSteps();
87 Uint32 NDBT_Context::getProperty(
const char* _name, Uint32 _default){
89 NdbMutex_Lock(propertyMutexPtr);
90 if(!props.get(_name, &val))
92 NdbMutex_Unlock(propertyMutexPtr);
96 bool NDBT_Context::getPropertyWait(
const char* _name, Uint32 _waitVal){
98 NdbMutex_Lock(propertyMutexPtr);
99 Uint32 val =! _waitVal;
101 while((!props.get(_name, &val) || (props.get(_name, &val) && val != _waitVal)) &&
103 NdbCondition_Wait(propertyCondPtr,
105 result = (val == _waitVal);
106 NdbMutex_Unlock(propertyMutexPtr);
110 const char* NDBT_Context::getProperty(
const char* _name,
const char* _default){
112 NdbMutex_Lock(propertyMutexPtr);
113 if(!props.get(_name, &val))
115 NdbMutex_Unlock(propertyMutexPtr);
119 const char* NDBT_Context::getPropertyWait(
const char* _name,
const char* _waitVal){
121 NdbMutex_Lock(propertyMutexPtr);
122 while(!props.get(_name, &val) && (strcmp(val, _waitVal)==0))
123 NdbCondition_Wait(propertyCondPtr,
126 NdbMutex_Unlock(propertyMutexPtr);
130 void NDBT_Context::setProperty(
const char* _name, Uint32 _val){
131 NdbMutex_Lock(propertyMutexPtr);
132 const bool b = props.
put(_name, _val,
true);
134 NdbCondition_Broadcast(propertyCondPtr);
135 NdbMutex_Unlock(propertyMutexPtr);
139 NDBT_Context::decProperty(
const char *
name){
140 NdbMutex_Lock(propertyMutexPtr);
142 if(props.get(name, &val)){
144 props.
put(name, (val - 1),
true);
146 NdbCondition_Broadcast(propertyCondPtr);
147 NdbMutex_Unlock(propertyMutexPtr);
151 NDBT_Context::incProperty(
const char * name){
152 NdbMutex_Lock(propertyMutexPtr);
154 props.get(name, &val);
155 props.
put(name, (val + 1),
true);
156 NdbCondition_Broadcast(propertyCondPtr);
157 NdbMutex_Unlock(propertyMutexPtr);
161 NDBT_Context::casProperty(
const char * name, Uint32 oldValue, Uint32 newValue)
163 NdbMutex_Lock(propertyMutexPtr);
165 props.get(name, &val);
168 props.
put(name, newValue,
true);
169 NdbCondition_Broadcast(propertyCondPtr);
171 NdbMutex_Unlock(propertyMutexPtr);
175 void NDBT_Context::setProperty(
const char* _name,
const char* _val){
176 NdbMutex_Lock(propertyMutexPtr);
177 const bool b = props.
put(_name, _val,
true);
179 NdbCondition_Broadcast(propertyCondPtr);
180 NdbMutex_Unlock(propertyMutexPtr);
183 void NDBT_Context::stopTest(){
184 NdbMutex_Lock(propertyMutexPtr);
185 g_info <<
"|- stopTest called" << endl;
187 NdbCondition_Broadcast(propertyCondPtr);
188 NdbMutex_Unlock(propertyMutexPtr);
191 bool NDBT_Context::isTestStopped(){
192 NdbMutex_Lock(propertyMutexPtr);
194 NdbMutex_Unlock(propertyMutexPtr);
198 void NDBT_Context::wait(){
199 NdbMutex_Lock(propertyMutexPtr);
200 NdbCondition_Wait(propertyCondPtr,
202 NdbMutex_Unlock(propertyMutexPtr);
205 void NDBT_Context::wait_timeout(
int msec){
206 NdbMutex_Lock(propertyMutexPtr);
207 NdbCondition_WaitTimeout(propertyCondPtr,
210 NdbMutex_Unlock(propertyMutexPtr);
213 void NDBT_Context::broadcast(){
214 NdbMutex_Lock(propertyMutexPtr);
215 NdbCondition_Broadcast(propertyCondPtr);
216 NdbMutex_Unlock(propertyMutexPtr);
219 Uint32 NDBT_Context::getDbProperty(
const char*){
224 bool NDBT_Context::setDbProperty(
const char*, Uint32){
231 tables.push_back(ptab);
237 tables.back() = ptab;
239 tables.push_back(ptab);
246 NDBT_Context::getTables()
248 return tables.getBase();
252 assert(psuite != NULL);
257 assert(pcase != NULL);
261 void NDBT_Context::setNumRecords(
int _records){
266 void NDBT_Context::setNumLoops(
int _loops){
270 NDBT_Step::NDBT_Step(
NDBT_TestCase* ptest,
const char* pname,
271 NDBT_TESTFUNC* pfunc) :
272 m_ctx(NULL), name(pname), func(pfunc),
273 testcase(ptest), step_no(-1), m_ndb(NULL)
277 #include "../../src/ndbapi/ndb_internal.hpp"
289 m_ndb =
new Ndb(&con,
"TEST_DB" );
292 Ndb_internal::setForceShortRequests(m_ndb,
293 m_ctx->suite->getForceShort());
297 g_err <<
"Ndb was not ready" << endl;
314 NDBT_Step::tearDown(){
320 Ndb* NDBT_Step::getNdb()
const {
321 assert(m_ndb != NULL);
331 g_info <<
" |- " << name <<
" started [" << ctx->suite->
getDate() <<
"]"
334 result = setUp(ctx->m_cluster_connection);
335 if (result != NDBT_OK){
339 result = func(ctx,
this);
341 if (result != NDBT_OK) {
342 g_err <<
" |- " << name <<
" FAILED [" << ctx->suite->
getDate()
346 g_info <<
" |- " << name <<
" PASSED [" << ctx->suite->
getDate() <<
"]"
356 assert(pctx != NULL);
361 assert(m_ctx != NULL);
368 NDBT_TESTFUNC* pfunc)
373 NDBT_TESTFUNC* pfunc)
378 NDBT_TESTFUNC* pfunc)
383 NDBT_TESTFUNC* pfunc)
389 const char* pcomment) :
394 assert(suite != NULL);
396 m_all_tables =
false;
402 const char* pcomment) :
407 numStepsCompleted = 0;
408 waitThreadsMutexPtr = NdbMutex_Create();
409 waitThreadsCondPtr = NdbCondition_Create();
411 m_driverType= psuite->getDriverType();
414 NDBT_TestCaseImpl1::~NDBT_TestCaseImpl1(){
415 NdbCondition_Destroy(waitThreadsCondPtr);
416 NdbMutex_Destroy(waitThreadsMutexPtr);
418 for(i = 0; i < initializers.size(); i++)
419 delete initializers[i];
420 initializers.clear();
421 for(i = 0; i < verifiers.size(); i++)
424 for(i = 0; i < finalizers.size(); i++)
425 delete finalizers[i];
427 for(i = 0; i < steps.size(); i++)
431 for(i = 0; i < testTables.size(); i++)
432 delete testTables[i];
434 for(i = 0; i < testResults.size(); i++)
435 delete testResults[i];
440 int NDBT_TestCaseImpl1::addStep(
NDBT_Step* pStep){
441 assert(pStep != NULL);
442 steps.push_back(pStep);
443 pStep->setStepNo(steps.size());
445 results.push_back(res);
449 int NDBT_TestCaseImpl1::addVerifier(
NDBT_Verifier* pVerifier){
450 assert(pVerifier != NULL);
451 verifiers.push_back(pVerifier);
457 assert(pInitializer != NULL);
459 initializers.push(pInitializer, 0);
461 initializers.push_back(pInitializer);
466 assert(pFinalizer != NULL);
467 finalizers.push_back(pFinalizer);
471 void NDBT_TestCaseImpl1::addTable(
const char* tableName,
bool isVerify) {
472 assert(tableName != NULL);
474 assert(pTable != NULL);
475 testTables.push_back(pTable);
476 isVerifyTables = isVerify;
480 for (
unsigned i = 0; i < testTables.size(); i++) {
481 if (strcasecmp(testTables[i]->getName(), aTable->
getName()) == 0) {
489 if (testTables.size() > 0) {
492 for (
unsigned i = 0; i < testTables.size(); i++) {
493 if (strcasecmp(testTables[i]->getName(), aTable->
getName()) == 0) {
495 if (isVerifyTables) {
513 void NDBT_TestCase::setProperty(
const char* _name, Uint32 _val){
514 const bool b = props.
put(_name, _val);
518 void NDBT_TestCase::setProperty(
const char* _name,
const char* _val){
519 const bool b = props.
put(_name, _val);
531 int res = pStep->execute(ctx);
537 assert(pCase != NULL);
538 pCase->reportStepResult(pStep, res);
551 void NDBT_TestCaseImpl1::startStepInThread(
int stepNo,
NDBT_Context* ctx){
553 pStep->setContext(ctx);
556 Uint32 stackSize = ctx->getProperty(NDBT_TestCase::getStepThreadStackSizePropName(),
559 NdbThread* pThread = NdbThread_Create(runStep_C,
563 NDB_THREAD_PRIO_LOW);
564 threads.push_back(pThread);
567 void NDBT_TestCaseImpl1::waitSteps(){
568 NdbMutex_Lock(waitThreadsMutexPtr);
569 while(numStepsCompleted != steps.size())
570 NdbCondition_Wait(waitThreadsCondPtr,
571 waitThreadsMutexPtr);
573 unsigned completedSteps = 0;
575 for(i=0; i<steps.size(); i++){
576 if (results[i] != NORESULT){
578 if (results[i] == NDBT_OK)
584 assert(completedSteps == steps.size());
585 assert(completedSteps == numStepsCompleted);
587 NdbMutex_Unlock(waitThreadsMutexPtr);
589 for(i=0; i<steps.size();i++){
590 NdbThread_WaitFor(threads[i], &status);
591 NdbThread_Destroy(&threads[i]);
599 return steps.size() - getNoOfCompletedSteps();
603 NDBT_TestCaseImpl1::getNoOfCompletedSteps()
const {
604 return numStepsCompleted;
607 void NDBT_TestCaseImpl1::reportStepResult(
const NDBT_Step* pStep,
int result){
608 NdbMutex_Lock(waitThreadsMutexPtr);
609 assert(pStep != NULL);
610 for (
unsigned i = 0; i < steps.size(); i++){
611 if(steps[i] != NULL && steps[i] == pStep){
616 if(numStepsCompleted == steps.size()){
617 NdbCondition_Signal(waitThreadsCondPtr);
619 NdbMutex_Unlock(waitThreadsMutexPtr);
626 ndbout <<
"- " << _name <<
" started [" << ctx->suite->
getDate()
633 for(
const char * key = it.first(); key != 0; key = it.next()){
636 const bool b = props.getTypeOf(key, &pt);
639 case PropertiesType_Uint32:{
641 props.get(key, &val);
642 ctx->setProperty(key, val);
645 case PropertiesType_char:{
647 props.get(key, &val);
648 ctx->setProperty(key, val);
660 if ((res = runInit(ctx)) == NDBT_OK){
666 res = runVerifier(ctx);
677 if (res == NDBT_OK) {
678 ndbout <<
"- " << _name <<
" PASSED [" << ctx->suite->
getDate() <<
"]"
682 ndbout <<
"- " << _name <<
" FAILED [" << ctx->suite->
getDate() <<
"]"
697 if (suite->timerIsOn()){
699 timer.printTestTimer(ctx->getNumLoops(), ctx->getNumRecords());
705 for (
unsigned i = 0; i < initializers.size(); i++){
706 initializers[
i]->setContext(ctx);
707 res = initializers[
i]->execute(ctx);
720 numStepsCompleted = 0;
722 for (i = 0; i < steps.size(); i++)
723 startStepInThread(i, ctx);
726 for(i = 0; i < steps.size(); i++)
727 if (results[i] != NDBT_OK)
734 for (
unsigned i = 0; i < verifiers.size(); i++){
735 verifiers[
i]->setContext(ctx);
736 res = verifiers[
i]->execute(ctx);
745 for (
unsigned i = 0; i < finalizers.size(); i++){
746 finalizers[
i]->setContext(ctx);
747 res = finalizers[
i]->execute(ctx);
755 void NDBT_TestCaseImpl1::saveTestResult(
const char* test_name,
759 timer.elapsedTime()));
762 void NDBT_TestCaseImpl1::printTestResult(){
765 ndbout << _name<<endl;
767 for (
unsigned i = 0; i < testResults.size(); i++){
769 const char* res =
"<unknown>";
770 if (tcr->getResult() == NDBT_OK)
772 else if (tcr->getResult() == NDBT_FAILED)
774 else if (tcr->getResult() == FAILED_TO_CREATE)
775 res =
"FAILED TO CREATE TABLE";
776 else if (tcr->getResult() == FAILED_TO_DISCOVER)
777 res =
"FAILED TO DISCOVER TABLE";
790 NDBT_TestSuite::NDBT_TestSuite(
const char* pname) :
794 m_connect_cluster(true),
800 numTestsExecuted = 0;
805 temporaryTables =
false;
808 m_forceShort =
false;
812 NDBT_TestSuite::~NDBT_TestSuite(){
813 for(
unsigned i=0; i<tests.size(); i++){
819 void NDBT_TestSuite::setCreateTable(
bool _flag){
820 m_createTable = _flag;
823 void NDBT_TestSuite::setRunAllTables(
bool _flag){
826 void NDBT_TestSuite::setCreateAllTables(
bool _flag){
829 void NDBT_TestSuite::setConnectCluster(
bool _flag){
830 assert(m_createTable ==
false);
831 m_connect_cluster = _flag;
834 void NDBT_TestSuite::setTemporaryTables(
bool val){
835 temporaryTables = val;
838 bool NDBT_TestSuite::getTemporaryTables()
const {
839 return temporaryTables;
842 void NDBT_TestSuite::setLogging(
bool val){
846 bool NDBT_TestSuite::getLogging()
const {
850 bool NDBT_TestSuite::getForceShort()
const {
854 bool NDBT_TestSuite::timerIsOn(){
859 assert(pTest != NULL);
860 tests.push_back(pTest);
865 const char* _testname){
867 if(tests.size() == 0)
870 ndbout << name <<
" started [" <<
getDate() <<
"]" << endl;
874 testSuiteTimer.doStart();
875 for (
int t=0; t < NDBT_Tables::getNumTables(); t++){
877 ndbout <<
"|- " << ptab->
getName() << endl;
878 execute(con, ptab, _testname);
880 testSuiteTimer.doStop();
884 for (
unsigned i = 0; i < tests.size(); i++){
885 if (_testname != NULL && strcasecmp(tests[i]->getName(), _testname) != 0)
888 tests[
i]->initBeforeTest();
891 ctx->setNumRecords(records);
892 ctx->setNumLoops(loops);
894 ctx->setProperty(
"NoDDL", (Uint32) m_noddl);
896 int result = tests[
i]->execute(ctx);
898 tests[
i]->saveTestResult(
"", result);
899 if (result != NDBT_OK)
908 return reportAllTables(_testname);
913 const char* _tabname,
const char* _testname){
915 if(tests.size() == 0)
918 ndbout << name <<
" started [" <<
getDate() <<
"]" << endl;
924 ndbout <<
"|- " << ptab->
getName() << endl;
926 execute(con, ptab, _testname);
928 if (numTestsFail > 0){
939 testSuiteTimer.doStart();
942 if(tests.size() == 0)
945 Ndb ndb(&con,
"TEST_DB");
948 Ndb_internal::setForceShortRequests(&ndb, m_forceShort);
950 int result = ndb.waitUntilReady(300);
952 g_err << name <<
": Ndb was not ready" << endl;
956 ndbout << name <<
" started [" <<
getDate() <<
"]" << endl;
957 ndbout <<
"|- " << ptab->
getName() << endl;
959 for (
unsigned t = 0; t < tests.size(); t++){
961 if (_testname != NULL &&
962 strcasecmp(tests[t]->getName(), _testname) != 0)
965 tests[t]->initBeforeTest();
969 ctx->setNumRecords(records);
970 ctx->setNumLoops(loops);
972 ctx->setProperty(
"NoDDL", (Uint32) m_noddl);
974 result = tests[t]->execute(ctx);
975 if (result != NDBT_OK)
984 if (numTestsFail > 0)
988 testSuiteTimer.doStop();
989 int res = report(_testname);
990 return NDBT_ProgramExit(res);
1004 col->setStorageType(NdbDictionary::Column::StorageTypeDisk);
1008 else if (temporaryTables)
1010 tab.setTemporary(
true);
1014 if (tsname != NULL) {
1015 tab.setTablespaceName(tsname);
1023 const char* _testname){
1026 for (
unsigned t = 0; t < tests.size(); t++){
1028 if (_testname != NULL &&
1029 strcasecmp(tests[t]->getName(), _testname) != 0)
1032 if (tests[t]->m_all_tables && tests[t]->m_has_run)
1037 if (tests[t]->isVerify(pTab) ==
false) {
1041 tests[t]->initBeforeTest();
1044 ctx->setNumRecords(records);
1045 ctx->setNumLoops(loops);
1046 ctx->setSuite(
this);
1048 ctx->setProperty(
"NoDDL", (Uint32) m_noddl);
1050 result = tests[t]->execute(ctx);
1051 tests[t]->saveTestResult(pTab->
getName(), result);
1052 if (result != NDBT_OK)
1058 tests[t]->m_has_run =
true;
1069 Ndb ndb(&con,
"TEST_DB");
1073 for(
unsigned i = 0; i<m_tables_in_test.size(); i++)
1075 const char *tab_name= m_tables_in_test[
i].c_str();
1079 g_err <<
"runCreateTables: Failed to drop table " << tab_name << endl
1083 if(NDBT_Tables::createTable(&ndb, tab_name, !getLogging()) != 0)
1085 g_err <<
"runCreateTables: Failed to create table " << tab_name << endl
1095 g_info <<
"created " << tab_name << endl;
1106 return suite->createTables(ctx->m_cluster_connection);
1113 Ndb ndb(&ctx->m_cluster_connection,
"TEST_DB");
1118 const char *tab_name= pTab->
getName();
1122 g_err <<
"runCreateTable: Failed to drop table " << tab_name << endl
1127 if(NDBT_Tables::createTable(&ndb, tab_name,
1128 !ctx->getSuite()->getLogging()) != 0)
1130 g_err <<
"runCreateTable: Failed to create table " << tab_name
1138 ctx->setProperty(
"$table", tab_name);
1147 Ndb ndb(&con,
"TEST_DB");
1151 for(
unsigned i = 0; i<m_tables_in_test.size(); i++)
1153 const char *tab_name= m_tables_in_test[
i].c_str();
1164 return suite->dropTables(ctx->m_cluster_connection);
1171 const char * tab_name = ctx->getProperty(
"$table", (
const char*)0);
1174 Ndb ndb(&ctx->m_cluster_connection,
"TEST_DB");
1187 Ndb ndb(&ctx->m_cluster_connection,
"TEST_DB");
1192 const char *tab_name= pTab->
getName();
1196 if (pDictTab == NULL)
1198 g_err <<
"runCheckTableExists : Failed to find table "
1199 << tab_name << endl;
1200 g_err <<
"Required schema : " << *((
NDBT_Table*)pTab) << endl;
1209 ctx->setTab(pDictTab);
1210 ctx->setProperty(
"$table", tab_name);
1222 NDBT_TestSuite::report(
const char* _tcname){
1224 ndbout <<
"Completed " << name <<
" [" <<
getDate() <<
"]" << endl;
1225 printTestCaseSummary(_tcname);
1226 ndbout << numTestsExecuted <<
" test(s) executed" << endl;
1227 ndbout << numTestsOk <<
" test(s) OK"
1229 if(numTestsFail > 0)
1230 ndbout << numTestsFail <<
" test(s) failed"
1232 testSuiteTimer.printTotalTime();
1233 if (numTestsFail > 0 || numTestsExecuted == 0){
1234 result = NDBT_FAILED;
1241 void NDBT_TestSuite::printTestCaseSummary(
const char* _tcname){
1242 ndbout <<
"= SUMMARY OF TEST EXECUTION ==============" << endl;
1243 for (
unsigned t = 0; t < tests.size(); t++){
1244 if (_tcname != NULL &&
1245 strcasecmp(tests[t]->getName(), _tcname) != 0)
1248 tests[t]->printTestResult();
1250 ndbout <<
"==========================================" << endl;
1253 int NDBT_TestSuite::reportAllTables(
const char* _testname){
1255 ndbout <<
"Completed running test [" <<
getDate() <<
"]" << endl;
1256 const int totalNumTests = numTestsExecuted;
1257 printTestCaseSummary(_testname);
1258 ndbout << numTestsExecuted<<
" test(s) executed" << endl;
1259 ndbout << numTestsOk <<
" test(s) OK("
1260 <<(int)(((
float)numTestsOk/totalNumTests)*100.0) <<
"%)"
1262 if(numTestsFail > 0)
1263 ndbout << numTestsFail <<
" test(s) failed("
1264 <<(int)(((
float)numTestsFail/totalNumTests)*100.0) <<"%)"
1266 testSuiteTimer.printTotalTime();
1267 if (numTestsExecuted > 0){
1268 if (numTestsFail > 0){
1269 result = NDBT_FAILED;
1274 result = NDBT_FAILED;
1279 static int opt_print =
false;
1280 static int opt_print_html =
false;
1281 static int opt_print_cases =
false;
1282 static int opt_records;
1283 static int opt_loops;
1284 static int opt_timer;
1285 static char * opt_testname = NULL;
1286 static int opt_verbose;
1287 unsigned opt_seed = 0;
1288 static int opt_nologging = 0;
1289 static int opt_temporary = 0;
1290 static int opt_noddl = 0;
1291 static int opt_forceShort = 0;
1293 static struct my_option my_long_options[] =
1296 {
"print", NDB_OPT_NOSHORT,
"Print execution tree",
1297 (uchar **) &opt_print, (uchar **) &opt_print, 0,
1298 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
1299 {
"print_html", NDB_OPT_NOSHORT,
"Print execution tree in html table format",
1300 (uchar **) &opt_print_html, (uchar **) &opt_print_html, 0,
1301 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
1302 {
"print_cases", NDB_OPT_NOSHORT,
"Print list of test cases",
1303 (uchar **) &opt_print_cases, (uchar **) &opt_print_cases, 0,
1304 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
1305 {
"records",
'r',
"Number of records",
1306 (uchar **) &opt_records, (uchar **) &opt_records, 0,
1307 GET_INT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0 },
1308 {
"loops",
'l',
"Number of loops",
1309 (uchar **) &opt_loops, (uchar **) &opt_loops, 0,
1310 GET_INT, REQUIRED_ARG, 5, 0, 0, 0, 0, 0 },
1311 {
"seed", NDB_OPT_NOSHORT,
"Random seed",
1312 (uchar **) &opt_seed, (uchar **) &opt_seed, 0,
1313 GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1314 {
"testname",
'n',
"Name of test to run",
1315 (uchar **) &opt_testname, (uchar **) &opt_testname, 0,
1316 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
1317 {
"timer",
't',
"Print execution time",
1318 (uchar **) &opt_timer, (uchar **) &opt_timer, 0,
1319 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
1320 {
"verbose",
'v',
"Print verbose status",
1321 (uchar **) &opt_verbose, (uchar **) &opt_verbose, 0,
1322 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
1323 {
"temporary-tables",
'T',
"Create temporary table(s)",
1324 (uchar **) &opt_temporary, (uchar **) &opt_temporary, 0,
1325 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
1326 {
"nologging", NDB_OPT_NOSHORT,
"Create table(s) wo/ logging",
1327 (uchar **) &opt_nologging, (uchar **) &opt_nologging, 0,
1328 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
1329 {
"noddl", NDB_OPT_NOSHORT,
1330 "Don't create/drop tables as part of running tests",
1331 (uchar**) &opt_noddl, (uchar**) &opt_noddl, 0,
1332 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
1333 {
"forceshortreqs", NDB_OPT_NOSHORT,
"Use short signals for NdbApi requests",
1334 (uchar**) &opt_forceShort, (uchar**) &opt_forceShort, 0,
1335 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
1336 { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1339 extern int global_flag_skip_invalidate_cache;
1341 const char *load_default_groups[]= {
"mysql_cluster",0 };
1343 static void short_usage_sub(
void)
1345 ndb_short_usage_sub(
"[tabname1 tabname2 ... tabnameN]");
1349 ndb_usage(short_usage_sub, load_default_groups, my_long_options);
1352 int NDBT_TestSuite::execute(
int argc,
const char** argv){
1353 int res = NDBT_FAILED;
1374 char **_argv= (
char **)argv;
1377 my_progname= _argv[0];
1379 ndb_opt_set_usage_funcs(short_usage_sub, usage);
1381 load_defaults(
"my",load_default_groups,&argc,&_argv);
1385 opt_debug=
"d:t:i:F:L";
1387 if ((ho_error=handle_options(&argc, &_argv, my_long_options,
1388 ndb_std_get_one_option)))
1391 return NDBT_ProgramExit(NDBT_WRONGARGS);
1399 records = opt_records;
1404 temporaryTables = opt_temporary;
1405 m_noddl = opt_noddl;
1406 m_forceShort = opt_forceShort;
1410 opt_seed = (unsigned)NdbTick_CurrentMillisecond();
1412 ndbout_c(
"random seed: %u", opt_seed);
1416 global_flag_skip_invalidate_cache = 1;
1418 int num_tables= argc;
1420 num_tables = NDBT_Tables::getNumTables();
1422 for(
int i = 0; i<num_tables; i++)
1425 m_tables_in_test.push_back(NDBT_Tables::getTable(i)->getName());
1427 m_tables_in_test.push_back(_argv[i]);
1432 for (
unsigned t = 0; t < tests.size(); t++)
1434 const char* createFuncName= NULL;
1435 NDBT_TESTFUNC* createFunc= NULL;
1436 const char* dropFuncName= NULL;
1437 NDBT_TESTFUNC* dropFunc= NULL;
1441 createFuncName= m_createAll ?
"runCreateTable" :
"runCreateTable";
1442 createFunc= m_createAll ? &runCreateTables : &runCreateTable;
1443 dropFuncName= m_createAll ?
"runDropTables" :
"runDropTable";
1444 dropFunc= m_createAll ? &runDropTables : &runDropTable;
1451 createFuncName=
"runCheckTableExists";
1452 createFunc= &runCheckTableExists;
1453 dropFuncName=
"runEmptyDropTable";
1454 dropFunc= &runEmptyDropTable;
1462 pt->addInitializer(pti,
true);
1467 pt->addFinalizer(ptf);
1471 if (opt_print ==
true){
1472 printExecutionTree();
1476 if (opt_print_html ==
true){
1477 printExecutionTreeHTML();
1481 if (opt_print_cases ==
true){
1487 if(m_connect_cluster && con.
connect(12, 5, 1))
1489 return NDBT_ProgramExit(NDBT_FAILED);
1494 res = executeAll(con, opt_testname);
1496 testSuiteTimer.doStart();
1497 for(
int i = 0; i<argc; i++){
1498 executeOne(con, _argv[i], opt_testname);
1500 testSuiteTimer.doStop();
1501 res = report(opt_testname);
1504 return NDBT_ProgramExit(res);
1508 void NDBT_TestSuite::printExecutionTree(){
1509 ndbout <<
"Testsuite: " << name << endl;
1510 for (
unsigned t = 0; t < tests.size(); t++){
1516 void NDBT_TestSuite::printExecutionTreeHTML(){
1517 ndbout <<
"<tr>" << endl;
1518 ndbout <<
"<td><h3>" << name <<
"</h3></td>" << endl;
1519 ndbout <<
"</tr>" << endl;
1520 for (
unsigned t = 0; t < tests.size(); t++){
1521 tests[t]->printHTML();
1527 void NDBT_TestSuite::printCases(){
1528 ndbout <<
"# Testsuite: " << name << endl;
1529 ndbout <<
"# Number of tests: " << tests.size() << endl;
1530 for (
unsigned t = 0; t < tests.size(); t++){
1531 ndbout << name <<
" -n " << tests[t]->getName() << endl;
1536 static char theTime[128];
1539 now = time((time_t*)NULL);
1541 tm_now = localtime(&now);
1543 tm_now = gmtime(&now);
1547 "%d-%.2d-%.2d %.2d:%.2d:%.2d",
1548 tm_now->tm_year + 1900,
1558 void NDBT_TestCaseImpl1::printHTML(){
1560 ndbout <<
"<tr><td> </td>" << endl;
1561 ndbout <<
"<td name=tc>" << endl << _name <<
"</td><td width=70%>"
1562 << _comment <<
"</td></tr>" << endl;
1565 void NDBT_TestCaseImpl1::print(){
1566 ndbout <<
"Test case: " << _name << endl;
1567 ndbout <<
"Description: "<< _comment << endl;
1569 ndbout <<
"Parameters: " << endl;
1572 for(
const char * key = it.first(); key != 0; key = it.next()){
1574 const bool b = props.getTypeOf(key, &pt);
1577 case PropertiesType_Uint32:{
1579 props.get(key, &val);
1580 ndbout <<
" " << key <<
": " << val << endl;
1583 case PropertiesType_char:{
1585 props.get(key, &val);
1586 ndbout <<
" " << key <<
": " << val << endl;
1594 for(i=0; i<initializers.size(); i++){
1595 ndbout <<
"Initializers[" << i <<
"]: " << endl;
1596 initializers[
i]->print();
1598 for(i=0; i<steps.size(); i++){
1599 ndbout <<
"Step[" << i <<
"]: " << endl;
1602 for(i=0; i<verifiers.size(); i++){
1603 ndbout <<
"Verifier[" << i <<
"]: " << endl;
1604 verifiers[
i]->print();
1606 for(i=0; i<finalizers.size(); i++){
1607 ndbout <<
"Finalizer[" << i <<
"]: " << endl;
1608 finalizers[
i]->print();
1613 void NDBT_Step::print(){
1614 ndbout <<
" "<< name << endl;
1620 Uint32 threads = getProperty(key, (
unsigned)0);
1627 NDBT_Context::sync_up_and_wait(
const char * key, Uint32 value){
1628 setProperty(key, value);
1629 getPropertyWait(key, (
unsigned)0);