diff options
author | unknown <jonas@eel.(none)> | 2005-09-09 13:30:38 +0200 |
---|---|---|
committer | unknown <jonas@eel.(none)> | 2005-09-09 13:30:38 +0200 |
commit | 12dbb18815863e82b91c4cc3eb4d28404720a11f (patch) | |
tree | 0eb3c618a57f75600f5f0f758d521ccaa8e167b0 /storage/ndb/test | |
parent | e371b26468bdb67fe668f3582c2f061c61835e84 (diff) | |
parent | 394d180b5e04504c9e2d52d1eaa4904b2056eb19 (diff) | |
download | mariadb-git-12dbb18815863e82b91c4cc3eb4d28404720a11f.tar.gz |
Merge eel.(none):/home/jonas/src/mysql-5.0
into eel.(none):/home/jonas/src/mysql-5.1-push
sql/set_var.cc:
Auto merged
sql/set_var.h:
Auto merged
sql/sql_show.cc:
Auto merged
storage/ndb/src/common/portlib/NdbThread.c:
Auto merged
storage/ndb/test/include/NDBT_Test.hpp:
Auto merged
storage/ndb/test/ndbapi/Makefile.am:
Auto merged
storage/ndb/test/ndbapi/bank/Bank.cpp:
Auto merged
storage/ndb/test/ndbapi/bank/Bank.hpp:
Auto merged
storage/ndb/test/src/NDBT_Test.cpp:
Auto merged
storage/ndb/test/src/UtilTransactions.cpp:
Auto merged
Diffstat (limited to 'storage/ndb/test')
-rw-r--r-- | storage/ndb/test/include/NDBT_Test.hpp | 3 | ||||
-rw-r--r-- | storage/ndb/test/ndbapi/Makefile.am | 5 | ||||
-rw-r--r-- | storage/ndb/test/ndbapi/bank/Bank.cpp | 168 | ||||
-rw-r--r-- | storage/ndb/test/ndbapi/bank/Bank.hpp | 2 | ||||
-rw-r--r-- | storage/ndb/test/src/NDBT_Test.cpp | 9 |
5 files changed, 102 insertions, 85 deletions
diff --git a/storage/ndb/test/include/NDBT_Test.hpp b/storage/ndb/test/include/NDBT_Test.hpp index 1b9c2751f64..027ac356e0c 100644 --- a/storage/ndb/test/include/NDBT_Test.hpp +++ b/storage/ndb/test/include/NDBT_Test.hpp @@ -67,7 +67,8 @@ public: const char* getPropertyWait(const char*, const char* ); void decProperty(const char *); - + void incProperty(const char *); + // Communicate with other tests void stopTest(); bool isTestStopped(); diff --git a/storage/ndb/test/ndbapi/Makefile.am b/storage/ndb/test/ndbapi/Makefile.am index f096a7c74e9..bf993d30111 100644 --- a/storage/ndb/test/ndbapi/Makefile.am +++ b/storage/ndb/test/ndbapi/Makefile.am @@ -34,7 +34,8 @@ test_event ndbapi_slow_select testReadPerf testLcp \ testPartitioning \ testBitfield \ DbCreate DbAsyncGenerator \ -test_event_multi_table +test_event_multi_table \ +testSRBank #flexTimedAsynch #testBlobs @@ -78,6 +79,7 @@ testBitfield_SOURCES = testBitfield.cpp DbCreate_SOURCES = bench/mainPopulate.cpp bench/dbPopulate.cpp bench/userInterface.cpp bench/dbPopulate.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp DbAsyncGenerator_SOURCES = bench/mainAsyncGenerator.cpp bench/asyncGenerator.cpp bench/ndb_async2.cpp bench/dbGenerator.h bench/macros.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp test_event_multi_table_SOURCES = test_event_multi_table.cpp +testSRBank_SOURCES = testSRBank.cpp INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/include/kernel @@ -89,6 +91,7 @@ include $(top_srcdir)/storage/ndb/config/type_ndbapitest.mk.am ##testSystemRestart_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel ##testTransactions_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel testBackup_LDADD = $(LDADD) bank/libbank.a +testSRBank_LDADD = bank/libbank.a $(LDADD) # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/storage/ndb/test/ndbapi/bank/Bank.cpp b/storage/ndb/test/ndbapi/bank/Bank.cpp index 40819ecc849..37224fdd055 100644 --- a/storage/ndb/test/ndbapi/bank/Bank.cpp +++ b/storage/ndb/test/ndbapi/bank/Bank.cpp @@ -19,12 +19,13 @@ #include <NdbSleep.h> #include <UtilTransactions.hpp> -Bank::Bank(Ndb_cluster_connection& con): +Bank::Bank(Ndb_cluster_connection& con, bool _init): m_ndb(&con, "BANK"), m_maxAccount(-1), m_initialized(false) { - + if(_init) + init(); } int Bank::init(){ @@ -34,40 +35,39 @@ int Bank::init(){ myRandom48Init(NdbTick_CurrentMillisecond()); m_ndb.init(); - while (m_ndb.waitUntilReady(10) != 0) - ndbout << "Waiting for ndb to be ready" << endl; - + if (m_ndb.waitUntilReady(30) != 0) + { + ndbout << "Ndb not ready" << endl; + return NDBT_FAILED; + } + if (getNumAccounts() != NDBT_OK) return NDBT_FAILED; + + m_initialized = true; return NDBT_OK; } int Bank::performTransactions(int maxSleepBetweenTrans, int yield){ - if (init() != NDBT_OK) - return NDBT_FAILED; int transactions = 0; - while(1){ - - while(m_ndb.waitUntilReady(10) != 0) - ndbout << "Waiting for ndb to be ready" << endl; - - while(performTransaction() != NDBT_FAILED){ - transactions++; - - if (maxSleepBetweenTrans > 0){ - int val = myRandom48(maxSleepBetweenTrans); - NdbSleep_MilliSleep(val); - } - - if((transactions % 100) == 0) - g_info << transactions << endl; - - if (yield != 0 && transactions >= yield) - return NDBT_OK; + while(performTransaction() == NDBT_OK) + { + transactions++; + + if (maxSleepBetweenTrans > 0){ + int val = myRandom48(maxSleepBetweenTrans); + NdbSleep_MilliSleep(val); } + + if((transactions % 100) == 0) + g_info << transactions << endl; + + if (yield != 0 && transactions >= yield) + return NDBT_OK; } + return NDBT_FAILED; } @@ -92,7 +92,7 @@ int Bank::performTransaction(){ int amount = myRandom48(maxAmount); - retry_transaction: +retry_transaction: int res = performTransaction(fromAccount, toAccount, amount); if (res != 0){ switch (res){ @@ -158,8 +158,9 @@ int Bank::performTransactionImpl1(int fromAccountId, // Ok, all clear to do the transaction Uint64 transId; - if (getNextTransactionId(transId) != NDBT_OK){ - return NDBT_FAILED; + int result = NDBT_OK; + if ((result= getNextTransactionId(transId)) != NDBT_OK){ + return result; } NdbConnection* pTrans = m_ndb.startTransaction(); @@ -500,8 +501,6 @@ int Bank::performTransactionImpl1(int fromAccountId, int Bank::performMakeGLs(int yield){ int result; - if (init() != NDBT_OK) - return NDBT_FAILED; int counter, maxCounter; int yieldCounter = 0; @@ -512,9 +511,6 @@ int Bank::performMakeGLs(int yield){ counter = 0; maxCounter = 50 + myRandom48(100); - while(m_ndb.waitUntilReady(10) != 0) - ndbout << "Waiting for ndb to be ready" << endl; - /** * Validate GLs and Transactions for previous days * @@ -526,6 +522,7 @@ int Bank::performMakeGLs(int yield){ return NDBT_FAILED; } g_info << "performValidateGLs failed" << endl; + return NDBT_FAILED; continue; } @@ -536,7 +533,7 @@ int Bank::performMakeGLs(int yield){ return NDBT_FAILED; } g_info << "performValidatePurged failed" << endl; - continue; + return NDBT_FAILED; } while (1){ @@ -607,14 +604,9 @@ int Bank::performMakeGLs(int yield){ int Bank::performValidateAllGLs(){ int result; - if (init() != NDBT_OK) - return NDBT_FAILED; while (1){ - while(m_ndb.waitUntilReady(10) != 0) - ndbout << "Waiting for ndb to be ready" << endl; - /** * Validate GLs and Transactions for previous days * Set age so that ALL GL's are validated @@ -1930,39 +1922,29 @@ int Bank::findTransactionsToPurge(const Uint64 glTime, } - int Bank::performIncreaseTime(int maxSleepBetweenDays, int yield){ - if (init() != NDBT_OK) - return NDBT_FAILED; - +int Bank::performIncreaseTime(int maxSleepBetweenDays, int yield) +{ int yieldCounter = 0; - - while(1){ - - while(m_ndb.waitUntilReady(10) != 0) - ndbout << "Waiting for ndb to be ready" << endl; - - while(1){ - - Uint64 currTime; - if (incCurrTime(currTime) != NDBT_OK) - break; - - g_info << "Current time is " << currTime << endl; - if (maxSleepBetweenDays > 0){ - int val = myRandom48(maxSleepBetweenDays); - NdbSleep_SecSleep(val); - } - - yieldCounter++; - if (yield != 0 && yieldCounter >= yield) - return NDBT_OK; - - } - } - return NDBT_FAILED; - } - - + + while(1){ + + Uint64 currTime; + if (incCurrTime(currTime) != NDBT_OK) + break; + + g_info << "Current time is " << currTime << endl; + if (maxSleepBetweenDays > 0){ + int val = myRandom48(maxSleepBetweenDays); + NdbSleep_SecSleep(val); + } + + yieldCounter++; + if (yield != 0 && yieldCounter >= yield) + return NDBT_OK; + + } + return NDBT_FAILED; +} int Bank::readSystemValue(SystemValueId sysValId, Uint64 & value){ @@ -1971,22 +1953,30 @@ int Bank::readSystemValue(SystemValueId sysValId, Uint64 & value){ NdbConnection* pTrans = m_ndb.startTransaction(); if (pTrans == NULL){ ERR(m_ndb.getNdbError()); + if(m_ndb.getNdbError().status == NdbError::TemporaryError) + return NDBT_TEMPORARY; return NDBT_FAILED; } - if (prepareReadSystemValueOp(pTrans, sysValId, value) != NDBT_OK) { + int result; + if ((result= prepareReadSystemValueOp(pTrans, sysValId, value)) != NDBT_OK) { ERR(pTrans->getNdbError()); m_ndb.closeTransaction(pTrans); - return NDBT_FAILED; + return result; } check = pTrans->execute(Commit); if( check == -1 ) { ERR(pTrans->getNdbError()); + if(pTrans->getNdbError().status == NdbError::TemporaryError) + { + m_ndb.closeTransaction(pTrans); + return NDBT_TEMPORARY; + } m_ndb.closeTransaction(pTrans); return NDBT_FAILED; } - + m_ndb.closeTransaction(pTrans); return NDBT_OK; @@ -2092,6 +2082,8 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){ NdbConnection* pTrans = m_ndb.startTransaction(); if (pTrans == NULL){ ERR(m_ndb.getNdbError()); + if (m_ndb.getNdbError().status == NdbError::TemporaryError) + DBUG_RETURN(NDBT_TEMPORARY); DBUG_RETURN(NDBT_FAILED); } @@ -2127,6 +2119,11 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){ check = pTrans->execute(NoCommit); if( check == -1 ) { ERR(pTrans->getNdbError()); + if (pTrans->getNdbError().status == NdbError::TemporaryError) + { + m_ndb.closeTransaction(pTrans); + DBUG_RETURN(NDBT_TEMPORARY); + } m_ndb.closeTransaction(pTrans); DBUG_RETURN(NDBT_FAILED); } @@ -2201,16 +2198,21 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){ check = pTrans->execute(Commit); if( check == -1 ) { ERR(pTrans->getNdbError()); + if (pTrans->getNdbError().status == NdbError::TemporaryError) + { + m_ndb.closeTransaction(pTrans); + DBUG_RETURN(NDBT_TEMPORARY); + } m_ndb.closeTransaction(pTrans); DBUG_RETURN(NDBT_FAILED); } // Check that value updated equals the value we read after the update if (valueNewRec->u_64_value() != value){ - + printf("value actual=%lld\n", valueNewRec->u_64_value()); printf("value expected=%lld actual=%lld\n", value, valueNewRec->u_64_value()); - + DBUG_PRINT("info", ("value expected=%ld actual=%ld", value, valueNewRec->u_64_value())); g_err << "getNextTransactionId: value was not updated" << endl; m_ndb.closeTransaction(pTrans); @@ -2218,7 +2220,7 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){ } m_ndb.closeTransaction(pTrans); - + DBUG_RETURN(0); } @@ -2235,6 +2237,8 @@ int Bank::increaseSystemValue2(SystemValueId sysValId, Uint64 &value){ NdbConnection* pTrans = m_ndb.startTransaction(); if (pTrans == NULL){ ERR(m_ndb.getNdbError()); + if(m_ndb.getNdbError().status == NdbError::TemporaryError) + return NDBT_TEMPORARY; return NDBT_FAILED; } @@ -2277,6 +2281,11 @@ int Bank::increaseSystemValue2(SystemValueId sysValId, Uint64 &value){ check = pTrans->execute(Commit); if( check == -1 ) { ERR(pTrans->getNdbError()); + if(pTrans->getNdbError().status == NdbError::TemporaryError) + { + m_ndb.closeTransaction(pTrans); + return NDBT_TEMPORARY; + } m_ndb.closeTransaction(pTrans); return NDBT_FAILED; } @@ -2301,16 +2310,11 @@ int Bank::prepareGetCurrTimeOp(NdbConnection *pTrans, Uint64 &time){ int Bank::performSumAccounts(int maxSleepBetweenSums, int yield){ - if (init() != NDBT_OK) - return NDBT_FAILED; int yieldCounter = 0; while (1){ - while (m_ndb.waitUntilReady(10) != 0) - ndbout << "Waiting for ndb to be ready" << endl; - Uint32 sumAccounts = 0; Uint32 numAccounts = 0; if (getSumAccounts(sumAccounts, numAccounts) != NDBT_OK){ diff --git a/storage/ndb/test/ndbapi/bank/Bank.hpp b/storage/ndb/test/ndbapi/bank/Bank.hpp index d9dd7b25944..b80f02dae97 100644 --- a/storage/ndb/test/ndbapi/bank/Bank.hpp +++ b/storage/ndb/test/ndbapi/bank/Bank.hpp @@ -27,7 +27,7 @@ class Bank { public: - Bank(Ndb_cluster_connection&); + Bank(Ndb_cluster_connection&, bool init = true); int createAndLoadBank(bool overWrite, int num_accounts=10); int dropBank(); diff --git a/storage/ndb/test/src/NDBT_Test.cpp b/storage/ndb/test/src/NDBT_Test.cpp index 7fd92db533e..8fecf56531f 100644 --- a/storage/ndb/test/src/NDBT_Test.cpp +++ b/storage/ndb/test/src/NDBT_Test.cpp @@ -148,6 +148,15 @@ NDBT_Context::decProperty(const char * name){ NdbCondition_Broadcast(propertyCondPtr); NdbMutex_Unlock(propertyMutexPtr); } +void +NDBT_Context::incProperty(const char * name){ + NdbMutex_Lock(propertyMutexPtr); + Uint32 val = 0; + props.get(name, &val); + props.put(name, (val + 1), true); + NdbCondition_Broadcast(propertyCondPtr); + NdbMutex_Unlock(propertyMutexPtr); +} void NDBT_Context::setProperty(const char* _name, const char* _val){ NdbMutex_Lock(propertyMutexPtr); |