Commit 83bf0251 authored by unknown's avatar unknown

testBank

    optimized for fewer timeouts
    changed for consistency in "time"
tests
    moved SR_UNDO tests to basic
    added testBackup -n BackupBank


ndb/test/ndbapi/bank/Bank.cpp:
  optimized for fewer timeouts
  changed for consistency in "time"
ndb/test/ndbapi/bank/Bank.hpp:
  optimized for fewer timeouts
  changed for consistency in "time"
ndb/test/run-test/daily-basic-tests.txt:
  moved SR_UNDO tests to basic
ndb/test/run-test/daily-devel-tests.txt:
  moved SR_UNDO tests to basic
  added testBackup -n BackupBank
parent 16bd53d4
...@@ -156,7 +156,14 @@ int Bank::performTransactionImpl1(int fromAccountId, ...@@ -156,7 +156,14 @@ int Bank::performTransactionImpl1(int fromAccountId,
int check; int check;
// Ok, all clear to do the transaction
Uint64 transId;
if (getNextTransactionId(transId) != NDBT_OK){
return NDBT_FAILED;
}
NdbConnection* pTrans = m_ndb.startTransaction(); NdbConnection* pTrans = m_ndb.startTransaction();
if( pTrans == NULL ) { if( pTrans == NULL ) {
const NdbError err = m_ndb.getNdbError(); const NdbError err = m_ndb.getNdbError();
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
...@@ -167,6 +174,13 @@ int Bank::performTransactionImpl1(int fromAccountId, ...@@ -167,6 +174,13 @@ int Bank::performTransactionImpl1(int fromAccountId,
return NDBT_FAILED; return NDBT_FAILED;
} }
Uint64 currTime;
if (prepareGetCurrTimeOp(pTrans, currTime) != NDBT_OK){
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
return NDBT_FAILED;
}
/** /**
* Check balance on from account * Check balance on from account
*/ */
...@@ -205,29 +219,6 @@ int Bank::performTransactionImpl1(int fromAccountId, ...@@ -205,29 +219,6 @@ int Bank::performTransactionImpl1(int fromAccountId,
return NDBT_FAILED; return NDBT_FAILED;
} }
check = pTrans->execute(NoCommit);
if( check == -1 ) {
const NdbError err = pTrans->getNdbError();
m_ndb.closeTransaction(pTrans);
if (err.status == NdbError::TemporaryError){
ERR(err);
return NDBT_TEMPORARY;
}
ERR(err);
return NDBT_FAILED;
}
Uint32 balanceFrom = balanceFromRec->u_32_value();
// ndbout << "balanceFrom: " << balanceFrom << endl;
if (((Int64)balanceFrom - amount) < 0){
m_ndb.closeTransaction(pTrans);
//ndbout << "Not enough funds" << endl;
return NOT_ENOUGH_FUNDS;
}
Uint32 fromAccountType = fromAccountTypeRec->u_32_value();
/** /**
* Read balance on to account * Read balance on to account
*/ */
...@@ -278,21 +269,22 @@ int Bank::performTransactionImpl1(int fromAccountId, ...@@ -278,21 +269,22 @@ int Bank::performTransactionImpl1(int fromAccountId,
return NDBT_FAILED; return NDBT_FAILED;
} }
Uint32 balanceTo = balanceToRec->u_32_value();
// ndbout << "balanceTo: " << balanceTo << endl;
Uint32 toAccountType = toAccountTypeRec->u_32_value();
// Ok, all clear to do the transaction Uint32 balanceFrom = balanceFromRec->u_32_value();
Uint64 transId; // ndbout << "balanceFrom: " << balanceFrom << endl;
if (getNextTransactionId(transId) != NDBT_OK){
return NDBT_FAILED;
}
Uint64 currTime; if (((Int64)balanceFrom - amount) < 0){
if (getCurrTime(currTime) != NDBT_OK){ m_ndb.closeTransaction(pTrans);
return NDBT_FAILED; //ndbout << "Not enough funds" << endl;
return NOT_ENOUGH_FUNDS;
} }
Uint32 fromAccountType = fromAccountTypeRec->u_32_value();
Uint32 balanceTo = balanceToRec->u_32_value();
// ndbout << "balanceTo: " << balanceTo << endl;
Uint32 toAccountType = toAccountTypeRec->u_32_value();
/** /**
* Update balance on from account * Update balance on from account
*/ */
...@@ -1988,47 +1980,50 @@ int Bank::readSystemValue(SystemValueId sysValId, Uint64 & value){ ...@@ -1988,47 +1980,50 @@ int Bank::readSystemValue(SystemValueId sysValId, Uint64 & value){
ERR(m_ndb.getNdbError()); ERR(m_ndb.getNdbError());
return NDBT_FAILED; return NDBT_FAILED;
} }
NdbOperation* pOp = pTrans->getNdbOperation("SYSTEM_VALUES"); if (prepareReadSystemValueOp(pTrans, sysValId, value) != NDBT_OK) {
if (pOp == NULL) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans); m_ndb.closeTransaction(pTrans);
return NDBT_FAILED; return NDBT_FAILED;
} }
check = pOp->readTuple(); check = pTrans->execute(Commit);
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans); m_ndb.closeTransaction(pTrans);
return NDBT_FAILED; return NDBT_FAILED;
} }
check = pOp->equal("SYSTEM_VALUES_ID", sysValId); m_ndb.closeTransaction(pTrans);
if( check == -1 ) { return NDBT_OK;
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans); }
int Bank::prepareReadSystemValueOp(NdbConnection* pTrans, SystemValueId sysValId, Uint64 & value){
int check;
NdbOperation* pOp = pTrans->getNdbOperation("SYSTEM_VALUES");
if (pOp == NULL) {
return NDBT_FAILED; return NDBT_FAILED;
} }
NdbRecAttr* valueRec = pOp->getValue("VALUE"); check = pOp->readTuple();
if( valueRec ==NULL ) { if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
return NDBT_FAILED; return NDBT_FAILED;
} }
check = pTrans->execute(Commit); check = pOp->equal("SYSTEM_VALUES_ID", sysValId);
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
return NDBT_FAILED; return NDBT_FAILED;
} }
value = valueRec->u_64_value(); NdbRecAttr* valueRec = pOp->getValue("VALUE", (char *)&value);
if( valueRec == NULL ) {
return NDBT_FAILED;
}
m_ndb.closeTransaction(pTrans);
return NDBT_OK; return NDBT_OK;
} }
int Bank::writeSystemValue(SystemValueId sysValId, Uint64 value){ int Bank::writeSystemValue(SystemValueId sysValId, Uint64 value){
...@@ -2307,6 +2302,10 @@ int Bank::getCurrTime(Uint64 &time){ ...@@ -2307,6 +2302,10 @@ int Bank::getCurrTime(Uint64 &time){
return readSystemValue(CurrentTime, time); return readSystemValue(CurrentTime, time);
} }
int Bank::prepareGetCurrTimeOp(NdbConnection *pTrans, Uint64 &time){
return prepareReadSystemValueOp(pTrans, CurrentTime, time);
}
int Bank::performSumAccounts(int maxSleepBetweenSums, int yield){ int Bank::performSumAccounts(int maxSleepBetweenSums, int yield){
if (init() != NDBT_OK) if (init() != NDBT_OK)
......
...@@ -118,6 +118,9 @@ private: ...@@ -118,6 +118,9 @@ private:
int incCurrTime(Uint64 &value); int incCurrTime(Uint64 &value);
int getCurrTime(Uint64 &time); int getCurrTime(Uint64 &time);
int prepareReadSystemValueOp(NdbConnection*, SystemValueId sysValId, Uint64 &time);
int prepareGetCurrTimeOp(NdbConnection*, Uint64 &time);
int createTables(); int createTables();
int createTable(const char* tabName); int createTable(const char* tabName);
......
...@@ -1006,3 +1006,18 @@ max-time: 1500 ...@@ -1006,3 +1006,18 @@ max-time: 1500
cmd: testSystemRestart cmd: testSystemRestart
args: -n SR2 T7 args: -n SR2 T7
max-time: 1500
cmd: testSystemRestart
args: -n SR_UNDO T1
max-time: 1500
cmd: testSystemRestart
args: -n SR_UNDO T6
max-time: 1500
cmd: testSystemRestart
args: -n SR_UNDO T7
max-time: 1500
cmd: testSystemRestart
args: -n SR_UNDO T8
...@@ -26,10 +26,10 @@ max-time: 600 ...@@ -26,10 +26,10 @@ max-time: 600
cmd: atrt-testBackup cmd: atrt-testBackup
args: -n BackupOne T1 T6 T3 I3 args: -n BackupOne T1 T6 T3 I3
#max-time: 600 max-time: 1000
#cmd: testBackup cmd: testBackup
#args: -n BackupBank T6 args: -n BackupBank T6
#
# #
# MGMAPI AND MGSRV # MGMAPI AND MGSRV
# #
...@@ -41,21 +41,6 @@ args: -n SingleUserMode T1 ...@@ -41,21 +41,6 @@ args: -n SingleUserMode T1
# #
# SYSTEM RESTARTS # SYSTEM RESTARTS
# #
max-time: 1500
cmd: testSystemRestart
args: -n SR_UNDO T1
max-time: 1500
cmd: testSystemRestart
args: -n SR_UNDO T6
max-time: 1500
cmd: testSystemRestart
args: -n SR_UNDO T7
max-time: 1500
cmd: testSystemRestart
args: -n SR_UNDO T8
max-time: 1500 max-time: 1500
cmd: testSystemRestart cmd: testSystemRestart
......
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