mirror of
https://github.com/MariaDB/server.git
synced 2025-09-03 20:43:11 +03:00
into mysql.com:/home/my/mysql-5.1 BUILD/FINISH.sh: Auto merged BitKeeper/deleted/.del-makefilewin.i~5c8479dcb8a455b2: Auto merged BitKeeper/deleted/.del-makefilewin~13888739357b3025: Auto merged BitKeeper/deleted/.del-makefilewin~14f24a4a173e2fcd: Auto merged BitKeeper/deleted/.del-makefilewin~15e9e5c9e8fa870b: Auto merged BitKeeper/deleted/.del-makefilewin~1c53f31b88dd36e: Auto merged BitKeeper/deleted/.del-makefilewin~1dbc058d76ebf1db: Auto merged BitKeeper/deleted/.del-makefilewin~2e0407fe123f8365: Auto merged BitKeeper/deleted/.del-makefilewin~2fc379bd4065c995: Auto merged BitKeeper/deleted/.del-makefilewin~389ee2dcf79afb79: Auto merged BitKeeper/deleted/.del-makefilewin~4d139e182457e553: Auto merged BitKeeper/deleted/.del-makefilewin~5104767c73775697: Auto merged BitKeeper/deleted/.del-makefilewin~608ed49dcd88e0f7: Auto merged BitKeeper/deleted/.del-makefilewin~63acd666293282a: Auto merged BitKeeper/deleted/.del-makefilewin~6ba64863bce3d0b8: Auto merged BitKeeper/deleted/.del-makefilewin~72a64128bacce71b: Auto merged BitKeeper/deleted/.del-makefilewin~78000390c783b1c5: Auto merged BitKeeper/deleted/.del-makefilewin~7a9d7d5a42bbfaf5: Auto merged Makefile.am: Auto merged BitKeeper/deleted/.del-makefilewin~a40ea12eebdd6ef0: Auto merged BitKeeper/deleted/.del-makefilewin~aeea7c82f21f7cf5: Auto merged BitKeeper/deleted/.del-makefilewin~b643e38d8da389ac: Auto merged BitKeeper/deleted/.del-makefilewin~c7b621c745e5de95: Auto merged BitKeeper/deleted/.del-makefilewin~c8273a47b90f52bb: Auto merged BitKeeper/deleted/.del-makefilewin~d1a9d1f7d33fcb73: Auto merged BitKeeper/deleted/.del-makefilewin~d37b6b303348c871: Auto merged BitKeeper/deleted/.del-makefilewin~d90f35fdc3f2ee5f: Auto merged BitKeeper/deleted/.del-makefilewin~dc4b8ad5ea53bd: Auto merged BitKeeper/deleted/.del-makefilewin~dea10ec1c94f7be: Auto merged BitKeeper/deleted/.del-makefilewin~ef3a208fa0e9b0db: Auto merged BitKeeper/deleted/.del-makefilewin~f1e3b890aa1c9ea3: Auto merged BitKeeper/deleted/.del-makefilewin~f4b7b99a887b7de: Auto merged BitKeeper/deleted/.del-makefilewin~fdda94ad32fa9e34: Auto merged BitKeeper/deleted/.del-my_cnf~977f69858affc57b: Auto merged BitKeeper/etc/config: Auto merged VC++Files/libmysqld/libmysqld.dsp: Auto merged VC++Files/sql/mysqld.dsp: Auto merged client/mysqltest.c: Auto merged include/Makefile.am: Auto merged include/base64.h: Auto merged include/my_base.h: Auto merged include/mysql_com.h: Auto merged libmysqld/Makefile.am: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/ndb_basic.result: Auto merged mysql-test/r/ndb_condition_pushdown.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/disabled.def: Auto merged mysql-test/t/query_cache.test: Auto merged mysys/Makefile.am: Auto merged mysys/base64.c: Auto merged scripts/make_win_src_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged sql/Makefile.am: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_berkeley.h: Auto merged sql/ha_federated.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item_subselect.cc: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sp.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_help.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged storage/heap/_check.c: Auto merged storage/heap/hp_create.c: Auto merged storage/innobase/include/Makefile.am: Auto merged storage/innobase/include/rem0rec.h: Auto merged storage/innobase/include/rem0rec.ic: Auto merged storage/innobase/row/row0ins.c: Auto merged storage/innobase/row/row0upd.c: Auto merged storage/myisam/mi_check.c: Auto merged storage/myisam/mi_delete.c: Auto merged storage/myisam/mi_rkey.c: Auto merged storage/myisam/mi_rnext_same.c: Auto merged storage/myisam/mi_search.c: Auto merged storage/myisam/mi_write.c: Auto merged storage/myisam/myisamchk.c: Auto merged storage/myisam/myisamdef.h: Auto merged storage/myisam/sort.c: Auto merged storage/myisammrg/myrg_queue.c: Auto merged storage/ndb/config/type_util.mk.am: Auto merged storage/ndb/include/kernel/signaldata/DumpStateOrd.hpp: Auto merged storage/ndb/include/mgmapi/mgmapi_config_parameters.h: Auto merged storage/ndb/include/mgmapi/ndbd_exit_codes.h: Auto merged storage/ndb/include/transporter/TransporterCallback.hpp: Auto merged storage/ndb/src/common/mgmcommon/IPCConfig.cpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.cpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.hpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.unix.cpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.win32.cpp: Auto merged storage/ndb/src/common/transporter/Transporter.hpp: Auto merged storage/ndb/src/common/transporter/TransporterRegistry.cpp: Auto merged storage/ndb/src/common/util/Makefile.am: Auto merged storage/ndb/src/common/util/Parser.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Auto merged storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Auto merged storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Auto merged storage/ndb/src/kernel/error/ndbd_exit_codes.c: Auto merged storage/ndb/src/kernel/vm/FastScheduler.cpp: Auto merged storage/ndb/src/kernel/vm/TransporterCallback.cpp: Auto merged storage/ndb/src/kernel/vm/VMSignal.hpp: Auto merged storage/ndb/src/mgmapi/mgmapi.cpp: Auto merged storage/ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.hpp: Auto merged storage/ndb/src/mgmsrv/Services.cpp: Auto merged storage/ndb/src/ndbapi/TransporterFacade.cpp: Auto merged storage/ndb/test/ndbapi/testBackup.cpp: Auto merged storage/ndb/test/ndbapi/testOperations.cpp: Auto merged storage/ndb/test/src/HugoCalculator.cpp: Auto merged storage/ndb/tools/ndb_condig.cpp: Auto merged strings/ctype-big5.c: Auto merged strings/ctype-ucs2.c: Auto merged support-files/mysql.spec.sh: Auto merged BUILD/SETUP.sh: manual merge configure.in: manual merge mysql-test/r/alter_table.result: manual merge sql/handler.cc: manual merge sql/mysql_priv.h: manual merge sql/records.cc: manual merge sql/share/errmsg.txt: manual merge sql/sql_table.cc: manual merge Fix labels sql/sql_update.cc: manual merge sql/table.cc: manual merge sql/unireg.cc: manual merge storage/ndb/config/type_ndbapi.mk.am: manual merge
559 lines
14 KiB
C++
559 lines
14 KiB
C++
/* Copyright (C) 2003 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#include <NDBT.hpp>
|
|
#include <NDBT_Test.hpp>
|
|
#include <HugoTransactions.hpp>
|
|
#include <UtilTransactions.hpp>
|
|
#include <NdbBackup.hpp>
|
|
|
|
|
|
#define CHECK(b) if (!(b)) { \
|
|
g_err << "ERR: "<< step->getName() \
|
|
<< " failed on line " << __LINE__ << endl; \
|
|
result = NDBT_FAILED; \
|
|
continue; }
|
|
|
|
|
|
int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){
|
|
|
|
int records = ctx->getNumRecords();
|
|
HugoTransactions hugoTrans(*ctx->getTab());
|
|
if (hugoTrans.loadTable(GETNDB(step), records) != 0){
|
|
return NDBT_FAILED;
|
|
}
|
|
return NDBT_OK;
|
|
}
|
|
|
|
bool testMaster = true;
|
|
bool testSlave = false;
|
|
|
|
int setMaster(NDBT_Context* ctx, NDBT_Step* step){
|
|
testMaster = true;
|
|
testSlave = false;
|
|
return NDBT_OK;
|
|
}
|
|
int setMasterAsSlave(NDBT_Context* ctx, NDBT_Step* step){
|
|
testMaster = true;
|
|
testSlave = true;
|
|
return NDBT_OK;
|
|
}
|
|
int setSlave(NDBT_Context* ctx, NDBT_Step* step){
|
|
testMaster = false;
|
|
testSlave = true;
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runAbort(NDBT_Context* ctx, NDBT_Step* step){
|
|
NdbBackup backup(GETNDB(step)->getNodeId()+1);
|
|
|
|
NdbRestarter restarter;
|
|
|
|
if (restarter.getNumDbNodes() < 2){
|
|
ctx->stopTest();
|
|
return NDBT_OK;
|
|
}
|
|
|
|
if(restarter.waitClusterStarted(60) != 0){
|
|
g_err << "Cluster failed to start" << endl;
|
|
return NDBT_FAILED;
|
|
}
|
|
|
|
if (testMaster) {
|
|
if (testSlave) {
|
|
if (backup.NFMasterAsSlave(restarter) != NDBT_OK){
|
|
return NDBT_FAILED;
|
|
}
|
|
} else {
|
|
if (backup.NFMaster(restarter) != NDBT_OK){
|
|
return NDBT_FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
if (backup.NFSlave(restarter) != NDBT_OK){
|
|
return NDBT_FAILED;
|
|
}
|
|
}
|
|
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runFail(NDBT_Context* ctx, NDBT_Step* step){
|
|
NdbBackup backup(GETNDB(step)->getNodeId()+1);
|
|
|
|
NdbRestarter restarter;
|
|
|
|
if (restarter.getNumDbNodes() < 2){
|
|
ctx->stopTest();
|
|
return NDBT_OK;
|
|
}
|
|
|
|
if(restarter.waitClusterStarted(60) != 0){
|
|
g_err << "Cluster failed to start" << endl;
|
|
return NDBT_FAILED;
|
|
}
|
|
|
|
if (testMaster) {
|
|
if (testSlave) {
|
|
if (backup.FailMasterAsSlave(restarter) != NDBT_OK){
|
|
return NDBT_FAILED;
|
|
}
|
|
} else {
|
|
if (backup.FailMaster(restarter) != NDBT_OK){
|
|
return NDBT_FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
if (backup.FailSlave(restarter) != NDBT_OK){
|
|
return NDBT_FAILED;
|
|
}
|
|
}
|
|
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runBackupOne(NDBT_Context* ctx, NDBT_Step* step){
|
|
NdbBackup backup(GETNDB(step)->getNodeId()+1);
|
|
unsigned backupId = 0;
|
|
|
|
if (backup.start(backupId) == -1){
|
|
return NDBT_FAILED;
|
|
}
|
|
ndbout << "Started backup " << backupId << endl;
|
|
ctx->setProperty("BackupId", backupId);
|
|
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int
|
|
runBackupLoop(NDBT_Context* ctx, NDBT_Step* step){
|
|
NdbBackup backup(GETNDB(step)->getNodeId()+1);
|
|
unsigned backupId = 0;
|
|
|
|
int loops = ctx->getNumLoops();
|
|
while(!ctx->isTestStopped() && loops--)
|
|
{
|
|
if (backup.start(backupId) == -1)
|
|
{
|
|
sleep(1);
|
|
loops++;
|
|
}
|
|
else
|
|
{
|
|
sleep(3);
|
|
}
|
|
}
|
|
|
|
ctx->stopTest();
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int
|
|
runDDL(NDBT_Context* ctx, NDBT_Step* step){
|
|
Ndb* pNdb= GETNDB(step);
|
|
NdbDictionary::Dictionary* pDict = pNdb->getDictionary();
|
|
|
|
const int tables = NDBT_Tables::getNumTables();
|
|
while(!ctx->isTestStopped())
|
|
{
|
|
const int tab_no = rand() % (tables);
|
|
NdbDictionary::Table tab = *NDBT_Tables::getTable(tab_no);
|
|
BaseString name= tab.getName();
|
|
name.appfmt("-%d", step->getStepNo());
|
|
tab.setName(name.c_str());
|
|
if(pDict->createTable(tab) == 0)
|
|
{
|
|
HugoTransactions hugoTrans(* pDict->getTable(name.c_str()));
|
|
if (hugoTrans.loadTable(pNdb, 10000) != 0){
|
|
return NDBT_FAILED;
|
|
}
|
|
|
|
while(pDict->dropTable(tab.getName()) != 0 &&
|
|
pDict->getNdbError().code != 4009)
|
|
g_err << pDict->getNdbError() << endl;
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
}
|
|
return NDBT_OK;
|
|
}
|
|
|
|
|
|
int runRestartInitial(NDBT_Context* ctx, NDBT_Step* step){
|
|
NdbRestarter restarter;
|
|
|
|
Ndb* pNdb = GETNDB(step);
|
|
|
|
const NdbDictionary::Table *tab = ctx->getTab();
|
|
pNdb->getDictionary()->dropTable(tab->getName());
|
|
|
|
if (restarter.restartAll(true) != 0)
|
|
return NDBT_FAILED;
|
|
|
|
if (restarter.waitClusterStarted() != 0)
|
|
return NDBT_FAILED;
|
|
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runRestoreOne(NDBT_Context* ctx, NDBT_Step* step){
|
|
NdbBackup backup(GETNDB(step)->getNodeId()+1);
|
|
unsigned backupId = ctx->getProperty("BackupId");
|
|
|
|
ndbout << "Restoring backup " << backupId << endl;
|
|
|
|
if (backup.restore(backupId) == -1){
|
|
return NDBT_FAILED;
|
|
}
|
|
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runVerifyOne(NDBT_Context* ctx, NDBT_Step* step){
|
|
int records = ctx->getNumRecords();
|
|
Ndb* pNdb = GETNDB(step);
|
|
int result = NDBT_OK;
|
|
int count = 0;
|
|
|
|
const NdbDictionary::Table* tab =
|
|
GETNDB(step)->getDictionary()->getTable(ctx->getTab()->getName());
|
|
if(tab == 0)
|
|
return NDBT_FAILED;
|
|
|
|
UtilTransactions utilTrans(* tab);
|
|
HugoTransactions hugoTrans(* tab);
|
|
|
|
do{
|
|
|
|
// Check that there are as many records as we expected
|
|
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
|
|
|
|
g_err << "count = " << count;
|
|
g_err << " records = " << records;
|
|
g_err << endl;
|
|
|
|
CHECK(count == records);
|
|
|
|
// Read and verify every record
|
|
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
|
|
|
|
} while (false);
|
|
|
|
return result;
|
|
}
|
|
|
|
int runClearTable(NDBT_Context* ctx, NDBT_Step* step){
|
|
int records = ctx->getNumRecords();
|
|
|
|
UtilTransactions utilTrans(*ctx->getTab());
|
|
if (utilTrans.clearTable2(GETNDB(step), records) != 0){
|
|
return NDBT_FAILED;
|
|
}
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runDropTable(NDBT_Context* ctx, NDBT_Step* step){
|
|
GETNDB(step)->getDictionary()->dropTable(ctx->getTab()->getName());
|
|
return NDBT_OK;
|
|
}
|
|
|
|
#include "bank/Bank.hpp"
|
|
|
|
int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){
|
|
Bank bank(ctx->m_cluster_connection);
|
|
int overWriteExisting = true;
|
|
if (bank.createAndLoadBank(overWriteExisting, 10) != NDBT_OK)
|
|
return NDBT_FAILED;
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){
|
|
Bank bank(ctx->m_cluster_connection);
|
|
int wait = 30; // Max seconds between each "day"
|
|
int yield = 1; // Loops before bank returns
|
|
|
|
while (ctx->isTestStopped() == false) {
|
|
bank.performIncreaseTime(wait, yield);
|
|
}
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){
|
|
Bank bank(ctx->m_cluster_connection);
|
|
int wait = 10; // Max ms between each transaction
|
|
int yield = 100; // Loops before bank returns
|
|
|
|
while (ctx->isTestStopped() == false) {
|
|
bank.performTransactions(wait, yield);
|
|
}
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runBankGL(NDBT_Context* ctx, NDBT_Step* step){
|
|
Bank bank(ctx->m_cluster_connection);
|
|
int yield = 20; // Loops before bank returns
|
|
int result = NDBT_OK;
|
|
|
|
while (ctx->isTestStopped() == false) {
|
|
if (bank.performMakeGLs(yield) != NDBT_OK){
|
|
ndbout << "bank.performMakeGLs FAILED" << endl;
|
|
result = NDBT_FAILED;
|
|
}
|
|
}
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runBankSum(NDBT_Context* ctx, NDBT_Step* step){
|
|
Bank bank(ctx->m_cluster_connection);
|
|
int wait = 2000; // Max ms between each sum of accounts
|
|
int yield = 1; // Loops before bank returns
|
|
int result = NDBT_OK;
|
|
|
|
while (ctx->isTestStopped() == false) {
|
|
if (bank.performSumAccounts(wait, yield) != NDBT_OK){
|
|
ndbout << "bank.performSumAccounts FAILED" << endl;
|
|
result = NDBT_FAILED;
|
|
}
|
|
}
|
|
return result ;
|
|
}
|
|
|
|
int runDropBank(NDBT_Context* ctx, NDBT_Step* step){
|
|
Bank bank(ctx->m_cluster_connection);
|
|
if (bank.dropBank() != NDBT_OK)
|
|
return NDBT_FAILED;
|
|
return NDBT_OK;
|
|
}
|
|
|
|
int runBackupBank(NDBT_Context* ctx, NDBT_Step* step){
|
|
int loops = ctx->getNumLoops();
|
|
int l = 0;
|
|
int maxSleep = 30; // Max seconds between each backup
|
|
Ndb* pNdb = GETNDB(step);
|
|
NdbBackup backup(GETNDB(step)->getNodeId()+1);
|
|
unsigned minBackupId = ~0;
|
|
unsigned maxBackupId = 0;
|
|
unsigned backupId = 0;
|
|
int result = NDBT_OK;
|
|
|
|
while (l < loops && result != NDBT_FAILED){
|
|
|
|
if (pNdb->waitUntilReady() != 0){
|
|
result = NDBT_FAILED;
|
|
continue;
|
|
}
|
|
|
|
// Sleep for a while
|
|
NdbSleep_SecSleep(maxSleep);
|
|
|
|
// Perform backup
|
|
if (backup.start(backupId) != 0){
|
|
ndbout << "backup.start failed" << endl;
|
|
result = NDBT_FAILED;
|
|
continue;
|
|
}
|
|
ndbout << "Started backup " << backupId << endl;
|
|
|
|
// Remember min and max backupid
|
|
if (backupId < minBackupId)
|
|
minBackupId = backupId;
|
|
|
|
if (backupId > maxBackupId)
|
|
maxBackupId = backupId;
|
|
|
|
ndbout << " maxBackupId = " << maxBackupId
|
|
<< ", minBackupId = " << minBackupId << endl;
|
|
ctx->setProperty("MinBackupId", minBackupId);
|
|
ctx->setProperty("MaxBackupId", maxBackupId);
|
|
|
|
l++;
|
|
}
|
|
|
|
ctx->stopTest();
|
|
|
|
return result;
|
|
}
|
|
|
|
int runRestoreBankAndVerify(NDBT_Context* ctx, NDBT_Step* step){
|
|
NdbRestarter restarter;
|
|
NdbBackup backup(GETNDB(step)->getNodeId()+1);
|
|
unsigned minBackupId = ctx->getProperty("MinBackupId");
|
|
unsigned maxBackupId = ctx->getProperty("MaxBackupId");
|
|
unsigned backupId = minBackupId;
|
|
int result = NDBT_OK;
|
|
int errSumAccounts = 0;
|
|
int errValidateGL = 0;
|
|
|
|
ndbout << " maxBackupId = " << maxBackupId << endl;
|
|
ndbout << " minBackupId = " << minBackupId << endl;
|
|
|
|
while (backupId <= maxBackupId){
|
|
|
|
// TEMPORARY FIX
|
|
// To erase all tables from cache(s)
|
|
// To be removed, maybe replaced by ndb.invalidate();
|
|
{
|
|
Bank bank(ctx->m_cluster_connection);
|
|
|
|
if (bank.dropBank() != NDBT_OK){
|
|
result = NDBT_FAILED;
|
|
break;
|
|
}
|
|
}
|
|
// END TEMPORARY FIX
|
|
|
|
ndbout << "Performing initial restart" << endl;
|
|
if (restarter.restartAll(true) != 0)
|
|
return NDBT_FAILED;
|
|
|
|
if (restarter.waitClusterStarted() != 0)
|
|
return NDBT_FAILED;
|
|
|
|
ndbout << "Restoring backup " << backupId << endl;
|
|
if (backup.restore(backupId) == -1){
|
|
return NDBT_FAILED;
|
|
}
|
|
ndbout << "Backup " << backupId << " restored" << endl;
|
|
|
|
// Let bank verify
|
|
Bank bank(ctx->m_cluster_connection);
|
|
|
|
int wait = 0;
|
|
int yield = 1;
|
|
if (bank.performSumAccounts(wait, yield) != 0){
|
|
ndbout << "bank.performSumAccounts FAILED" << endl;
|
|
ndbout << " backupId = " << backupId << endl << endl;
|
|
result = NDBT_FAILED;
|
|
errSumAccounts++;
|
|
}
|
|
|
|
if (bank.performValidateAllGLs() != 0){
|
|
ndbout << "bank.performValidateAllGLs FAILED" << endl;
|
|
ndbout << " backupId = " << backupId << endl << endl;
|
|
result = NDBT_FAILED;
|
|
errValidateGL++;
|
|
}
|
|
|
|
backupId++;
|
|
}
|
|
|
|
if (result != NDBT_OK){
|
|
ndbout << "Verification of backup failed" << endl
|
|
<< " errValidateGL="<<errValidateGL<<endl
|
|
<< " errSumAccounts="<<errSumAccounts<<endl << endl;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
NDBT_TESTSUITE(testBackup);
|
|
TESTCASE("BackupOne",
|
|
"Test that backup and restore works on one table \n"
|
|
"1. Load table\n"
|
|
"2. Backup\n"
|
|
"3. Restart -i\n"
|
|
"4. Restore\n"
|
|
"5. Verify count and content of table\n"){
|
|
INITIALIZER(runLoadTable);
|
|
INITIALIZER(runBackupOne);
|
|
INITIALIZER(runRestartInitial);
|
|
INITIALIZER(runRestoreOne);
|
|
VERIFIER(runVerifyOne);
|
|
FINALIZER(runClearTable);
|
|
}
|
|
TESTCASE("BackupDDL",
|
|
"Test that backup and restore works on with DDL ongoing\n"
|
|
"1. Backups and DDL (create,drop,table.index)"){
|
|
INITIALIZER(runLoadTable);
|
|
STEP(runBackupLoop);
|
|
STEP(runDDL);
|
|
STEP(runDDL);
|
|
FINALIZER(runClearTable);
|
|
}
|
|
TESTCASE("BackupBank",
|
|
"Test that backup and restore works during transaction load\n"
|
|
" by backing up the bank"
|
|
"1. Create bank\n"
|
|
"2a. Start bank and let it run\n"
|
|
"2b. Perform loop number of backups of the bank\n"
|
|
" when backups are finished tell bank to close\n"
|
|
"3. Restart ndb -i and reload each backup\n"
|
|
" let bank verify that the backup is consistent\n"
|
|
"4. Drop bank\n"){
|
|
INITIALIZER(runCreateBank);
|
|
STEP(runBankTimer);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankTransactions);
|
|
STEP(runBankGL);
|
|
// TODO STEP(runBankSum);
|
|
STEP(runBackupBank);
|
|
VERIFIER(runRestoreBankAndVerify);
|
|
// FINALIZER(runDropBank);
|
|
}
|
|
TESTCASE("NFMaster",
|
|
"Test that backup behaves during node failiure\n"){
|
|
INITIALIZER(setMaster);
|
|
STEP(runAbort);
|
|
|
|
}
|
|
TESTCASE("NFMasterAsSlave",
|
|
"Test that backup behaves during node failiure\n"){
|
|
INITIALIZER(setMasterAsSlave);
|
|
STEP(runAbort);
|
|
|
|
}
|
|
TESTCASE("NFSlave",
|
|
"Test that backup behaves during node failiure\n"){
|
|
INITIALIZER(setSlave);
|
|
STEP(runAbort);
|
|
|
|
}
|
|
TESTCASE("FailMaster",
|
|
"Test that backup behaves during node failiure\n"){
|
|
INITIALIZER(setMaster);
|
|
STEP(runFail);
|
|
|
|
}
|
|
TESTCASE("FailMasterAsSlave",
|
|
"Test that backup behaves during node failiure\n"){
|
|
INITIALIZER(setMasterAsSlave);
|
|
STEP(runFail);
|
|
|
|
}
|
|
TESTCASE("FailSlave",
|
|
"Test that backup behaves during node failiure\n"){
|
|
INITIALIZER(setSlave);
|
|
STEP(runFail);
|
|
|
|
}
|
|
NDBT_TESTSUITE_END(testBackup);
|
|
|
|
int main(int argc, const char** argv){
|
|
ndb_init();
|
|
return testBackup.execute(argc, argv);
|
|
}
|
|
|
|
|