diff options
author | unknown <jonas@perch.ndb.mysql.com> | 2005-11-07 12:19:28 +0100 |
---|---|---|
committer | unknown <jonas@perch.ndb.mysql.com> | 2005-11-07 12:19:28 +0100 |
commit | ee740746aff3c5163adfff481bc4cf70c37728f5 (patch) | |
tree | 2cb53178c95e7d8d6578018e169c2d71bb1fdbcb /storage/ndb/test | |
parent | 8a224ed85a8794743472f3611830349dc490aabc (diff) | |
download | mariadb-git-ee740746aff3c5163adfff481bc4cf70c37728f5.tar.gz |
Import ndb varsize
BitKeeper/deleted/.del-MetaData.cpp~146ae9865dd35829:
Delete: storage/ndb/src/kernel/vm/MetaData.cpp
BitKeeper/deleted/.del-MetaData.hpp~538342afcd8ac53c:
Delete: storage/ndb/src/kernel/vm/MetaData.hpp
BitKeeper/deleted/.del-DbtupLCP.cpp~855b1ed3fbc86a42:
Delete: storage/ndb/src/kernel/blocks/dbtup/DbtupLCP.cpp
BitKeeper/deleted/.del-DbtupSystemRestart.cpp~15b54d7e4e75d2d:
Delete: storage/ndb/src/kernel/blocks/dbtup/DbtupSystemRestart.cpp
BitKeeper/deleted/.del-DbtupUndoLog.cpp~5a2ef6e86b1404e9:
Delete: storage/ndb/src/kernel/blocks/dbtup/DbtupUndoLog.cpp
storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/CreateFilegroup.hpp''
storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp''
storage/ndb/include/kernel/signaldata/CreateObj.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/CreateObj.hpp''
storage/ndb/include/kernel/signaldata/DictObjOp.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/DictObjOp.hpp''
storage/ndb/include/kernel/signaldata/DropFilegroup.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/DropFilegroup.hpp''
storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/DropFilegroupImpl.hpp''
storage/ndb/include/kernel/signaldata/DropObj.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/DropObj.hpp''
storage/ndb/include/kernel/signaldata/Extent.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/Extent.hpp''
storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/LgmanContinueB.hpp''
storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/PgmanContinueB.hpp''
storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/RestoreContinueB.hpp''
storage/ndb/include/kernel/signaldata/RestoreImpl.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/RestoreImpl.hpp''
storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp:
New BitKeeper file ``storage/ndb/include/kernel/signaldata/TsmanContinueB.hpp''
storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/dbdih/printSysfile.cpp''
storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp''
storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp''
storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.cpp''
storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/Undo_buffer.hpp''
storage/ndb/src/kernel/blocks/dbtup/test_varpage.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/test_varpage.cpp''
storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/tuppage.cpp''
storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/dbtup/tuppage.hpp''
storage/ndb/src/kernel/blocks/diskpage.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/diskpage.cpp''
storage/ndb/src/kernel/blocks/diskpage.hpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/diskpage.hpp''
storage/ndb/src/kernel/blocks/lgman.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/lgman.cpp''
storage/ndb/src/kernel/blocks/lgman.hpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/lgman.hpp''
storage/ndb/src/kernel/blocks/pgman.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/pgman.cpp''
storage/ndb/src/kernel/blocks/pgman.hpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/pgman.hpp''
storage/ndb/src/kernel/blocks/print_file.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/print_file.cpp''
storage/ndb/src/kernel/blocks/restore.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/restore.cpp''
storage/ndb/src/kernel/blocks/restore.hpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/restore.hpp''
storage/ndb/src/kernel/blocks/tsman.cpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/tsman.cpp''
storage/ndb/src/kernel/blocks/tsman.hpp:
New BitKeeper file ``storage/ndb/src/kernel/blocks/tsman.hpp''
storage/ndb/src/kernel/vm/DLCFifoList.hpp:
New BitKeeper file ``storage/ndb/src/kernel/vm/DLCFifoList.hpp''
storage/ndb/src/kernel/vm/DLCHashTable.hpp:
New BitKeeper file ``storage/ndb/src/kernel/vm/DLCHashTable.hpp''
storage/ndb/src/kernel/vm/KeyTable2Ref.hpp:
New BitKeeper file ``storage/ndb/src/kernel/vm/KeyTable2Ref.hpp''
storage/ndb/src/kernel/vm/Rope.cpp:
New BitKeeper file ``storage/ndb/src/kernel/vm/Rope.cpp''
storage/ndb/src/kernel/vm/Rope.hpp:
New BitKeeper file ``storage/ndb/src/kernel/vm/Rope.hpp''
Diffstat (limited to 'storage/ndb/test')
24 files changed, 991 insertions, 341 deletions
diff --git a/storage/ndb/test/include/HugoCalculator.hpp b/storage/ndb/test/include/HugoCalculator.hpp index 03de46cd7ea..05cc2d218a4 100644 --- a/storage/ndb/test/include/HugoCalculator.hpp +++ b/storage/ndb/test/include/HugoCalculator.hpp @@ -31,7 +31,8 @@ class HugoCalculator { public: HugoCalculator(const NdbDictionary::Table& tab); Int32 calcValue(int record, int attrib, int updates) const; - const char* calcValue(int record, int attrib, int updates, char* buf, int len) const; + const char* calcValue(int record, int attrib, int updates, char* buf, + int len, Uint32* real_len) const; int verifyRowValues(NDBT_ResultRow* const pRow) const; int getIdValue(NDBT_ResultRow* const pRow) const; diff --git a/storage/ndb/test/include/HugoTransactions.hpp b/storage/ndb/test/include/HugoTransactions.hpp index dd6f6c0dd3b..5c987a576bc 100644 --- a/storage/ndb/test/include/HugoTransactions.hpp +++ b/storage/ndb/test/include/HugoTransactions.hpp @@ -33,7 +33,8 @@ public: int batch = 512, bool allowConstraintViolation = true, int doSleep = 0, - bool oneTrans = false); + bool oneTrans = false, + int updateValue = 0); int scanReadRecords(Ndb*, int records, diff --git a/storage/ndb/test/include/NDBT_Table.hpp b/storage/ndb/test/include/NDBT_Table.hpp index 500ac7c0e39..93dc5a1b994 100644 --- a/storage/ndb/test/include/NDBT_Table.hpp +++ b/storage/ndb/test/include/NDBT_Table.hpp @@ -29,7 +29,8 @@ public: int _length = 1, bool _pk = false, bool _nullable = false, - CHARSET_INFO *cs= 0): + CHARSET_INFO *cs= 0, + NdbDictionary::Column::StorageType storage = NdbDictionary::Column::StorageTypeMemory): NdbDictionary::Column(_name) { assert(_name != 0); @@ -42,6 +43,7 @@ public: { setCharset(cs); } + setStorageType(storage); } }; diff --git a/storage/ndb/test/include/NDBT_Tables.hpp b/storage/ndb/test/include/NDBT_Tables.hpp index fb0df8aa35b..4a5886502e1 100644 --- a/storage/ndb/test/include/NDBT_Tables.hpp +++ b/storage/ndb/test/include/NDBT_Tables.hpp @@ -23,13 +23,15 @@ #include <NdbDictionary.hpp> #include <NDBT_Table.hpp> -typedef int (* NDBT_CreateTableHook)(Ndb*, NdbDictionary::Table&, int when); +typedef int (* NDBT_CreateTableHook)(Ndb*, NdbDictionary::Table&, int when, + void* arg); class NDBT_Tables { public: static int createTable(Ndb* pNdb, const char* _name, bool _temp = false, - bool existsOK = false, NDBT_CreateTableHook = 0); + bool existsOK = false, NDBT_CreateTableHook = 0, + void* arg = 0); static int createAllTables(Ndb* pNdb, bool _temp, bool existsOK = false); static int createAllTables(Ndb* pNdb); diff --git a/storage/ndb/test/include/NDBT_Test.hpp b/storage/ndb/test/include/NDBT_Test.hpp index 62579cbfd6b..a22aa6e53bf 100644 --- a/storage/ndb/test/include/NDBT_Test.hpp +++ b/storage/ndb/test/include/NDBT_Test.hpp @@ -41,6 +41,7 @@ public: NDBT_Context(Ndb_cluster_connection&); ~NDBT_Context(); const NdbDictionary::Table* getTab(); + const NdbDictionary::Table** getTables(); int getNumTables() const; const char * getTableName(int) const; NDBT_TestSuite* getSuite(); @@ -82,6 +83,7 @@ public: bool setDbProperty(const char*, Uint32); void setTab(const NdbDictionary::Table*); + void addTab(const NdbDictionary::Table*); void setRemoteMgm(char * mgm); /** @@ -105,7 +107,7 @@ private: void setCase(NDBT_TestCase*); void setNumRecords(int); void setNumLoops(int); - const NdbDictionary::Table* tab; + Vector<const NdbDictionary::Table*> tables; NDBT_TestSuite* suite; NDBT_TestCase* testcase; Ndb* ndb; @@ -337,6 +339,7 @@ public: // to control the behaviour of the testsuite void setCreateTable(bool); // Create table before test func is called void setCreateAllTables(bool); // Create all tables before testsuite is executed + void setRunAllTables(bool); // Run once with all tables // Prints the testsuite, testcases and teststeps void printExecutionTree(); @@ -356,9 +359,10 @@ public: // Returns true if timing info should be printed bool timerIsOn(); - int addTest(NDBT_TestCase* pTest); + // Table create tweaks + int createHook(Ndb*, NdbDictionary::Table&, int when); Vector<BaseString> m_tables_in_test; private: int executeOne(Ndb_cluster_connection&, @@ -382,6 +386,9 @@ private: int timer; NdbTimer testSuiteTimer; bool createTable; + bool diskbased; + bool runonce; + const char* tsname; bool createAllTables; }; diff --git a/storage/ndb/test/include/NdbRestarter.hpp b/storage/ndb/test/include/NdbRestarter.hpp index 19a88b4f8ad..85c3f92f9ee 100644 --- a/storage/ndb/test/include/NdbRestarter.hpp +++ b/storage/ndb/test/include/NdbRestarter.hpp @@ -65,6 +65,8 @@ public: int getRandomNodeOtherNodeGroup(int nodeId, int randomNumber); int getRandomNotMasterNodeId(int randomNumber); + NdbMgmHandle handle; + protected: int waitClusterState(ndb_mgm_node_status _status, @@ -87,7 +89,6 @@ protected: bool connected; BaseString addr; - NdbMgmHandle handle; ndb_mgm_configuration * m_config; protected: ndb_mgm_configuration * getConfig(); diff --git a/storage/ndb/test/include/NdbSchemaOp.hpp b/storage/ndb/test/include/NdbSchemaOp.hpp index 1edbc155643..92a57fcf02a 100644 --- a/storage/ndb/test/include/NdbSchemaOp.hpp +++ b/storage/ndb/test/include/NdbSchemaOp.hpp @@ -71,11 +71,11 @@ }; /** * Indicate whether the attribute should be stored on disk or not + * Only for legacy createAttribute(). */ enum StorageMode { - MMBased = 0, ///< Main memory - DiskBased = 1, ///< Disk (Not yet supported.) - NoStorageTypeDef ///< Used for debugging only + MMBased = NDB_STORAGETYPE_MEMORY, + DiskBased = NDB_STORAGETYPE_DISK }; /** diff --git a/storage/ndb/test/ndbapi/create_tab.cpp b/storage/ndb/test/ndbapi/create_tab.cpp index b35c8655236..4177b63bb8b 100644 --- a/storage/ndb/test/ndbapi/create_tab.cpp +++ b/storage/ndb/test/ndbapi/create_tab.cpp @@ -22,7 +22,27 @@ #include <getarg.h> - +static int g_diskbased = 0; +static const char* g_tsname = 0; + +static int +g_create_hook(Ndb* ndb, NdbDictionary::Table& tab, int when, void* arg) +{ + if (when == 0) { + if (g_diskbased) { + for (int i = 0; i < tab.getNoOfColumns(); i++) { + NdbDictionary::Column* col = tab.getColumn(i); + if (! col->getPrimaryKey()) { + col->setStorageType(NdbDictionary::Column::StorageTypeDisk); + } + } + } + if (g_tsname != NULL) { + tab.setTablespace(g_tsname); + } + } + return 0; +} int main(int argc, const char** argv){ ndb_init(); @@ -32,13 +52,16 @@ int main(int argc, const char** argv){ int _all = 0; int _print = 0; const char* _connectstr = NULL; + int _diskbased = 0; + const char* _tsname = NULL; struct getargs args[] = { - { "all", 'a', arg_flag, &_all, "Create/print all tables" }, - { "print", 'p', arg_flag, &_print, "Print table(s) instead of creating it"}, - { "temp", 't', arg_flag, &_temp, "Temporary table", "temp" }, - { "connstr", 'c', arg_string, &_connectstr, "connect string", - "How to connect to NDB"}, + { "all", 'a', arg_flag, &_all, "Create/print all tables", 0 }, + { "print", 'p', arg_flag, &_print, "Print table(s) instead of creating it", 0}, + { "temp", 't', arg_flag, &_temp, "Temporary table", 0 }, + { "connstr", 'c', arg_string, &_connectstr, "Connect string", "cs" }, + { "diskbased", 0, arg_flag, &_diskbased, "Store attrs on disk if possible", 0 }, + { "tsname", 0, arg_string, &_tsname, "Tablespace name", "ts" }, { "usage", '?', arg_flag, &_help, "Print help", "" } }; int num_args = sizeof(args) / sizeof(args[0]); @@ -59,6 +82,9 @@ int main(int argc, const char** argv){ return NDBT_ProgramExit(NDBT_WRONGARGS); } + g_diskbased = _diskbased; + g_tsname = _tsname; + int res = 0; if(_print){ /** @@ -98,7 +124,8 @@ int main(int argc, const char** argv){ int tmp; for(int i = optind; i<argc; i++){ ndbout << "Trying to create " << argv[i] << endl; - if((tmp = NDBT_Tables::createTable(&MyNdb, argv[i], _temp)) != 0) + if((tmp = NDBT_Tables::createTable(&MyNdb, argv[i], _temp, false, + g_create_hook)) != 0) res = tmp; } } @@ -109,5 +136,3 @@ int main(int argc, const char** argv){ else return NDBT_ProgramExit(NDBT_OK); } - - diff --git a/storage/ndb/test/ndbapi/flexBench.cpp b/storage/ndb/test/ndbapi/flexBench.cpp index abddecfdc40..d272b09e5dc 100644 --- a/storage/ndb/test/ndbapi/flexBench.cpp +++ b/storage/ndb/test/ndbapi/flexBench.cpp @@ -775,12 +775,12 @@ static void* flexBenchThread(void* pArg) (char *)longKeyAttrValue[count - 1][i], tSizeOfLongPK*4); } else - pOps[countTables]->equal((char*)attrName[0], + pOps[countTables]->equal((Uint32)0, (char*)&attrRefValue[nRefLocalOpOffset]); if (tType == stInsert || tType == stUpdate){ for (int ca = 1; ca < loopCountAttributes; ca++){ - pOps[countTables]->setValue((char*)attrName[ca], + pOps[countTables]->setValue((Uint32)ca, (char*)&attrRefValue[nRefLocalOpOffset + tAttributeSize*ca]); }//for } else if (tType == stRead || stVerify == tType) { @@ -788,7 +788,7 @@ static void* flexBenchThread(void* pArg) loopCountAttributes * countTables ; for (int ca = 1; ca < loopCountAttributes; ca++) { - tTmp = pOps[countTables]->getValue((char*)attrName[ca], + tTmp = pOps[countTables]->getValue((Uint32)ca, (char*)&attrValue[nTableOffset + tAttributeSize*ca]); }//for } else if (stVerifyDelete == tType) { @@ -802,7 +802,7 @@ static void* flexBenchThread(void* pArg) int nTableOffset = tAttributeSize * loopCountAttributes * countTables ; - tTmp = pOps[countTables]->getValue((char*)attrName[0], + tTmp = pOps[countTables]->getValue((Uint32)0, (char*)&attrValue[nTableOffset]); } }//if diff --git a/storage/ndb/test/ndbapi/testDict.cpp b/storage/ndb/test/ndbapi/testDict.cpp index dd5846f0d62..0176db8d4fd 100644 --- a/storage/ndb/test/ndbapi/testDict.cpp +++ b/storage/ndb/test/ndbapi/testDict.cpp @@ -1469,6 +1469,99 @@ runTestDictionaryPerf(NDBT_Context* ctx, NDBT_Step* step){ return NDBT_OK; } +int +runCreateLogfileGroup(NDBT_Context* ctx, NDBT_Step* step){ + Ndb* pNdb = GETNDB(step); + NdbDictionary::LogfileGroup lg; + lg.setName("DEFAULT-LG"); + lg.setUndoBufferSize(8*1024*1024); + + int res; + res = pNdb->getDictionary()->createLogfileGroup(lg); + if(res != 0){ + g_err << "Failed to create logfilegroup:" + << endl << pNdb->getDictionary()->getNdbError() << endl; + return NDBT_FAILED; + } + + NdbDictionary::Undofile uf; + uf.setPath("undofile01.dat"); + uf.setSize(5*1024*1024); + uf.setLogfileGroup("DEFAULT-LG"); + + res = pNdb->getDictionary()->createUndofile(uf); + if(res != 0){ + g_err << "Failed to create undofile:" + << endl << pNdb->getDictionary()->getNdbError() << endl; + return NDBT_FAILED; + } + + uf.setPath("undofile02.dat"); + uf.setSize(5*1024*1024); + uf.setLogfileGroup("DEFAULT-LG"); + + res = pNdb->getDictionary()->createUndofile(uf); + if(res != 0){ + g_err << "Failed to create undofile:" + << endl << pNdb->getDictionary()->getNdbError() << endl; + return NDBT_FAILED; + } + + return NDBT_OK; +} + +int +runCreateTablespace(NDBT_Context* ctx, NDBT_Step* step){ + Ndb* pNdb = GETNDB(step); + NdbDictionary::Tablespace lg; + lg.setName("DEFAULT-TS"); + lg.setExtentSize(1024*1024); + lg.setDefaultLogfileGroup("DEFAULT-LG"); + + int res; + res = pNdb->getDictionary()->createTablespace(lg); + if(res != 0){ + g_err << "Failed to create tablespace:" + << endl << pNdb->getDictionary()->getNdbError() << endl; + return NDBT_FAILED; + } + + NdbDictionary::Datafile uf; + uf.setPath("datafile01.dat"); + uf.setSize(10*1024*1024); + uf.setTablespace("DEFAULT-TS"); + + res = pNdb->getDictionary()->createDatafile(uf); + if(res != 0){ + g_err << "Failed to create datafile:" + << endl << pNdb->getDictionary()->getNdbError() << endl; + return NDBT_FAILED; + } + + return NDBT_OK; +} +int +runCreateDiskTable(NDBT_Context* ctx, NDBT_Step* step){ + Ndb* pNdb = GETNDB(step); + + NdbDictionary::Table tab = *ctx->getTab(); + tab.setTablespace("DEFAULT-TS"); + + for(Uint32 i = 0; i<tab.getNoOfColumns(); i++) + if(!tab.getColumn(i)->getPrimaryKey()) + tab.getColumn(i)->setStorageType(NdbDictionary::Column::StorageTypeDisk); + + int res; + res = pNdb->getDictionary()->createTable(tab); + if(res != 0){ + g_err << "Failed to create table:" + << endl << pNdb->getDictionary()->getNdbError() << endl; + return NDBT_FAILED; + } + + return NDBT_OK; +} + int runFailAddFragment(NDBT_Context* ctx, NDBT_Step* step){ static int acclst[] = { 3001 }; static int tuplst[] = { 4007, 4008, 4009, 4010, 4011, 4012 }; @@ -1647,6 +1740,15 @@ TESTCASE("DictionaryPerf", ""){ INITIALIZER(runTestDictionaryPerf); } +TESTCASE("CreateLogfileGroup", ""){ + INITIALIZER(runCreateLogfileGroup); +} +TESTCASE("CreateTablespace", ""){ + INITIALIZER(runCreateTablespace); +} +TESTCASE("CreateDiskTable", ""){ + INITIALIZER(runCreateDiskTable); +} TESTCASE("FailAddFragment", "Fail add fragment or attribute in ACC or TUP or TUX\n"){ INITIALIZER(runFailAddFragment); diff --git a/storage/ndb/test/ndbapi/testLcp.cpp b/storage/ndb/test/ndbapi/testLcp.cpp index 8bfc7ccf9b9..69789b0191f 100644 --- a/storage/ndb/test/ndbapi/testLcp.cpp +++ b/storage/ndb/test/ndbapi/testLcp.cpp @@ -3,9 +3,13 @@ #include <NdbApi.hpp> #include <NdbRestarter.hpp> #include <HugoOperations.hpp> +#include <HugoTransactions.hpp> #include <UtilTransactions.hpp> #include <signaldata/DumpStateOrd.hpp> +#include <getarg.h> +#include <InputStream.hpp> + struct CASE { bool start_row; @@ -13,29 +17,37 @@ struct CASE bool curr_row; const char * op1; const char * op2; + const char * op3; int val; }; -static CASE g_ops[] = +static CASE g_op_types[] = { - { false, true, false, "INSERT", 0, 0 }, - { false, true, false, "INSERT", "UPDATE", 0 }, - { false, false, false, "INSERT", "DELETE", 0 }, - { true, true, false, "UPDATE", 0, 0 }, - { true, true, false, "UPDATE", "UPDATE", 0 }, - { true, false, false, "UPDATE", "DELETE", 0 }, - { true, false, false, "DELETE", 0, 0 }, - { true, true, false, "DELETE", "INSERT", 0 } + { false, true, false, "INS", 0, 0, 0 }, // 0x001 a + { true, true, false, "UPD", 0, 0, 0 }, // 0x002 d + { true, false, false, "DEL", 0, 0, 0 }, // 0x004 g + + { false, true, false, "INS", "UPD", 0, 0 }, // 0x008 b + { false, false, false, "INS", "DEL", 0, 0 }, // 0x010 c + { true, true, false, "UPD", "UPD", 0, 0 }, // 0x020 e + { true, false, false, "UPD", "DEL", 0, 0 }, // 0x040 f + { true, true, false, "DEL", "INS", 0, 0 }, // 0x080 h + + { false, true, false, "INS", "DEL", "INS", 0 }, // 0x100 i + { true, false, false, "DEL", "INS", "DEL", 0 } // 0x200 j }; -const size_t OP_COUNT = (sizeof(g_ops)/sizeof(g_ops[0])); +const size_t OP_COUNT = (sizeof(g_op_types)/sizeof(g_op_types[0])); static Ndb* g_ndb = 0; +static CASE* g_ops; static Ndb_cluster_connection *g_cluster_connection= 0; -static CASE* g_cases; static HugoOperations* g_hugo_ops; - -static int g_rows = 1000; +static int g_use_ops = 1 | 2 | 4; +static int g_cases = 0x1; +static int g_case_loop = 2; +static int g_rows = 10; static int g_setup_tables = 1; +static int g_one_op_at_a_time = 0; static const char * g_tablename = "T1"; static const NdbDictionary::Table* g_table = 0; static NdbRestarter g_restarter; @@ -45,9 +57,9 @@ static int parse_args(int argc, char** argv); static int connect_ndb(); static int drop_all_tables(); static int load_table(); -static int pause_lcp(); +static int pause_lcp(int error); static int do_op(int row); -static int continue_lcp(int error); +static int continue_lcp(int error = 0); static int commit(); static int restart(); static int validate(); @@ -56,9 +68,10 @@ static int validate(); int main(int argc, char ** argv){ - + ndb_init(); require(!init_ndb(argc, argv)); - require(!parse_args(argc, argv)); + if(parse_args(argc, argv)) + return -1; require(!connect_ndb()); if(g_setup_tables){ @@ -77,48 +90,97 @@ main(int argc, char ** argv){ require(g_hugo_ops = new HugoOperations(* g_table)); require(!g_hugo_ops->startTransaction(g_ndb)); - g_cases= new CASE[g_rows]; - require(!load_table()); + g_ops= new CASE[g_rows]; - g_info << "Performing all ops wo/ inteference of LCP" << endl; - - g_info << "Testing pre LCP operations, ZLCP_OP_WRITE_RT_BREAK" << endl; - g_info << " where ZLCP_OP_WRITE_RT_BREAK is finished before SAVE_PAGES" - << endl; - require(!pause_lcp()); - size_t j; - for(j = 0; j<g_rows; j++){ - require(!do_op(j)); - } - require(!continue_lcp(5900)); - require(!commit()); - require(!restart()); - require(!validate()); - - g_info << "Testing pre LCP operations, ZLCP_OP_WRITE_RT_BREAK" << endl; - g_info << " where ZLCP_OP_WRITE_RT_BREAK is finished after SAVE_PAGES" - << endl; - require(!load_table()); - require(!pause_lcp()); - for(j = 0; j<g_rows; j++){ - require(!do_op(j)); - } - require(!continue_lcp(5901)); - require(!commit()); - require(!restart()); - require(!validate()); - - g_info << "Testing pre LCP operations, undo-ed at commit" << endl; - require(!load_table()); - require(!pause_lcp()); - for(j = 0; j<g_rows; j++){ - require(!do_op(j)); + const int use_ops = g_use_ops; + for(size_t i = 0; i<OP_COUNT; i++) + { + if(g_one_op_at_a_time){ + while(i < OP_COUNT && (use_ops & (1 << i)) == 0) i++; + if(i == OP_COUNT) + break; + ndbout_c("-- loop\noperation: %c use_ops: %x", 'a'+i, use_ops); + g_use_ops = (1 << i); + } else { + i = OP_COUNT - 1; + } + + size_t test_case = 0; + if((1 << test_case++) & g_cases) + { + for(size_t tl = 0; tl<g_case_loop; tl++){ + g_info << "Performing all ops wo/ inteference of LCP" << endl; + + g_info << "Testing pre LCP operations, ZLCP_OP_WRITE_RT_BREAK" << endl; + g_info << " where ZLCP_OP_WRITE_RT_BREAK is " + " finished before SAVE_PAGES" << endl; + require(!load_table()); + require(!pause_lcp(5900)); + for(size_t j = 0; j<g_rows; j++){ + require(!do_op(j)); + } + require(!continue_lcp(5900)); + require(!commit()); + require(!pause_lcp(5900)); + require(!restart()); + require(!validate()); + } + } + + if((1 << test_case++) & g_cases) + { + for(size_t tl = 0; tl<g_case_loop; tl++){ + g_info << "Testing pre LCP operations, ZLCP_OP_WRITE_RT_BREAK" << endl; + g_info << " where ZLCP_OP_WRITE_RT_BREAK is finished after SAVE_PAGES" + << endl; + require(!load_table()); + require(!pause_lcp(5901)); + for(size_t j = 0; j<g_rows; j++){ + require(!do_op(j)); + } + require(!continue_lcp(5901)); + require(!commit()); + require(!pause_lcp(5900)); + require(!restart()); + require(!validate()); + } + } + + if((1 << test_case++) & g_cases) + { + for(size_t tl = 0; tl<g_case_loop; tl++){ + g_info << "Testing pre LCP operations, undo-ed at commit" << endl; + require(!load_table()); + require(!pause_lcp(5902)); + for(size_t j = 0; j<g_rows; j++){ + require(!do_op(j)); + } + require(!continue_lcp(5902)); + require(!commit()); + require(!continue_lcp(5903)); + require(!pause_lcp(5900)); + require(!restart()); + require(!validate()); + } + } + + if((1 << test_case++) & g_cases) + { + for(size_t tl = 0; tl<g_case_loop; tl++){ + g_info << "Testing prepared during LCP and committed after" << endl; + require(!load_table()); + require(!pause_lcp(5904)); // Start LCP, but don't save pages + for(size_t j = 0; j<g_rows; j++){ + require(!do_op(j)); + } + require(!continue_lcp(5904)); // Start ACC save pages + require(!pause_lcp(5900)); // Next LCP + require(!commit()); + require(!restart()); + require(!validate()); + } + } } - require(!continue_lcp(5902)); - require(!commit()); - require(!continue_lcp(5903)); - require(!restart()); - require(!validate()); } static int init_ndb(int argc, char** argv) @@ -129,6 +191,58 @@ static int init_ndb(int argc, char** argv) static int parse_args(int argc, char** argv) { + size_t i; + char * ops= 0, *cases=0; + struct getargs args[] = { + { "records", 0, arg_integer, &g_rows, "Number of records", "records" }, + { "operations", 'o', arg_string, &ops, "Operations [a-h]", 0 }, + { "1", '1', arg_flag, &g_one_op_at_a_time, "One op at a time", 0 }, + { "0", '0', arg_negative_flag, &g_one_op_at_a_time, "All ops at once", 0 }, + { "cases", 'c', arg_string, &cases, "Cases [a-c]", 0 }, + { 0, 't', arg_flag, &g_setup_tables, "Create table", 0 }, + { 0, 'u', arg_negative_flag, &g_setup_tables, "Dont create table", 0 } + }; + + int optind= 0; + const int num_args = sizeof(args)/sizeof(args[0]); + if(getarg(args, num_args, argc, (const char**)argv, &optind)) { + arg_printusage(args, num_args, argv[0], " tabname1\n"); + ndbout_c("\n -- Operations [a-%c] = ", 'a'+OP_COUNT-1); + for(i = 0; i<OP_COUNT; i++){ + ndbout_c("\t%c = %s %s", + 'a'+i, g_op_types[i].op1, + g_op_types[i].op2 ? g_op_types[i].op2 : ""); + } + return -1; + } + + if(ops != 0){ + g_use_ops = 0; + char * s = ops; + while(* s) + g_use_ops |= (1 << ((* s++) - 'a')); + } + + if(cases != 0){ + g_cases = 0; + char * s = cases; + while(* s) + g_cases |= (1 << ((* s++) - 'a')); + } + + ndbout_c("table: %s", g_tablename); + printf("operations: "); + for(i = 0; i<OP_COUNT; i++) + if(g_use_ops & (1 << i)) + printf("%c", 'a'+i); + printf("\n"); + + printf("test cases: "); + for(i = 0; i<3; i++) + if(g_cases & (1 << i)) + printf("%c", '1'+i); + printf("\n"); + printf("-------------\n"); return 0; } @@ -141,10 +255,11 @@ static int connect_ndb() } g_ndb = new Ndb(g_cluster_connection, "TEST_DB"); - g_ndb->init(); + g_ndb->init(256); if(g_ndb->waitUntilReady(30) == 0){ - int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP }; - return g_restarter.dumpStateAllNodes(args, 1); + return 0; +// int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP }; +// return g_restarter.dumpStateAllNodes(args, 1); } return -1; } @@ -211,77 +326,165 @@ static int load_table() HugoOperations ops(* g_table); require(!ops.startTransaction(g_ndb)); + size_t op = 0; + size_t rows = 0; + size_t uncommitted = 0; + bool prepared = false; for(size_t i = 0; i<g_rows; i++){ - g_cases[i] = g_ops[ i % OP_COUNT]; - if(g_cases[i].start_row){ - g_cases[i].curr_row = true; - g_cases[i].val = rand(); - require(!ops.pkInsertRecord(g_ndb, i, 1, g_cases[i].val)); + for(op %= OP_COUNT; !((1 << op) & g_use_ops); op = (op + 1) % OP_COUNT); + g_ops[i] = g_op_types[op++]; + if(g_ops[i].start_row){ + g_ops[i].curr_row = true; + g_ops[i].val = rand(); + require(!ops.pkInsertRecord(g_ndb, i, 1, g_ops[i].val)); + uncommitted++; + } else { + g_ops[i].curr_row = false; } - if((i+1) % 100 == 0){ + if(uncommitted >= 100){ require(!ops.execute_Commit(g_ndb)); require(!ops.getTransaction()->restart()); + rows += uncommitted; + uncommitted = 0; } } - if((g_rows+1) % 100 != 0) + if(uncommitted) require(!ops.execute_Commit(g_ndb)); + + require(!ops.closeTransaction(g_ndb)); + rows += uncommitted; + g_info << "Inserted " << rows << " rows" << endl; return 0; } -static int pause_lcp() +static int pause_lcp(int error) { - return 0; + int nodes = g_restarter.getNumDbNodes(); + + int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_INFO, 0 }; + int fd = ndb_mgm_listen_event(g_restarter.handle, filter); + require(fd >= 0); + require(!g_restarter.insertErrorInAllNodes(error)); + int dump[] = { DumpStateOrd::DihStartLcpImmediately }; + require(!g_restarter.dumpStateAllNodes(dump, 1)); + + char *tmp; + char buf[1024]; + SocketInputStream in(fd, 1000); + int count = 0; + do { + tmp = in.gets(buf, 1024); + if(tmp) + { + int id; + if(sscanf(tmp, "%*[^:]: LCP: %d ", &id) == 1 && id == error && + --nodes == 0){ + close(fd); + return 0; + } + } + } while(count++ < 30); + + close(fd); + return -1; } static int do_op(int row) { HugoOperations & ops = * g_hugo_ops; - if(strcmp(g_cases[row].op1, "INSERT") == 0){ - require(!g_cases[row].curr_row); - g_cases[row].curr_row = true; - g_cases[row].val = rand(); - require(!ops.pkInsertRecord(g_ndb, row, 1, g_cases[row].val)); - } else if(strcmp(g_cases[row].op1, "UPDATE") == 0){ - require(g_cases[row].curr_row); - g_cases[row].val = rand(); - require(!ops.pkUpdateRecord(g_ndb, row, 1, g_cases[row].val)); - } else if(strcmp(g_cases[row].op1, "DELETE") == 0){ - require(g_cases[row].curr_row); - g_cases[row].curr_row = false; + if(strcmp(g_ops[row].op1, "INS") == 0){ + require(!g_ops[row].curr_row); + g_ops[row].curr_row = true; + g_ops[row].val = rand(); + require(!ops.pkInsertRecord(g_ndb, row, 1, g_ops[row].val)); + } else if(strcmp(g_ops[row].op1, "UPD") == 0){ + require(g_ops[row].curr_row); + g_ops[row].val = rand(); + require(!ops.pkUpdateRecord(g_ndb, row, 1, g_ops[row].val)); + } else if(strcmp(g_ops[row].op1, "DEL") == 0){ + require(g_ops[row].curr_row); + g_ops[row].curr_row = false; require(!ops.pkDeleteRecord(g_ndb, row, 1)); } require(!ops.execute_NoCommit(g_ndb)); - if(g_cases[row].op2 == 0){ - } else if(strcmp(g_cases[row].op2, "INSERT") == 0){ - require(!g_cases[row].curr_row); - g_cases[row].curr_row = true; - g_cases[row].val = rand(); - require(!ops.pkInsertRecord(g_ndb, row, 1, g_cases[row].val)); - } else if(strcmp(g_cases[row].op2, "UPDATE") == 0){ - require(g_cases[row].curr_row); - g_cases[row].val = rand(); - require(!ops.pkUpdateRecord(g_ndb, row, 1, g_cases[row].val)); - } else if(strcmp(g_cases[row].op2, "DELETE") == 0){ - require(g_cases[row].curr_row); - g_cases[row].curr_row = false; + if(g_ops[row].op2 == 0){ + } else if(strcmp(g_ops[row].op2, "INS") == 0){ + require(!g_ops[row].curr_row); + g_ops[row].curr_row = true; + g_ops[row].val = rand(); + require(!ops.pkInsertRecord(g_ndb, row, 1, g_ops[row].val)); + } else if(strcmp(g_ops[row].op2, "UPD") == 0){ + require(g_ops[row].curr_row); + g_ops[row].val = rand(); + require(!ops.pkUpdateRecord(g_ndb, row, 1, g_ops[row].val)); + } else if(strcmp(g_ops[row].op2, "DEL") == 0){ + require(g_ops[row].curr_row); + g_ops[row].curr_row = false; require(!ops.pkDeleteRecord(g_ndb, row, 1)); } - if(g_cases[row].op2 != 0) + if(g_ops[row].op2 != 0) require(!ops.execute_NoCommit(g_ndb)); + + if(g_ops[row].op3 == 0){ + } else if(strcmp(g_ops[row].op3, "INS") == 0){ + require(!g_ops[row].curr_row); + g_ops[row].curr_row = true; + g_ops[row].val = rand(); + require(!ops.pkInsertRecord(g_ndb, row, 1, g_ops[row].val)); + } else if(strcmp(g_ops[row].op3, "UPD") == 0){ + require(g_ops[row].curr_row); + g_ops[row].val = rand(); + require(!ops.pkUpdateRecord(g_ndb, row, 1, g_ops[row].val)); + } else if(strcmp(g_ops[row].op3, "DEL") == 0){ + require(g_ops[row].curr_row); + g_ops[row].curr_row = false; + require(!ops.pkDeleteRecord(g_ndb, row, 1)); + } + + if(g_ops[row].op3 != 0) + require(!ops.execute_NoCommit(g_ndb)); + return 0; } static int continue_lcp(int error) { - error = 0; - if(g_restarter.insertErrorInAllNodes(error) == 0){ - int args[] = { DumpStateOrd::DihStartLcpImmediately }; - return g_restarter.dumpStateAllNodes(args, 1); + int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_INFO, 0 }; + int fd = -1; + if(error){ + fd = ndb_mgm_listen_event(g_restarter.handle, filter); + require(fd >= 0); } - return -1; + + int args[] = { DumpStateOrd::LCPContinue }; + if(g_restarter.dumpStateAllNodes(args, 1) != 0) + return -1; + + if(error){ + char *tmp; + char buf[1024]; + SocketInputStream in(fd, 1000); + int count = 0; + int nodes = g_restarter.getNumDbNodes(); + do { + tmp = in.gets(buf, 1024); + if(tmp) + { + int id; + if(sscanf(tmp, "%*[^:]: LCP: %d ", &id) == 1 && id == error && + --nodes == 0){ + close(fd); + return 0; + } + } + } while(count++ < 30); + + close(fd); + } + return 0; } static int commit() @@ -297,6 +500,7 @@ static int commit() static int restart() { g_info << "Restarting cluster" << endl; + g_hugo_ops->closeTransaction(g_ndb); disconnect_ndb(); delete g_hugo_ops; @@ -315,17 +519,25 @@ static int validate() { HugoOperations ops(* g_table); for(size_t i = 0; i<g_rows; i++){ - require(g_cases[i].curr_row == g_cases[i].end_row); + require(g_ops[i].curr_row == g_ops[i].end_row); require(!ops.startTransaction(g_ndb)); ops.pkReadRecord(g_ndb, i, 1); int res = ops.execute_Commit(g_ndb); - if(g_cases[i].curr_row){ - require(res == 0 && ops.verifyUpdatesValue(g_cases[i].val) == 0); + if(g_ops[i].curr_row){ + require(res == 0 && ops.verifyUpdatesValue(g_ops[i].val) == 0); } else { require(res == 626); } ops.closeTransaction(g_ndb); } + + for(size_t j = 0; j<10; j++){ + UtilTransactions clear(* g_table); + require(!clear.clearTable(g_ndb)); + + HugoTransactions trans(* g_table); + require(trans.loadTable(g_ndb, 1024) == 0); + } return 0; } diff --git a/storage/ndb/test/ndbapi/testOIBasic.cpp b/storage/ndb/test/ndbapi/testOIBasic.cpp index 942ee2ec966..a752b9995f0 100644 --- a/storage/ndb/test/ndbapi/testOIBasic.cpp +++ b/storage/ndb/test/ndbapi/testOIBasic.cpp @@ -4237,8 +4237,7 @@ readverifyfull(Par par) CHK(scanreadtable(par) == 0); // once more via tup scan par.m_tupscan = true; - if (NDB_VERSION < MAKE_VERSION(5, 1, 0)) //TODO - CHK(scanreadtable(par) == 0); + CHK(scanreadtable(par) == 0); } // each thread scans different indexes for (unsigned i = 0; i < tab.m_itabs; i++) { @@ -4614,20 +4613,29 @@ tbuild(Par par) RUNSTEP(par, createtable, ST); RUNSTEP(par, invalidatetable, MT); for (par.m_slno = 0; par.m_slno < par.m_subloop; par.m_slno++) { - if (par.m_slno % 2 == 0) { + if (par.m_slno % 3 == 0) { RUNSTEP(par, createindex, ST); RUNSTEP(par, invalidateindex, MT); RUNSTEP(par, pkinsert, MT); + RUNSTEP(par, pkupdate, MT); + } else if (par.m_slno % 3 == 1) { + RUNSTEP(par, pkinsert, MT); + RUNSTEP(par, createindex, ST); + RUNSTEP(par, invalidateindex, MT); + RUNSTEP(par, pkupdate, MT); } else { RUNSTEP(par, pkinsert, MT); + RUNSTEP(par, pkupdate, MT); RUNSTEP(par, createindex, ST); RUNSTEP(par, invalidateindex, MT); } - RUNSTEP(par, pkupdate, MT); - RUNSTEP(par, readverifyfull, MT); - RUNSTEP(par, pkdelete, MT); RUNSTEP(par, readverifyfull, MT); - RUNSTEP(par, dropindex, ST); + // leave last one alone e.g. to continue manually + if (par.m_slno + 1 < par.m_subloop) { + RUNSTEP(par, pkdelete, MT); + RUNSTEP(par, readverifyfull, MT); + RUNSTEP(par, dropindex, ST); + } } return 0; } diff --git a/storage/ndb/test/ndbapi/testPartitioning.cpp b/storage/ndb/test/ndbapi/testPartitioning.cpp index 0b88896566b..2607d18967e 100644 --- a/storage/ndb/test/ndbapi/testPartitioning.cpp +++ b/storage/ndb/test/ndbapi/testPartitioning.cpp @@ -35,7 +35,7 @@ run_drop_table(NDBT_Context* ctx, NDBT_Step* step) static int -add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when) +add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when, void* arg) { switch(when){ case 0: // Before @@ -70,8 +70,16 @@ add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when) BaseString name; name.assfmt("PK_DK_%d", dks); col.setName(name.c_str()); - col.setType(NdbDictionary::Column::Unsigned); - col.setLength(1); + if((rand() % 100) > 50) + { + col.setType(NdbDictionary::Column::Unsigned); + col.setLength(1); + } + else + { + col.setType(NdbDictionary::Column::Varbinary); + col.setLength(1+(rand() % 25)); + } col.setNullable(false); col.setPrimaryKey(true); col.setDistributionKey(true); @@ -348,8 +356,9 @@ run_startHint(NDBT_Context* ctx, NDBT_Step* step) int sz = tab->getColumn(j)->getSizeInBytes(); int aligned_size = 4 * ((sz + 3) >> 2); memset(pos, 0, aligned_size); - dummy.calcValue(i, j, 0, pos, sz); - pos += aligned_size; + Uint32 real_size; + dummy.calcValue(i, j, 0, pos, sz, &real_size); + pos += (real_size + 3) & ~3; } } // Now we have the pk diff --git a/storage/ndb/test/run-test/daily-basic-tests.txt b/storage/ndb/test/run-test/daily-basic-tests.txt index 8b44594a9b5..ca4cc10f8cd 100644 --- a/storage/ndb/test/run-test/daily-basic-tests.txt +++ b/storage/ndb/test/run-test/daily-basic-tests.txt @@ -81,23 +81,23 @@ args: -n UpdateAndRead max-time: 500 cmd: testBasic -args: -n PkReadAndLocker T6 +args: -n PkReadAndLocker T6 D1 D2 max-time: 500 cmd: testBasic -args: -n PkReadAndLocker2 T6 +args: -n PkReadAndLocker2 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n PkReadUpdateAndLocker T6 +args: -n PkReadUpdateAndLocker T6 D1 D2 max-time: 500 cmd: testBasic -args: -n ReadWithLocksAndInserts T6 +args: -n ReadWithLocksAndInserts T6 D1 D2 max-time: 500 cmd: testBasic -args: -n PkInsertTwice T1 T6 T10 +args: -n PkInsertTwice T1 T6 T10 D1 D2 max-time: 1500 cmd: testBasic @@ -109,79 +109,79 @@ args: -n Fill T6 max-time: 500 cmd: testBasic -args: -n NoCommitSleep T6 +args: -n NoCommitSleep T6 D1 D2 max-time: 500 cmd: testBasic -args: -n NoCommit626 T6 +args: -n NoCommit626 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n NoCommitAndClose T6 +args: -n NoCommitAndClose T6 D1 D2 max-time: 500 cmd: testBasic -args: -n Commit626 T6 +args: -n Commit626 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n CommitTry626 T6 +args: -n CommitTry626 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n CommitAsMuch626 T6 +args: -n CommitAsMuch626 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n NoCommit626 T6 +args: -n NoCommit626 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n NoCommitRollback626 T1 T6 +args: -n NoCommitRollback626 T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n Commit630 T1 T6 +args: -n Commit630 T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n CommitTry630 T1 T6 +args: -n CommitTry630 T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n CommitAsMuch630 T1 T6 +args: -n CommitAsMuch630 T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n NoCommit630 T1 T6 +args: -n NoCommit630 T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n NoCommitRollback630 T1 T6 +args: -n NoCommitRollback630 T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n NoCommitAndClose T1 T6 +args: -n NoCommitAndClose T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n RollbackUpdate T1 T6 +args: -n RollbackUpdate T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n RollbackDeleteMultiple T1 T6 +args: -n RollbackDeleteMultiple T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n ImplicitRollbackDelete T1 T6 +args: -n ImplicitRollbackDelete T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n CommitDelete T1 T6 +args: -n CommitDelete T1 T6 D1 D2 max-time: 500 cmd: testBasic -args: -n RollbackNothing T1 T6 +args: -n RollbackNothing T1 T6 D1 D2 max-time: 500 cmd: testBasicAsynch @@ -201,11 +201,11 @@ args: -n PkDeleteAsynch max-time: 500 cmd: testBasic -args: -n MassiveRollback T1 T6 T13 +args: -n MassiveRollback T1 T6 T13 D1 D2 max-time: 500 cmd: testBasic -args: -n MassiveRollback2 T1 T6 T13 +args: -n MassiveRollback2 T1 T6 T13 D1 D2 max-time: 500 cmd: testTimeout @@ -231,7 +231,7 @@ args: -n ScanUpdate max-time: 500 cmd: testScan -args: -n ScanUpdate2 T6 +args: -n ScanUpdate2 T6 D1 D2 max-time: 500 cmd: testScan @@ -239,47 +239,47 @@ args: -n ScanDelete max-time: 500 cmd: testScan -args: -n ScanDelete2 T10 +args: -n ScanDelete2 T10 D1 D2 max-time: 500 cmd: testScan -args: -n ScanUpdateAndScanRead T6 +args: -n ScanUpdateAndScanRead T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadAndLocker T6 +args: -n ScanReadAndLocker T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadAndPkRead T6 +args: -n ScanReadAndPkRead T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanRead488 -l 10 T6 +args: -n ScanRead488 -l 10 T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanRead488O -l 10 T6 +args: -n ScanRead488O -l 10 T6 D1 D2 max-time: 1000 cmd: testScan -args: -n ScanRead488_Mixed -l 10 T6 +args: -n ScanRead488_Mixed -l 10 T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanRead488Timeout -l 10 T6 +args: -n ScanRead488Timeout -l 10 T6 D1 D2 max-time: 600 cmd: testScan -args: -n ScanRead40 -l 100 T2 +args: -n ScanRead40 -l 100 T2 D1 D2 max-time: 1800 cmd: testScan -args: -n ScanRead100 -l 100 T1 +args: -n ScanRead100 -l 100 T1 D1 D2 max-time: 600 cmd: testScan -args: -n ScanRead40 -l 100 T1 +args: -n ScanRead40 -l 100 T1 D1 D2 max-time: 1800 cmd: testScan @@ -291,123 +291,123 @@ args: -n ScanRead40RandomTable -l 1000 T2 max-time: 500 cmd: testScan -args: -n ScanWithLocksAndInserts T6 +args: -n ScanWithLocksAndInserts T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadAbort T6 +args: -n ScanReadAbort T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadAbort15 T6 +args: -n ScanReadAbort15 T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadAbort240 T6 +args: -n ScanReadAbort240 T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanUpdateAbort16 T6 +args: -n ScanUpdateAbort16 T6 D1 D2 max-time: 3600 cmd: testScan -args: -n ScanReadRestart T1 T6 T13 +args: -n ScanReadRestart T1 T6 T13 D1 D2 max-time: 500 cmd: testScan -args: -n ScanUpdateRestart T6 +args: -n ScanUpdateRestart T6 D1 D2 max-time: 500 cmd: testScan -args: -n CheckGetValue T6 +args: -n CheckGetValue T6 D1 D2 max-time: 500 cmd: testScan -args: -n CloseWithoutStop T6 +args: -n CloseWithoutStop T6 D1 D2 max-time: 500 cmd: testScan -args: -n NextScanWhenNoMore T6 +args: -n NextScanWhenNoMore T6 D1 D2 max-time: 500 cmd: testScan -args: -n ExecuteScanWithoutOpenScan T6 +args: -n ExecuteScanWithoutOpenScan T6 D1 D2 max-time: 500 cmd: testScan -args: -n OnlyOpenScanOnce T6 +args: -n OnlyOpenScanOnce T6 D1 D2 max-time: 500 cmd: testScan -args: -n OnlyOneOpInScanTrans T6 +args: -n OnlyOneOpInScanTrans T6 D1 D2 max-time: 500 cmd: testScan -args: -n OnlyOneOpBeforeOpenScan T6 +args: -n OnlyOneOpBeforeOpenScan T6 D1 D2 max-time: 500 cmd: testScan -args: -n OnlyOneScanPerTrans T6 +args: -n OnlyOneScanPerTrans T6 D1 D2 max-time: 500 cmd: testScan -args: -n NoCloseTransaction T6 +args: -n NoCloseTransaction T6 D1 D2 max-time: 500 cmd: testScan -args: -n CheckInactivityTimeOut T6 +args: -n CheckInactivityTimeOut T6 D1 D2 max-time: 500 cmd: testScan -args: -n CheckInactivityBeforeClose T6 +args: -n CheckInactivityBeforeClose T6 D1 D2 max-time: 500 cmd: testScan -args: -n CheckAfterTerror T6 +args: -n CheckAfterTerror T6 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadError5021 T1 +args: -n ScanReadError5021 T1 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReaderror5022 T1 +args: -n ScanReaderror5022 T1 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadError5023 T1 +args: -n ScanReadError5023 T1 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadError5024 T1 +args: -n ScanReadError5024 T1 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadError5025 T1 +args: -n ScanReadError5025 T1 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadError5030 T1 +args: -n ScanReadError5030 T1 D1 D2 max-time: 500 cmd: testScan -args: -n InsertDelete T1 T6 +args: -n InsertDelete T1 T6 D1 D2 max-time: 500 cmd: testScan -args: -n CheckAfterTerror T1 +args: -n CheckAfterTerror T1 D1 D2 max-time: 500 cmd: testScan -args: -n ScanReadWhileNodeIsDown T1 +args: -n ScanReadWhileNodeIsDown T1 D1 D2 max-time: 500 cmd: testScan -args: -n ScanRestart T1 +args: -n ScanRestart T1 D1 D2 max-time: 500 cmd: testScan -args: -l 100 -n Scan-bug8262 T7 +args: -l 100 -n Scan-bug8262 T7 D1 D2 max-time: 500 cmd: testScan @@ -425,7 +425,7 @@ args: -n CreateAndDropWithData max-time: 1500 cmd: testDict -args: -n CreateAndDropDuring T6 T10 +args: -n CreateAndDropDuring T6 T10 D1 D2 max-time: 1500 cmd: testDict @@ -510,23 +510,23 @@ args: -n GetValueInUpdate T6 max-time: 500 cmd: testNdbApi -args: -n UpdateWithoutKeys T6 +args: -n UpdateWithoutKeys T6 D1 D2 max-time: 500 cmd: testNdbApi -args: -n UpdateWithoutValues T6 +args: -n UpdateWithoutValues T6 D1 D2 max-time: 500 cmd: testNdbApi -args: -n ReadWithoutGetValue +args: -n ReadWithoutGetValue D1 D2 max-time: 500 cmd: testNdbApi -args: -n Bug_11133 T1 +args: -n Bug_11133 T1 D1 D2 max-time: 500 cmd: testNdbApi -args: -n Scan_4006 T1 +args: -n Scan_4006 T1 D1 D2 #max-time: 500 #cmd: testInterpreter @@ -582,6 +582,14 @@ args: -n SR1 T8 max-time: 1500 cmd: testSystemRestart +args: -n SR1 D1 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR1 D2 + +max-time: 1500 +cmd: testSystemRestart args: -n SR2 T1 max-time: 1500 @@ -594,6 +602,14 @@ args: -n SR2 T7 max-time: 1500 cmd: testSystemRestart +args: -n SR2 D1 + +max-time: 1500 +cmd: testSystemRestart +args: -n SR2 D2 + +max-time: 1500 +cmd: testSystemRestart args: -n SR_UNDO T1 max-time: 1500 diff --git a/storage/ndb/test/src/HugoCalculator.cpp b/storage/ndb/test/src/HugoCalculator.cpp index d4d7ca2f95f..06aab5b8669 100644 --- a/storage/ndb/test/src/HugoCalculator.cpp +++ b/storage/ndb/test/src/HugoCalculator.cpp @@ -77,7 +77,8 @@ HugoCalculator::calcValue(int record, int updates) const { Int32 i; - calcValue(record, attrib, updates, (char*)&i, sizeof(i)); + Uint32 j; + calcValue(record, attrib, updates, (char*)&i, sizeof(i), &j); return i; } @@ -94,10 +95,12 @@ HugoCalculator::calcValue(int record, int attrib, int updates, char* buf, - int len) const { + int len, + Uint32 *outlen) const { Uint64 seed; const NdbDictionary::Column* attr = m_tab.getColumn(attrib); Uint32 val; + * outlen = len; do { if (attrib == m_idCol) @@ -128,9 +131,13 @@ HugoCalculator::calcValue(int record, val = myRand(&seed); if(attr->getNullable() && (((val >> 16) & 255) > 220)) + { + * outlen = 0; return NULL; + } int pos= 0; + char* dst= buf; switch(attr->getType()){ case NdbDictionary::Column::Tinyint: case NdbDictionary::Column::Tinyunsigned: @@ -172,34 +179,45 @@ HugoCalculator::calcValue(int record, break; case NdbDictionary::Column::Varbinary: case NdbDictionary::Column::Varchar: - case NdbDictionary::Column::Text: - case NdbDictionary::Column::Char: + len = 1 + (myRand(&seed) % (len - 1)); + assert(len < 256); + * outlen = len + 1; + * buf = len; + dst++; + goto write_char; case NdbDictionary::Column::Longvarchar: case NdbDictionary::Column::Longvarbinary: + len = 1 + (myRand(&seed) % (len - 2)); + assert(len < 65536); + * outlen = len + 2; + int2store(buf, len); + dst += 2; +write_char: + case NdbDictionary::Column::Char: { char* ptr= (char*)&val; while(len >= 4) { len -= 4; - buf[pos++] = base64_table[ptr[0] & 0x3f]; - buf[pos++] = base64_table[ptr[1] & 0x3f]; - buf[pos++] = base64_table[ptr[2] & 0x3f]; - buf[pos++] = base64_table[ptr[3] & 0x3f]; + dst[pos++] = base64_table[ptr[0] & 0x3f]; + dst[pos++] = base64_table[ptr[1] & 0x3f]; + dst[pos++] = base64_table[ptr[2] & 0x3f]; + dst[pos++] = base64_table[ptr[3] & 0x3f]; val= myRand(&seed); } for(; len; len--, pos++) - buf[pos] = base64_table[ptr[len] & 0x3f]; + dst[pos] = base64_table[ptr[len] & 0x3f]; pos--; break; } case NdbDictionary::Column::Blob: case NdbDictionary::Column::Undefined: + case NdbDictionary::Column::Text: abort(); break; } - return buf; } @@ -216,9 +234,9 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ for (int i = 0; i<m_tab.getNoOfColumns(); i++){ if (i != m_updatesCol && id != m_idCol) { const NdbDictionary::Column* attr = m_tab.getColumn(i); - Uint32 len = attr->getSizeInBytes(); + Uint32 len = attr->getSizeInBytes(), real_len; char buf[8000]; - const char* res = calcValue(id, i, updates, buf, len); + const char* res = calcValue(id, i, updates, buf, len, &real_len); if (res == NULL){ if (!pRow->attributeStore(i)->isNULL()){ g_err << "|- NULL ERROR: expected a NULL but the column was not null" << endl; @@ -226,7 +244,16 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ result = -1; } } else{ - if (memcmp(res, pRow->attributeStore(i)->aRef(), len) != 0){ + if (real_len != pRow->attributeStore(i)->get_size_in_bytes()) + { + g_err << "|- Invalid data found in attribute " << i << ": \"" + << "Length of expected=" << real_len << endl + << "Lenght of read=" + << pRow->attributeStore(i)->get_size_in_bytes() << endl; + result= -1; + } + else if (memcmp(res, pRow->attributeStore(i)->aRef(), real_len) != 0) + { g_err << "Column: " << attr->getName() << endl; const char* buf2 = pRow->attributeStore(i)->aRef(); for (Uint32 j = 0; j < len; j++) @@ -244,7 +271,7 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ << "\" != \"" << res << "\"" << endl << "Length of expected=" << (unsigned)strlen(res) << endl << "Lenght of read=" - << (unsigned)strlen(pRow->attributeStore(i)->aRef()) << endl; + << pRow->attributeStore(i)->get_size_in_bytes() << endl; g_err << "|- The row: \"" << (* pRow) << "\"" << endl; result = -1; } diff --git a/storage/ndb/test/src/HugoOperations.cpp b/storage/ndb/test/src/HugoOperations.cpp index 6cd40179205..84ea88388dc 100644 --- a/storage/ndb/test/src/HugoOperations.cpp +++ b/storage/ndb/test/src/HugoOperations.cpp @@ -516,8 +516,9 @@ int HugoOperations::equalForAttr(NdbOperation* pOp, int len = attr->getSizeInBytes(); char buf[8000]; memset(buf, 0, sizeof(buf)); - return pOp->equal( attr->getName(), - calc.calcValue(rowId, attrId, 0, buf, len)); + Uint32 real_len; + const char * value = calc.calcValue(rowId, attrId, 0, buf, len, &real_len); + return pOp->equal( attr->getName(), value, real_len); } int HugoOperations::setValueForAttr(NdbOperation* pOp, @@ -530,8 +531,10 @@ int HugoOperations::setValueForAttr(NdbOperation* pOp, int len = attr->getSizeInBytes(); char buf[8000]; memset(buf, 0, sizeof(buf)); - return pOp->setValue( attr->getName(), - calc.calcValue(rowId, attrId, updateId, buf, len)); + Uint32 real_len; + const char * value = calc.calcValue(rowId, attrId, + updateId, buf, len, &real_len); + return pOp->setValue( attr->getName(), value, real_len); } int diff --git a/storage/ndb/test/src/HugoTransactions.cpp b/storage/ndb/test/src/HugoTransactions.cpp index b8614369f2d..74aab2aa55a 100644 --- a/storage/ndb/test/src/HugoTransactions.cpp +++ b/storage/ndb/test/src/HugoTransactions.cpp @@ -518,7 +518,8 @@ HugoTransactions::loadTable(Ndb* pNdb, int batch, bool allowConstraintViolation, int doSleep, - bool oneTrans){ + bool oneTrans, + int value){ int check, a; int retryAttempt = 0; int retryMax = 5; @@ -573,7 +574,7 @@ HugoTransactions::loadTable(Ndb* pNdb, } } - if(pkInsertRecord(pNdb, c, batch) != NDBT_OK) + if(pkInsertRecord(pNdb, c, batch, value) != NDBT_OK) { ERR(pTrans->getNdbError()); closeTransaction(pNdb); diff --git a/storage/ndb/test/src/NDBT_ResultRow.cpp b/storage/ndb/test/src/NDBT_ResultRow.cpp index 09e6b8a383c..4552c6741f9 100644 --- a/storage/ndb/test/src/NDBT_ResultRow.cpp +++ b/storage/ndb/test/src/NDBT_ResultRow.cpp @@ -95,10 +95,19 @@ BaseString NDBT_ResultRow::c_str() const { str.append(buf); }else{ Uint32* p = (Uint32*)data[i]->aRef(); - Uint32 sizeInBytes = data[i]->attrSize() * data[i]->arraySize(); + Uint32 sizeInBytes = data[i]->get_size_in_bytes(); for (Uint32 j = 0; j < sizeInBytes; j+=(sizeof(Uint32))){ str.append("H'"); - sprintf(buf, "%.8x", *p); + if (j + 4 < sizeInBytes) + { + sprintf(buf, "%.8x", *p); + } + else + { + Uint32 tmp = 0; + memcpy(&tmp, p, sizeInBytes - j); + sprintf(buf, "%.8x", tmp); + } p++; str.append(buf); if ((j + sizeof(Uint32)) < sizeInBytes) diff --git a/storage/ndb/test/src/NDBT_Tables.cpp b/storage/ndb/test/src/NDBT_Tables.cpp index ce4c49b3c75..3cbd3fb305e 100644 --- a/storage/ndb/test/src/NDBT_Tables.cpp +++ b/storage/ndb/test/src/NDBT_Tables.cpp @@ -142,7 +142,7 @@ NDBT_Attribute T7Attribs[] = { NDBT_Attribute("PK1", NdbDictionary::Column::Unsigned, 1, true), NDBT_Attribute("PK2", NdbDictionary::Column::Unsigned, 1, true), NDBT_Attribute("PK3", NdbDictionary::Column::Unsigned, 1, true), - NDBT_Attribute("PK4", NdbDictionary::Column::Unsigned, 1, true), + NDBT_Attribute("PK4", NdbDictionary::Column::Varbinary, 123, true), NDBT_Attribute("ATTR1", NdbDictionary::Column::Unsigned), NDBT_Attribute("ATTR2", NdbDictionary::Column::Unsigned), NDBT_Attribute("ATTR3", NdbDictionary::Column::Unsigned), @@ -173,8 +173,8 @@ static const NDBT_Attribute T8Attribs[] = { NDBT_Attribute("PERSON_ID", NdbDictionary::Column::Unsigned, 1, true), - NDBT_Attribute("NAME", NdbDictionary::Column::Char, 257), - NDBT_Attribute("ADRESS", NdbDictionary::Column::Char, 513), + NDBT_Attribute("NAME", NdbDictionary::Column::Varbinary, 255), + NDBT_Attribute("ADRESS", NdbDictionary::Column::Longvarbinary, 513), NDBT_Attribute("POSTADRESS", NdbDictionary::Column::Char, 1173), NDBT_Attribute("VALUE", NdbDictionary::Column::Unsigned), @@ -383,6 +383,35 @@ static NDBT_Table I3("I3", sizeof(I3_Cols)/sizeof(NDBT_Attribute), I3_Cols ); // ,I3_Indexes); +/* D1 */ +static +const +NDBT_Attribute D1Attribs[] = { + NDBT_Attribute("KOL1", NdbDictionary::Column::Unsigned, 1, true), + NDBT_Attribute("KOL2", NdbDictionary::Column::Unsigned, 1, false, false, 0, NdbDictionary::Column::StorageTypeDisk), + NDBT_Attribute("KOL3", NdbDictionary::Column::Unsigned), + NDBT_Attribute("KOL4", NdbDictionary::Column::Char, 233, false, true, 0, NdbDictionary::Column::StorageTypeDisk), + NDBT_Attribute("KOL5", NdbDictionary::Column::Unsigned), +}; +static +const +NDBT_Table D1("D1", sizeof(D1Attribs)/sizeof(NDBT_Attribute), D1Attribs); + +static +const +NDBT_Attribute D2Attribs[] = { + NDBT_Attribute("KOL1", NdbDictionary::Column::Varbinary, 127, true), + NDBT_Attribute("KOL2", NdbDictionary::Column::Unsigned, 1, false, false, 0, NdbDictionary::Column::StorageTypeDisk), + NDBT_Attribute("KOL3", NdbDictionary::Column::Unsigned), + NDBT_Attribute("KOL4", NdbDictionary::Column::Varbinary, 133), + NDBT_Attribute("KOL5", NdbDictionary::Column::Char, 199, false, true, 0, NdbDictionary::Column::StorageTypeDisk), + NDBT_Attribute("KOL6", NdbDictionary::Column::Bit, 21, false, false, 0, NdbDictionary::Column::StorageTypeDisk), +}; +static +const +NDBT_Table D2("D2", sizeof(D2Attribs)/sizeof(NDBT_Attribute), D2Attribs); + + // Define array with pointer to all tables static const @@ -404,7 +433,8 @@ NDBT_Table *test_tables[]= &T14, &I1, &I2, - &I3 + &I3, + &D1, &D2 }; struct NDBT_IndexList { @@ -818,10 +848,113 @@ NDBT_Tables::createAllTables(Ndb* pNdb){ return createAllTables(pNdb, false); } +static int -NDBT_Tables::createTable(Ndb* pNdb, const char* _name, bool _temp, - bool existsOk, NDBT_CreateTableHook f){ +create_default_tablespace(Ndb* pNdb) +{ + NdbDictionary::Dictionary* pDict = pNdb->getDictionary(); + + int res; + NdbDictionary::LogfileGroup lg = pDict->getLogfileGroup("DEFAULT-LG"); + if (strcmp(lg.getName(), "DEFAULT-LG") != 0) + { + lg.setName("DEFAULT-LG"); + lg.setUndoBufferSize(8*1024*1024); + res = pDict->createLogfileGroup(lg); + if(res != 0){ + g_err << "Failed to create logfilegroup:" + << endl << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + } + { + NdbDictionary::Undofile uf = pDict->getUndofile(0, "undofile01.dat"); + if (strcmp(uf.getPath(), "undofile01.dat") != 0) + { + uf.setPath("undofile01.dat"); + uf.setSize(32*1024*1024); + uf.setLogfileGroup("DEFAULT-LG"); + + res = pDict->createUndofile(uf, true); + if(res != 0){ + g_err << "Failed to create undofile:" + << endl << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + } + } + { + NdbDictionary::Undofile uf = pDict->getUndofile(0, "undofile02.dat"); + if (strcmp(uf.getPath(), "undofile02.dat") != 0) + { + uf.setPath("undofile02.dat"); + uf.setSize(32*1024*1024); + uf.setLogfileGroup("DEFAULT-LG"); + + res = pDict->createUndofile(uf, true); + if(res != 0){ + g_err << "Failed to create undofile:" + << endl << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + } + } + NdbDictionary::Tablespace ts = pDict->getTablespace("DEFAULT-TS"); + if (strcmp(ts.getName(), "DEFAULT-TS") != 0) + { + ts.setName("DEFAULT-TS"); + ts.setExtentSize(1024*1024); + ts.setDefaultLogfileGroup("DEFAULT-LG"); + + res = pDict->createTablespace(ts); + if(res != 0){ + g_err << "Failed to create tablespace:" + << endl << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + } + { + NdbDictionary::Datafile df = pDict->getDatafile(0, "datafile01.dat"); + if (strcmp(df.getPath(), "datafile01.dat") != 0) + { + df.setPath("datafile01.dat"); + df.setSize(64*1024*1024); + df.setTablespace("DEFAULT-TS"); + + res = pDict->createDatafile(df, true); + if(res != 0){ + g_err << "Failed to create datafile:" + << endl << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + } + } + + { + NdbDictionary::Datafile df = pDict->getDatafile(0, "datafile02.dat"); + if (strcmp(df.getPath(), "datafile02.dat") != 0) + { + df.setPath("datafile02.dat"); + df.setSize(64*1024*1024); + df.setTablespace("DEFAULT-TS"); + + res = pDict->createDatafile(df, true); + if(res != 0){ + g_err << "Failed to create datafile:" + << endl << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + } + } + + return NDBT_OK; +} + +int +NDBT_Tables::createTable(Ndb* pNdb, const char* _name, bool _temp, + bool existsOk, NDBT_CreateTableHook f, void* arg) +{ const NdbDictionary::Table* tab = NDBT_Tables::getTable(_name); if (tab == NULL){ ndbout << "Could not create table " << _name @@ -834,21 +967,31 @@ NDBT_Tables::createTable(Ndb* pNdb, const char* _name, bool _temp, do { NdbDictionary::Table tmpTab(* tab); tmpTab.setStoredTable(_temp ? 0 : 1); - if(f != 0 && f(pNdb, tmpTab, 0)) + if(f != 0 && f(pNdb, tmpTab, 0, arg)) { ndbout << "Failed to create table" << endl; return NDBT_FAILED; - } + } +loop: r = pNdb->getDictionary()->createTable(tmpTab); if(r == -1){ + if(pNdb->getDictionary()->getNdbError().code == 723) + { + if (create_default_tablespace(pNdb) == 0) + { + goto loop; + } + } if(!existsOk){ - ndbout << "Error: " << pNdb->getDictionary()->getNdbError() << endl; + ndbout << "Error0: " << pNdb->getDictionary()->getNdbError() << endl; + break; } if(pNdb->getDictionary()->getNdbError().code != 721){ ndbout << "Error: " << pNdb->getDictionary()->getNdbError() << endl; break; } + r = 0; } @@ -887,7 +1030,7 @@ NDBT_Tables::createTable(Ndb* pNdb, const char* _name, bool _temp, } } } - if(f != 0 && f(pNdb, tmpTab, 1)) + if(f != 0 && f(pNdb, tmpTab, 1, arg)) { ndbout << "Failed to create table" << endl; return NDBT_FAILED; diff --git a/storage/ndb/test/src/NDBT_Test.cpp b/storage/ndb/test/src/NDBT_Test.cpp index 4cd9df8e538..701c9912373 100644 --- a/storage/ndb/test/src/NDBT_Test.cpp +++ b/storage/ndb/test/src/NDBT_Test.cpp @@ -31,7 +31,6 @@ NDBT_Context::NDBT_Context(Ndb_cluster_connection& con) : m_cluster_connection(con) { - tab = NULL; suite = NULL; testcase = NULL; ndb = NULL; @@ -58,8 +57,8 @@ NDBT_Context::~NDBT_Context(){ } const NdbDictionary::Table* NDBT_Context::getTab(){ - assert(tab != NULL); - return tab; + assert(tables.size()); + return tables[0]; } NDBT_TestSuite* NDBT_Context::getSuite(){ @@ -225,8 +224,25 @@ bool NDBT_Context::setDbProperty(const char*, Uint32){ } void NDBT_Context::setTab(const NdbDictionary::Table* ptab){ - assert(ptab != NULL); - tab = ptab; + tables.clear(); + tables.push_back(ptab); + tables.push_back(0); +} + +void NDBT_Context::addTab(const NdbDictionary::Table* ptab){ + if(tables.size()) + tables.back() = ptab; + else + tables.push_back(ptab); + + tables.push_back(0); +} + + +const NdbDictionary::Table** +NDBT_Context::getTables() +{ + return tables.getBase(); } void NDBT_Context::setSuite(NDBT_TestSuite* psuite){ @@ -751,6 +767,8 @@ NDBT_TestSuite::NDBT_TestSuite(const char* pname):name(pname){ records = 0; loops = 0; createTable = true; + diskbased = false; + tsname = NULL; createAllTables = false; } @@ -766,6 +784,9 @@ void NDBT_TestSuite::setCreateTable(bool _flag){ createTable = _flag; } +void NDBT_TestSuite::setRunAllTables(bool _flag){ + runonce = _flag; +} void NDBT_TestSuite::setCreateAllTables(bool _flag){ createAllTables = _flag; } @@ -780,6 +801,14 @@ int NDBT_TestSuite::addTest(NDBT_TestCase* pTest){ return 0; } +static int +g_create_hook(Ndb* ndb, NdbDictionary::Table& tab, int when, void* arg) +{ + NDBT_TestSuite* ts = (NDBT_TestSuite*)arg; + return ts->createHook(ndb, tab, when); +} + + int NDBT_TestSuite::executeAll(Ndb_cluster_connection& con, const char* _testname){ @@ -796,14 +825,84 @@ int NDBT_TestSuite::executeAll(Ndb_cluster_connection& con, ndbout << name << " started [" << getDate() << "]" << endl; - testSuiteTimer.doStart(); - for (int t=0; t < NDBT_Tables::getNumTables(); t++){ - const NdbDictionary::Table* ptab = NDBT_Tables::getTable(t); - ndbout << "|- " << ptab->getName() << endl; - execute(con, &ndb, ptab, _testname); + if(!runonce) + { + testSuiteTimer.doStart(); + for (int t=0; t < NDBT_Tables::getNumTables(); t++){ + const NdbDictionary::Table* ptab = NDBT_Tables::getTable(t); + ndbout << "|- " << ptab->getName() << endl; + execute(con, &ndb, ptab, _testname); + } + testSuiteTimer.doStop(); + } + else + { + NdbDictionary::Dictionary* pDict= ndb.getDictionary(); + for (unsigned i = 0; i < tests.size(); i++){ + if (_testname != NULL && strcasecmp(tests[i]->getName(), _testname) != 0) + continue; + + + tests[i]->initBeforeTest(); + ctx = new NDBT_Context(con); + + Uint32 t; + for (t=0; t < (Uint32)NDBT_Tables::getNumTables(); t++) + { + const NdbDictionary::Table* pTab = NDBT_Tables::getTable(t); + const NdbDictionary::Table* pTab2 = pDict->getTable(pTab->getName()); + + if(pTab2 != 0 && pDict->dropTable(pTab->getName()) != 0) + { + numTestsFail++; + numTestsExecuted++; + g_err << "ERROR0: Failed to drop table " << pTab->getName() << endl; + tests[i]->saveTestResult(pTab, FAILED_TO_CREATE); + continue; + } + + if (NDBT_Tables::createTable(&ndb, pTab->getName(), false, false, + g_create_hook, this) != 0) { + numTestsFail++; + numTestsExecuted++; + g_err << "ERROR1: Failed to create table " << pTab->getName() + << pDict->getNdbError() << endl; + tests[i]->saveTestResult(pTab, FAILED_TO_CREATE); + continue; + } + pTab2 = pDict->getTable(pTab->getName()); + + ctx->addTab(pTab2); + } + + ctx->setNumRecords(records); + ctx->setNumLoops(loops); + if(remote_mgm != NULL) + ctx->setRemoteMgm(remote_mgm); + ctx->setSuite(this); + + const NdbDictionary::Table** tables= ctx->getTables(); + + result = tests[i]->execute(ctx); + tests[i]->saveTestResult(tables[0], result); + if (result != NDBT_OK) + numTestsFail++; + else + numTestsOk++; + numTestsExecuted++; + + if(result == NDBT_OK) + { + for(t = 0; tables[t] != 0; t++) + { + pDict->dropTable(tables[t]->getName()); + } + } + + delete ctx; + } } - testSuiteTimer.doStop(); return reportAllTables(_testname); } @@ -839,6 +938,25 @@ NDBT_TestSuite::executeOne(Ndb_cluster_connection& con, } } +int +NDBT_TestSuite::createHook(Ndb* ndb, NdbDictionary::Table& tab, int when) +{ + if (when == 0) { + if (diskbased) { + for (int i = 0; i < tab.getNoOfColumns(); i++) { + NdbDictionary::Column* col = tab.getColumn(i); + if (! col->getPrimaryKey()) { + col->setStorageType(NdbDictionary::Column::StorageTypeDisk); + } + } + } + if (tsname != NULL) { + tab.setTablespace(tsname); + } + } + return 0; +} + void NDBT_TestSuite::execute(Ndb_cluster_connection& con, Ndb* ndb, const NdbDictionary::Table* pTab, const char* _testname){ @@ -873,7 +991,8 @@ void NDBT_TestSuite::execute(Ndb_cluster_connection& con, continue; } - if(NDBT_Tables::createTable(ndb, pTab->getName()) != 0){ + if (NDBT_Tables::createTable(ndb, pTab->getName(), false, false, + g_create_hook, this) != 0) { numTestsFail++; numTestsExecuted++; g_err << "ERROR1: Failed to create table " << pTab->getName() diff --git a/storage/ndb/test/src/UtilTransactions.cpp b/storage/ndb/test/src/UtilTransactions.cpp index eabd22f3a17..4d220a4f77a 100644 --- a/storage/ndb/test/src/UtilTransactions.cpp +++ b/storage/ndb/test/src/UtilTransactions.cpp @@ -175,7 +175,7 @@ UtilTransactions::clearTable3(Ndb* pNdb, return NDBT_FAILED; failed: - closeTransaction(pNdb); + if(pTrans != 0) closeTransaction(pNdb); ERR(err); return (err.code != 0 ? err.code : NDBT_FAILED); } @@ -322,7 +322,7 @@ UtilTransactions::addRowToInsert(Ndb* pNdb, // Set all attributes for (int a = 0; a < tab.getNoOfColumns(); a++){ NdbRecAttr* r = row.attributeStore(a); - int sz = r->attrSize() * r->arraySize(); + int sz = r->get_size_in_bytes(); if (pInsOp->setValue(tab.getColumn(a)->getName(), r->aRef(), sz) != 0) { @@ -1422,7 +1422,7 @@ loop: } } - pTrans->close(); pTrans= 0; + closeTransaction(pNdb); g_info << row_count << " rows compared" << endl; { @@ -1442,11 +1442,7 @@ error: { g_err << err << endl; NdbSleep_MilliSleep(50); - if(pTrans != 0) - { - pTrans->close(); - pTrans= 0; - } + closeTransaction(pNdb); if(cmp.getTransaction()) cmp.closeTransaction(pNdb); @@ -1459,7 +1455,8 @@ error: } close: - if(pTrans != 0) pTrans->close(); + closeTransaction(pNdb); return return_code; } + diff --git a/storage/ndb/test/tools/hugoLoad.cpp b/storage/ndb/test/tools/hugoLoad.cpp index 1a229169650..2982e75cbf1 100644 --- a/storage/ndb/test/tools/hugoLoad.cpp +++ b/storage/ndb/test/tools/hugoLoad.cpp @@ -27,14 +27,15 @@ int main(int argc, const char** argv){ ndb_init(); int _records = 0; - const char* _tabname = NULL; int _help = 0; int _batch = 512; + int _loops = -1; const char* db = 0; struct getargs args[] = { { "records", 'r', arg_integer, &_records, "Number of records", "recs" }, { "batch", 'b', arg_integer, &_batch, "Number of operations in each transaction", "batch" }, + { "loops", 'l', arg_integer, &_loops, "Number of loops", "" }, { "database", 'd', arg_string, &db, "Database", "" }, { "usage", '?', arg_flag, &_help, "Print help", "" } }; @@ -53,7 +54,7 @@ int main(int argc, const char** argv){ arg_printusage(args, num_args, argv[0], desc); return NDBT_ProgramExit(NDBT_WRONGARGS); } - _tabname = argv[optind]; + // Connect to Ndb Ndb_cluster_connection con; @@ -72,18 +73,33 @@ int main(int argc, const char** argv){ while(MyNdb.waitUntilReady() != 0) ndbout << "Waiting for ndb to become ready..." << endl; - // Check if table exists in db - const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname); - if(pTab == NULL){ - ndbout << " Table " << _tabname << " does not exist!" << endl; - return NDBT_ProgramExit(NDBT_WRONGARGS); - } - - HugoTransactions hugoTrans(*pTab); - if (hugoTrans.loadTable(&MyNdb, - _records, - _batch) != 0){ - return NDBT_ProgramExit(NDBT_FAILED); + for(Uint32 i = optind; i<argc; i++) + { + const char* _tabname = argv[i]; + // Check if table exists in db + const NdbDictionary::Table* pTab = + NDBT_Table::discoverTableFromDb(&MyNdb, _tabname); + if(pTab == NULL){ + ndbout << " Table " << _tabname << " does not exist!" << endl; + return NDBT_ProgramExit(NDBT_WRONGARGS); + } + + HugoTransactions hugoTrans(*pTab); +loop: + if (hugoTrans.loadTable(&MyNdb, + _records, + _batch, + true, 0, false, _loops) != 0){ + return NDBT_ProgramExit(NDBT_FAILED); + } + + if(_loops > 0) + { + hugoTrans.clearTable(&MyNdb); + //hugoTrans.pkDelRecords(&MyNdb, _records); + _loops--; + goto loop; + } } return NDBT_ProgramExit(NDBT_OK); diff --git a/storage/ndb/test/tools/hugoPkReadRecord.cpp b/storage/ndb/test/tools/hugoPkReadRecord.cpp index c60a994c7d4..d0d46511487 100644 --- a/storage/ndb/test/tools/hugoPkReadRecord.cpp +++ b/storage/ndb/test/tools/hugoPkReadRecord.cpp @@ -119,60 +119,7 @@ int main(int argc, const char** argv) for (i = 0; i < table->getNoOfColumns(); i++) { NdbRecAttr* a = data[i]; - switch(a->getType()) - { - case NdbDictionary::Column::Char: - case NdbDictionary::Column::Varchar: - case NdbDictionary::Column::Binary: - case NdbDictionary::Column::Varbinary: - { - if (_hex) - { - char* b = a->aRef(); - for (int j = 0; j < a->arraySize(); j++) - { - //ndbout_c("%x", b[j]); - g_info << hex << b[j] << "[" << dec << j << "]"; - } - } - else - { - g_info << "\"" - << a->aRef() << "\""; - } - g_info << " "; - } - break; - - case NdbDictionary::Column::Int: - case NdbDictionary::Column::Unsigned: - { - g_info << a->int32_value() << " "; - } - break; - - case NdbDictionary::Column::Bigint: - case NdbDictionary::Column::Bigunsigned: - { - g_info << a->int64_value() << " "; - } - break; - - case NdbDictionary::Column::Float: - { - g_info << a->float_value() << " "; - } - break; - - case NdbDictionary::Column::Undefined: - default: - { - g_info << "Undefined!!! "; - } - break; - - } // case - g_info << " "; + ndbout << (* a) << " "; } // for g_info << endl; } // if (conn diff --git a/storage/ndb/test/tools/hugoScanUpdate.cpp b/storage/ndb/test/tools/hugoScanUpdate.cpp index 6960fa44b96..07807b254ee 100644 --- a/storage/ndb/test/tools/hugoScanUpdate.cpp +++ b/storage/ndb/test/tools/hugoScanUpdate.cpp @@ -35,6 +35,7 @@ int main(int argc, const char** argv){ int _ver2 = 0; const char* _tabname = NULL, *db = 0; int _help = 0; + int abort= 0; struct getargs args[] = { { "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" }, @@ -42,6 +43,7 @@ int main(int argc, const char** argv){ { "records", 'r', arg_integer, &_records, "Number of records", "recs" }, { "ver2", '2', arg_flag, &_ver2, "Use version 2 of scanUpdateRecords", "" }, { "ver2", '1', arg_negative_flag, &_ver2, "Use version 1 of scanUpdateRecords (default)", "" }, + { "abort", 'a', arg_integer, &abort, "Abort probability", "" }, { "usage", '?', arg_flag, &_help, "Print help", "" }, { "database", 'd', arg_string, &db, "Database", "" } }; @@ -88,14 +90,14 @@ int main(int argc, const char** argv){ ndbout << i << ": "; if (_ver2 == 0){ res = hugoTrans.scanUpdateRecords(&MyNdb, - _records, - 0, - _parallelism); + _records, + abort % 101, + _parallelism); } else{ res = hugoTrans.scanUpdateRecords2(&MyNdb, - _records, - 0, - _parallelism); + _records, + abort % 101, + _parallelism); } if (res != NDBT_OK ){ return NDBT_ProgramExit(NDBT_FAILED); @@ -103,6 +105,6 @@ int main(int argc, const char** argv){ i++; //NdbSleep_MilliSleep(300); } - + return NDBT_ProgramExit(NDBT_OK); } |