diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2005-09-15 12:53:59 +0200 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2005-09-15 12:53:59 +0200 |
commit | 519ebe2bdbd4fbde6106439ed5ca64e348e197f2 (patch) | |
tree | 102ad288ae95c6c22f57720344a287fa1acab215 /storage/ndb/test | |
parent | 2ff26b97f20c6a44dd9ee8465372340756dd6772 (diff) | |
download | mariadb-git-519ebe2bdbd4fbde6106439ed5ca64e348e197f2.tar.gz |
merge error
Diffstat (limited to 'storage/ndb/test')
-rw-r--r-- | storage/ndb/test/run-test/conf-daily-basic-ndb08.txt | 19 | ||||
-rw-r--r-- | storage/ndb/test/run-test/conf-daily-devel-ndb08.txt | 19 | ||||
-rw-r--r-- | storage/ndb/test/run-test/conf-daily-sql-ndb08.txt | 20 | ||||
-rw-r--r-- | storage/ndb/test/sql/BANK.sql | 44 | ||||
-rw-r--r-- | storage/ndb/test/sql/T1.sql | 9 | ||||
-rw-r--r-- | storage/ndb/test/tools/listen.cpp | 169 |
6 files changed, 280 insertions, 0 deletions
diff --git a/storage/ndb/test/run-test/conf-daily-basic-ndb08.txt b/storage/ndb/test/run-test/conf-daily-basic-ndb08.txt new file mode 100644 index 00000000000..bcd809593f3 --- /dev/null +++ b/storage/ndb/test/run-test/conf-daily-basic-ndb08.txt @@ -0,0 +1,19 @@ +baseport: 14000 +basedir: /space/autotest +mgm: CHOOSE_host1 +ndb: CHOOSE_host2 CHOOSE_host3 CHOOSE_host2 CHOOSE_host3 +api: CHOOSE_host1 CHOOSE_host1 CHOOSE_host1 +-- cluster config +[DB DEFAULT] +NoOfReplicas: 2 +IndexMemory: 100M +DataMemory: 300M +BackupMemory: 64M +MaxNoOfConcurrentScans: 100 +DataDir: . +FileSystemPath: /space/autotest/run + +[MGM DEFAULT] +PortNumber: 14000 +ArbitrationRank: 1 +DataDir: . diff --git a/storage/ndb/test/run-test/conf-daily-devel-ndb08.txt b/storage/ndb/test/run-test/conf-daily-devel-ndb08.txt new file mode 100644 index 00000000000..8b340e6a39d --- /dev/null +++ b/storage/ndb/test/run-test/conf-daily-devel-ndb08.txt @@ -0,0 +1,19 @@ +baseport: 16000 +basedir: /space/autotest +mgm: CHOOSE_host1 +ndb: CHOOSE_host2 CHOOSE_host3 CHOOSE_host2 CHOOSE_host3 +api: CHOOSE_host1 CHOOSE_host1 CHOOSE_host1 +-- cluster config +[DB DEFAULT] +NoOfReplicas: 2 +IndexMemory: 100M +DataMemory: 300M +BackupMemory: 64M +MaxNoOfConcurrentScans: 100 +DataDir: . +FileSystemPath: /space/autotest/run + +[MGM DEFAULT] +PortNumber: 16000 +ArbitrationRank: 1 +DataDir: . diff --git a/storage/ndb/test/run-test/conf-daily-sql-ndb08.txt b/storage/ndb/test/run-test/conf-daily-sql-ndb08.txt new file mode 100644 index 00000000000..0d6a99f8d48 --- /dev/null +++ b/storage/ndb/test/run-test/conf-daily-sql-ndb08.txt @@ -0,0 +1,20 @@ +baseport: 16000 +basedir: /space/autotest +mgm: CHOOSE_host1 +ndb: CHOOSE_host2 CHOOSE_host3 +mysqld: CHOOSE_host1 CHOOSE_host4 +mysql: CHOOSE_host1 CHOOSE_host1 CHOOSE_host1 CHOOSE_host1 CHOOSE_host1 CHOOSE_host1 CHOOSE_host4 CHOOSE_host4 CHOOSE_host4 CHOOSE_host4 CHOOSE_host4 CHOOSE_host4 +-- cluster config +[DB DEFAULT] +NoOfReplicas: 2 +IndexMemory: 100M +DataMemory: 300M +BackupMemory: 64M +MaxNoOfConcurrentScans: 100 +DataDir: . +FileSystemPath: /space/autotest/run + +[MGM DEFAULT] +PortNumber: 16000 +ArbitrationRank: 1 +DataDir: . diff --git a/storage/ndb/test/sql/BANK.sql b/storage/ndb/test/sql/BANK.sql new file mode 100644 index 00000000000..055761621e3 --- /dev/null +++ b/storage/ndb/test/sql/BANK.sql @@ -0,0 +1,44 @@ +CREATE DATABASE IF NOT EXISTS BANK default charset=latin1 default collate=latin1_bin; +USE BANK; +DROP TABLE IF EXISTS GL; +CREATE TABLE GL ( TIME BIGINT UNSIGNED NOT NULL, + ACCOUNT_TYPE INT UNSIGNED NOT NULL, + BALANCE INT UNSIGNED NOT NULL, + DEPOSIT_COUNT INT UNSIGNED NOT NULL, + DEPOSIT_SUM INT UNSIGNED NOT NULL, + WITHDRAWAL_COUNT INT UNSIGNED NOT NULL, + WITHDRAWAL_SUM INT UNSIGNED NOT NULL, + PURGED INT UNSIGNED NOT NULL, + PRIMARY KEY USING HASH (TIME,ACCOUNT_TYPE)) + ENGINE = NDB; + +DROP TABLE IF EXISTS ACCOUNT; +CREATE TABLE ACCOUNT ( ACCOUNT_ID INT UNSIGNED NOT NULL, + OWNER INT UNSIGNED NOT NULL, + BALANCE INT UNSIGNED NOT NULL, + ACCOUNT_TYPE INT UNSIGNED NOT NULL, + PRIMARY KEY USING HASH (ACCOUNT_ID)) + ENGINE = NDB; + +DROP TABLE IF EXISTS TRANSACTION; +CREATE TABLE TRANSACTION ( TRANSACTION_ID BIGINT UNSIGNED NOT NULL, + ACCOUNT INT UNSIGNED NOT NULL, + ACCOUNT_TYPE INT UNSIGNED NOT NULL, + OTHER_ACCOUNT INT UNSIGNED NOT NULL, + TRANSACTION_TYPE INT UNSIGNED NOT NULL, + TIME BIGINT UNSIGNED NOT NULL, + AMOUNT INT UNSIGNED NOT NULL, + PRIMARY KEY USING HASH (TRANSACTION_ID,ACCOUNT)) + ENGINE = NDB; + +DROP TABLE IF EXISTS SYSTEM_VALUES; +CREATE TABLE SYSTEM_VALUES ( SYSTEM_VALUES_ID INT UNSIGNED NOT NULL, + VALUE BIGINT UNSIGNED NOT NULL, + PRIMARY KEY USING HASH (SYSTEM_VALUES_ID)) + ENGINE = NDB; + +DROP TABLE IF EXISTS ACCOUNT_TYPE; +CREATE TABLE ACCOUNT_TYPE ( ACCOUNT_TYPE_ID INT UNSIGNED NOT NULL, + DESCRIPTION CHAR(64) NOT NULL, + PRIMARY KEY USING HASH (ACCOUNT_TYPE_ID)) + ENGINE = NDB; diff --git a/storage/ndb/test/sql/T1.sql b/storage/ndb/test/sql/T1.sql new file mode 100644 index 00000000000..754211c4eac --- /dev/null +++ b/storage/ndb/test/sql/T1.sql @@ -0,0 +1,9 @@ +create database if not exists TEST_DB; +use TEST_DB; +drop table if exists T1; +create table T1 (KOL1 int unsigned not null, + KOL2 int unsigned not null, + KOL3 int unsigned not null, + KOL4 int unsigned not null, + KOL5 int unsigned not null, + primary key using hash(KOL1)) engine=ndb; diff --git a/storage/ndb/test/tools/listen.cpp b/storage/ndb/test/tools/listen.cpp new file mode 100644 index 00000000000..05edb012fdb --- /dev/null +++ b/storage/ndb/test/tools/listen.cpp @@ -0,0 +1,169 @@ +/* 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 <NdbOut.hpp> +#include <NdbApi.hpp> +#include <NdbSleep.h> +#include <NDBT.hpp> +#include <HugoTransactions.hpp> +#include <getarg.h> + + +int +main(int argc, const char** argv){ + ndb_init(); + + + int _help = 0; + const char* db = 0; + + struct getargs args[] = { + { "database", 'd', arg_string, &db, "Database", "" }, + { "usage", '?', arg_flag, &_help, "Print help", "" } + }; + int num_args = sizeof(args) / sizeof(args[0]); + int optind = 0, i; + char desc[] = + "<tabname>+ \nThis program listen to events on specified tables\n"; + + if(getarg(args, num_args, argc, argv, &optind) || + argv[optind] == NULL || _help) { + arg_printusage(args, num_args, argv[0], desc); + return NDBT_ProgramExit(NDBT_WRONGARGS); + } + + // Connect to Ndb + Ndb_cluster_connection con; + if(con.connect(12, 5, 1) != 0) + { + return NDBT_ProgramExit(NDBT_FAILED); + } + Ndb MyNdb( &con, db ? db : "TEST_DB" ); + + if(MyNdb.init() != 0){ + ERR(MyNdb.getNdbError()); + return NDBT_ProgramExit(NDBT_FAILED); + } + + // Connect to Ndb and wait for it to become ready + while(MyNdb.waitUntilReady() != 0) + ndbout << "Waiting for ndb to become ready..." << endl; + + int result = 0; + Uint64 last_gci= 0, cnt= 0; + + NdbDictionary::Dictionary *myDict = MyNdb.getDictionary(); + Vector<NdbDictionary::Event*> events; + Vector<NdbEventOperation*> event_ops; + for(i= optind; i<argc; i++) + { + const NdbDictionary::Table* table= myDict->getTable(argv[i]); + if(!table) + { + ndbout_c("Could not find table: %s, skipping", argv[i]); + continue; + } + + BaseString name; + name.appfmt("EV-%s", argv[i]); + NdbDictionary::Event *myEvent= new NdbDictionary::Event(name.c_str()); + myEvent->setTable(table->getName()); + myEvent->addTableEvent(NdbDictionary::Event::TE_ALL); + for(int a = 0; a < table->getNoOfColumns(); a++){ + myEvent->addEventColumn(a); + } + + if (myDict->createEvent(* myEvent)) + { + if(myDict->getNdbError().classification == NdbError::SchemaObjectExists) + { + g_info << "Event creation failed event exists\n"; + if (myDict->dropEvent(name.c_str())) + { + g_err << "Failed to drop event: " << myDict->getNdbError() << endl; + result = 1; + goto end; + } + // try again + if (myDict->createEvent(* myEvent)) + { + g_err << "Failed to create event: " << myDict->getNdbError() << endl; + result = 1; + goto end; + } + } + else + { + g_err << "Failed to create event: " << myDict->getNdbError() << endl; + result = 1; + goto end; + } + } + + events.push_back(myEvent); + + NdbEventOperation* pOp = MyNdb.createEventOperation(name.c_str()); + if ( pOp == NULL ) { + g_err << "Event operation creation failed" << endl; + result = 1; + goto end; + } + + for (int a = 0; a < table->getNoOfColumns(); a++) + { + pOp->getValue(table->getColumn(a)->getName()); + pOp->getPreValue(table->getColumn(a)->getName()); + } + event_ops.push_back(pOp); + } + + for(i= 0; i<(int)event_ops.size(); i++) + { + if (event_ops[i]->execute()) + { + g_err << "operation execution failed: " << event_ops[i]->getNdbError() + << endl; + result = 1; + goto end; + } + } + + while(true) + { + while(MyNdb.pollEvents(100) == 0); + + NdbEventOperation* pOp; + while((pOp= MyNdb.nextEvent()) != 0) + { + if(pOp->getGCI() != last_gci) + { + if(cnt) ndbout_c("GCI: %lld events: %lld", last_gci, cnt); + cnt= 1; + last_gci= pOp->getGCI(); + } + else + { + cnt++; + } + } + } +end: + return NDBT_ProgramExit(NDBT_OK); +} + +template class Vector<NdbDictionary::Event*>; +template class Vector<NdbEventOperation*>; |