mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 14:02:32 +01:00
230134152e
# -------------------------------------------- # 04/04/13 joreland@mysql.com 1.1858.1.1 # Removal of NDBT_Table # -------------------------------------------- # 04/04/13 joreland@mysql.com 1.1858.1.2 # Removal of NDBT_Table # -------------------------------------------- # 04/04/13 joreland@mysql.com 1.1858.1.3 # Fix for crashing AT # -------------------------------------------- # 04/04/13 joreland@mysql.com 1.1858.1.4 # Bug fixes in testIndex # -------------------------------------------- # 04/04/13 joreland@mysql.com 1.1866.1.5 # Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb # into mysql.com:/home/jonas/src/tmp # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1858.1.5 # Fix for takeover when accessing indexes. # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1866.1.6 # Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb # into mysql.com:/home/jonas/src/tmp # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1858.2.1 # Fixed error handling of fire_trigger_ord + lqhkeyref w.r.t indexes # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1858.2.2 # Simple retry mechanism in UTIL # Helps testIndex -n BuildDuring _a lot_ # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1858.2.3 # Misc fixes to test prg. # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1858.2.4 # Allow more retires on application errors # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1858.2.5 # Pass no of rows fetched in SUB_SYNC_CONTINUE_REQ # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1869 # wl1714 # Improve parallellism # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1870 # Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb # into mysql.com:/home/jonas/src/wl1714 # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1866.1.7 # Merge # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1871 # Merge mysql.com:/home/jonas/src/wl1714 # into mysql.com:/home/jonas/src/mysql-4.1-ndb # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1872 # Fix for testScan -n ScanReadError5030 # -------------------------------------------- # 04/04/14 joreland@mysql.com 1.1873 # fix testDict -n FragmentType* # -------------------------------------------- # 04/04/14 johan@stingray.(none) 1.1866.2.1 # small fixes # -------------------------------------------- # 04/04/14 johan@stingray.(none) 1.1874 # Merge jandersson@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb # into stingray.(none):/space/bk/rep/mysql-4.1-ndb # -------------------------------------------- # 04/04/14 johan@stingray.(none) 1.1875 # handle rep node as an api node # -------------------------------------------- # 04/04/14 pekka@mysql.com 1.1873.1.1 # Fix for NDBT_Table removal # -------------------------------------------- # 04/04/15 joreland@mysql.com 1.1873.1.2 # Uninitialized var. # -------------------------------------------- # 04/04/15 johan@stingray.(none) 1.1876 # Merge jandersson@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb # into stingray.(none):/space/bk/rep/mysql-4.1-ndb # -------------------------------------------- # 04/04/15 joreland@mysql.com 1.1873.1.3 # Write pid before changing user # (as runas user probably doesn't have permissions on pid-dir) # -------------------------------------------- # -------------------------------------------- # 04/04/15 ndb@mc03.ndb.mysql.com 1.1862.1.3 # Fix printout of varchars # -------------------------------------------- # 04/04/15 ndb@mc03.ndb.mysql.com 1.1877 # Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb # into mc03.ndb.mysql.com:/space/ndb/tmp # -------------------------------------------- # 04/04/15 ndb@mc03.ndb.mysql.com 1.1862.1.4 # Hmm.. don't print attr as many times as length of array # -------------------------------------------- # 04/04/15 ndb@mc03.ndb.mysql.com 1.1878 # Merge mc03.ndb.mysql.com:/space/ndb/mysql-4.1-ndb # into mc03.ndb.mysql.com:/space/ndb/tmp # -------------------------------------------- # 04/04/15 joreland@mysql.com 1.1876.1.1 # Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb # into mysql.com:/home/jonas/src/mysql-4.1-ndb # -------------------------------------------- # 04/04/15 joreland@mysql.com 1.1877.1.1 # Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb # into mysql.com:/home/jonas/src/mysql-4.1-ndb # -------------------------------------------- # 04/04/15 ndb@mc03.ndb.mysql.com 1.1879 # Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb # into mc03.ndb.mysql.com:/space/ndb/tmp # -------------------------------------------- # 04/04/17 joreland@mysql.com 1.1880 # LCP bug when restarting ops take's longer than DIH sending a new lcp ord # Solution: # Send LCP_FRAG_REP after restarting all ops # -------------------------------------------- # 04/04/18 joreland@mysql.com 1.1881 # Missspelled ERROR_INSERT # -------------------------------------------- # 04/04/18 joreland@mysql.com 1.1882 # Added possibility to log only distributed signals # -------------------------------------------- # 04/04/22 joreland@mysql.com 1.1883 # Removed dependancy to libstdc++ # * pure virtual functions "__cxa_pure_virtual" is defined in libstd++ -> # remove all pure virtual functions # -------------------------------------------- # 04/04/23 joreland@mysql.com 1.1884 # Various minor bug fixes for problems found while compiling # with icc # -------------------------------------------- # -------------------------------------------- # 04/04/25 joreland@mysql.com 1.1885 # Removed debug code (joreland:1.1875) # -------------------------------------------- # 04/04/26 ejonore@mc03.ndb.mysql.com 1.1862.1.5 # Lock pages in memory _after_ daemon-mode (exec/fork) # -------------------------------------------- # 04/04/27 ejonore@mc03.ndb.mysql.com 1.1862.1.6 # 1) Trap abort() # 2) StopStart/StopAborted events # 3) warning if memlock fails # 4) use g_logger more often (instead of ndbout) # # -------------------------------------------- # 04/04/27 joreland@mysql.com 1.1886 # bug fix for a bug in wl1714 + software upgrade # -------------------------------------------- # 04/04/27 joreland@mysql.com 1.1887 # Cset exclude: joreland@mysql.com|ChangeSet|20040422160720|05374 # -------------------------------------------- # 04/04/27 joreland@mysql.com 1.1888 # removed libstc++ second try... # -------------------------------------------- # 04/04/28 ejonore@mc03.ndb.mysql.com 1.1862.1.7 # 1) Don't lock FUTURE pages but only current # 2) Do this when SIZEALT has completed # -------------------------------------------- # 04/04/30 joreland@mysql.com 1.1889 # Merge jonas@orca:/home/ndb/releases/mysql-4.1-ndb-3.4.x # into mysql.com:/home/jonas/src/mysql-4.1-ndb # -------------------------------------------- # 04/05/03 ndb@mc03.ndb.mysql.com 1.1862.1.8 # Version update # -------------------------------------------- # 04/05/03 joreland@mysql.com 1.1862.3.1 # Changed restart behavior. # Use "angel" process which monitor "real" process # -------------------------------------------- # 04/05/03 joreland@mysql.com 1.1862.1.9 # Merge jonas@orca:/home/ndb/releases/mysql-4.1-ndb-3.4.x # into mysql.com:/home/jonas/src/mysql-4.1-ndb-3.4.x # -------------------------------------------- # 04/05/03 joreland@mysql.com 1.1890 # Merge B2 fixes # -------------------------------------------- # -------------------------------------------- # 04/05/03 joreland@mysql.com 1.1862.1.10 # Better handling of children terminations # -------------------------------------------- # 04/05/03 joreland@mysql.com 1.1862.1.11 # Fixes for angel-restarting # -------------------------------------------- # 04/05/03 joreland@mysql.com 1.1891 # Merge mysql.com:/home/jonas/src/mysql-4.1-ndb-3.4.x # into mysql.com:/home/jonas/src/mysql-4.1-ndb # -------------------------------------------- #
184 lines
6 KiB
C++
184 lines
6 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 <NdbRestarter.hpp>
|
|
#include <Vector.hpp>
|
|
#include <random.h>
|
|
|
|
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;
|
|
}
|
|
|
|
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 create_index_on_pk(Ndb* pNdb, const char* tabName){
|
|
int result = NDBT_OK;
|
|
|
|
const NdbDictionary::Table * tab = NDBT_Table::discoverTableFromDb(pNdb,
|
|
tabName);
|
|
|
|
// Create index
|
|
const char* idxName = "IDX_ON_PK";
|
|
ndbout << "Create: " <<idxName << "( ";
|
|
NdbDictionary::Index pIdx(idxName);
|
|
pIdx.setTable(tabName);
|
|
pIdx.setType(NdbDictionary::Index::UniqueHashIndex);
|
|
for (int c = 0; c< tab->getNoOfPrimaryKeys(); c++){
|
|
pIdx.addIndexColumn(tab->getPrimaryKey(c));
|
|
ndbout << tab->getPrimaryKey(c)<<" ";
|
|
}
|
|
|
|
ndbout << ") ";
|
|
if (pNdb->getDictionary()->createIndex(pIdx) != 0){
|
|
ndbout << "FAILED!" << endl;
|
|
const NdbError err = pNdb->getDictionary()->getNdbError();
|
|
ERR(err);
|
|
result = NDBT_FAILED;
|
|
} else {
|
|
ndbout << "OK!" << endl;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
int drop_index_on_pk(Ndb* pNdb, const char* tabName){
|
|
int result = NDBT_OK;
|
|
const char* idxName = "IDX_ON_PK";
|
|
ndbout << "Drop: " << idxName;
|
|
if (pNdb->getDictionary()->dropIndex(idxName, tabName) != 0){
|
|
ndbout << "FAILED!" << endl;
|
|
const NdbError err = pNdb->getDictionary()->getNdbError();
|
|
ERR(err);
|
|
result = NDBT_FAILED;
|
|
} else {
|
|
ndbout << "OK!" << endl;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
#define CHECK(b) if (!(b)) { \
|
|
g_err << "ERR: "<< step->getName() \
|
|
<< " failed on line " << __LINE__ << endl; \
|
|
result = NDBT_FAILED; \
|
|
continue; }
|
|
|
|
int runTestSingleUserMode(NDBT_Context* ctx, NDBT_Step* step){
|
|
int result = NDBT_OK;
|
|
int loops = ctx->getNumLoops();
|
|
int records = ctx->getNumRecords();
|
|
Ndb* pNdb = GETNDB(step);
|
|
NdbRestarter restarter;
|
|
char tabName[255];
|
|
strncpy(tabName, ctx->getTab()->getName(), 255);
|
|
ndbout << "tabName="<<tabName<<endl;
|
|
|
|
int i = 0;
|
|
int count;
|
|
HugoTransactions hugoTrans(*ctx->getTab());
|
|
UtilTransactions utilTrans(*ctx->getTab());
|
|
while (i<loops && result == NDBT_OK) {
|
|
g_info << i << ": ";
|
|
int timeout = 120;
|
|
// Test that the single user mode api can do everything
|
|
CHECK(restarter.enterSingleUserMode(pNdb->getNodeId()) == 0);
|
|
CHECK(restarter.waitClusterSingleUser(timeout) == 0);
|
|
CHECK(hugoTrans.loadTable(pNdb, records, 128) == 0);
|
|
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
|
|
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
|
|
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
|
|
CHECK(count == records);
|
|
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
|
|
CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
|
|
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
|
|
CHECK(count == (records/2));
|
|
CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
|
|
CHECK(restarter.exitSingleUserMode() == 0);
|
|
CHECK(restarter.waitClusterStarted(timeout) == 0);
|
|
|
|
// Test create index in single user mode
|
|
CHECK(restarter.enterSingleUserMode(pNdb->getNodeId()) == 0);
|
|
CHECK(restarter.waitClusterSingleUser(timeout) == 0);
|
|
CHECK(create_index_on_pk(pNdb, tabName) == 0);
|
|
CHECK(hugoTrans.loadTable(pNdb, records, 128) == 0);
|
|
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
|
|
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
|
|
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
|
|
CHECK(count == records);
|
|
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
|
|
CHECK(drop_index_on_pk(pNdb, tabName) == 0);
|
|
CHECK(restarter.exitSingleUserMode() == 0);
|
|
CHECK(restarter.waitClusterStarted(timeout) == 0);
|
|
|
|
// Test recreate index in single user mode
|
|
CHECK(create_index_on_pk(pNdb, tabName) == 0);
|
|
CHECK(hugoTrans.loadTable(pNdb, records, 128) == 0);
|
|
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
|
|
CHECK(restarter.enterSingleUserMode(pNdb->getNodeId()) == 0);
|
|
CHECK(restarter.waitClusterSingleUser(timeout) == 0);
|
|
CHECK(drop_index_on_pk(pNdb, tabName) == 0);
|
|
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
|
|
CHECK(create_index_on_pk(pNdb, tabName) == 0);
|
|
CHECK(restarter.exitSingleUserMode() == 0);
|
|
CHECK(restarter.waitClusterStarted(timeout) == 0);
|
|
CHECK(drop_index_on_pk(pNdb, tabName) == 0);
|
|
|
|
CHECK(utilTrans.clearTable(GETNDB(step), records) == 0);
|
|
|
|
ndbout << "Restarting cluster" << endl;
|
|
CHECK(restarter.restartAll() == 0);
|
|
CHECK(restarter.waitClusterStarted(timeout) == 0);
|
|
CHECK(pNdb->waitUntilReady(timeout) == 0);
|
|
|
|
i++;
|
|
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
NDBT_TESTSUITE(testMgm);
|
|
TESTCASE("SingleUserMode",
|
|
"Test single user mode"){
|
|
INITIALIZER(runTestSingleUserMode);
|
|
FINALIZER(runClearTable);
|
|
}
|
|
NDBT_TESTSUITE_END(testMgm);
|
|
|
|
int main(int argc, const char** argv){
|
|
myRandom48Init(NdbTick_CurrentMillisecond());
|
|
return testMgm.execute(argc, argv);
|
|
}
|
|
|