Commit c2505873 authored by unknown's avatar unknown

NdbRepStress.cpp:

  Updated with new support function from Magnus push to dbutil


storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp:
  Updated with new support function from Magnus push to dbutil
parent b6d3eac0
...@@ -58,8 +58,7 @@ syncSlaveWithMaster() ...@@ -58,8 +58,7 @@ syncSlaveWithMaster()
know when the slave has caught up know when the slave has caught up
*/ */
MYSQL_RES * result; SqlResultSet result;
MYSQL_ROW row;
unsigned int masterEpoch = 0; unsigned int masterEpoch = 0;
unsigned int slaveEpoch = 0; unsigned int slaveEpoch = 0;
unsigned int slaveEpochOld = 0; unsigned int slaveEpochOld = 0;
...@@ -76,14 +75,11 @@ syncSlaveWithMaster() ...@@ -76,14 +75,11 @@ syncSlaveWithMaster()
} }
//Get max epoch from master //Get max epoch from master
if(master.doQuery("SELECT MAX(epoch) FROM mysql.ndb_binlog_index")) if(master.doQuery("SELECT MAX(epoch) FROM mysql.ndb_binlog_index", result))
{ {
return NDBT_FAILED; return NDBT_FAILED;
} }
result = mysql_use_result(master.getMysql()); masterEpoch = result.columnAsInt("epoch");
row = mysql_fetch_row(result);
masterEpoch = atoi(row[0]);
mysql_free_result(result);
/* /*
Now we will pull current epoch from slave. If not the Now we will pull current epoch from slave. If not the
...@@ -103,14 +99,11 @@ syncSlaveWithMaster() ...@@ -103,14 +99,11 @@ syncSlaveWithMaster()
while(slaveEpoch != masterEpoch && loopCnt < maxLoops) while(slaveEpoch != masterEpoch && loopCnt < maxLoops)
{ {
if(slave.doQuery("SELECT epoch FROM mysql.ndb_apply_status")) if(slave.doQuery("SELECT epoch FROM mysql.ndb_apply_status",result))
{ {
return NDBT_FAILED; return NDBT_FAILED;
} }
result = mysql_use_result(slave.getMysql()); slaveEpoch = result.columnAsInt("epoch");
row = mysql_fetch_row(result);
slaveEpoch = atoi(row[0]);
mysql_free_result(result);
if(slaveEpoch != slaveEpochOld) if(slaveEpoch != slaveEpochOld)
{ {
...@@ -135,17 +128,15 @@ syncSlaveWithMaster() ...@@ -135,17 +128,15 @@ syncSlaveWithMaster()
} }
int int
verifySlaveLoad(BaseString *table) verifySlaveLoad(BaseString &table)
{ {
BaseString sqlStm; //BaseString sqlStm;
BaseString db; BaseString db;
MYSQL_RES * result;
MYSQL_ROW row;
unsigned int masterCount = 0; unsigned int masterCount = 0;
unsigned int slaveCount = 0; unsigned int slaveCount = 0;
db.assign("TEST_DB"); db.assign("TEST_DB");
sqlStm.assfmt("SELECT COUNT(*) FROM %s", table); //sqlStm.assfmt("SELECT COUNT(*) FROM %s", table);
//First thing to do is sync slave //First thing to do is sync slave
if(syncSlaveWithMaster()) if(syncSlaveWithMaster())
...@@ -163,14 +154,10 @@ verifySlaveLoad(BaseString *table) ...@@ -163,14 +154,10 @@ verifySlaveLoad(BaseString *table)
return NDBT_FAILED; return NDBT_FAILED;
} }
if(master.doQuery(sqlStm.c_str())) if((masterCount = master.selectCountTable(table.c_str())) == 0 )
{ {
return NDBT_FAILED; return NDBT_FAILED;
} }
result = mysql_use_result(master.getMysql());
row = mysql_fetch_row(result);
masterCount = atoi(row[0]);
mysql_free_result(result);
//Create a DB Object for slave //Create a DB Object for slave
DbUtil slave(db.c_str(),".slave"); DbUtil slave(db.c_str(),".slave");
...@@ -181,14 +168,10 @@ verifySlaveLoad(BaseString *table) ...@@ -181,14 +168,10 @@ verifySlaveLoad(BaseString *table)
return NDBT_FAILED; return NDBT_FAILED;
} }
if(slave.doQuery(sqlStm.c_str())) if((slaveCount = slave.selectCountTable(table.c_str())) == 0 )
{ {
return NDBT_FAILED; return NDBT_FAILED;
} }
result = mysql_use_result(slave.getMysql());
row = mysql_fetch_row(result);
slaveCount = atoi(row[0]);
mysql_free_result(result);
if(slaveCount != masterCount) if(slaveCount != masterCount)
{ {
...@@ -245,10 +228,9 @@ dropTEST_DB(NDBT_Context* ctx, NDBT_Step* step) ...@@ -245,10 +228,9 @@ dropTEST_DB(NDBT_Context* ctx, NDBT_Step* step)
} }
int int
verifySlave(BaseString& sqlStm, BaseString& db) verifySlave(BaseString& sqlStm, BaseString& db, BaseString& column)
{ {
MYSQL_RES* resource; SqlResultSet result;
MYSQL_ROW row;
float masterSum; float masterSum;
float slaveSum; float slaveSum;
...@@ -269,14 +251,11 @@ verifySlave(BaseString& sqlStm, BaseString& db) ...@@ -269,14 +251,11 @@ verifySlave(BaseString& sqlStm, BaseString& db)
return NDBT_FAILED; return NDBT_FAILED;
} }
if(master.doQuery(sqlStm.c_str()) != NDBT_OK) if(master.doQuery(sqlStm.c_str(),result) != NDBT_OK)
{ {
return NDBT_FAILED; return NDBT_FAILED;
} }
resource = mysql_use_result(master.getMysql()); masterSum = result.columnAsInt(column.c_str());
row = mysql_fetch_row(resource);
masterSum = atoi(row[0]);
mysql_free_result(resource);
//Login to slave //Login to slave
if (!slave.connect()) if (!slave.connect())
...@@ -284,14 +263,11 @@ verifySlave(BaseString& sqlStm, BaseString& db) ...@@ -284,14 +263,11 @@ verifySlave(BaseString& sqlStm, BaseString& db)
return NDBT_FAILED; return NDBT_FAILED;
} }
if(slave.doQuery(sqlStm.c_str()) != NDBT_OK) if(slave.doQuery(sqlStm.c_str(),result) != NDBT_OK)
{ {
return NDBT_FAILED; return NDBT_FAILED;
} }
resource = mysql_use_result(slave.getMysql()); slaveSum = result.columnAsInt(column.c_str());
row = mysql_fetch_row(resource);
slaveSum = atoi(row[0]);
mysql_free_result(resource);
if(masterSum != slaveSum) if(masterSum != slaveSum)
{ {
...@@ -364,7 +340,7 @@ createTable_rep1(NDBT_Context* ctx, NDBT_Step* step) ...@@ -364,7 +340,7 @@ createTable_rep1(NDBT_Context* ctx, NDBT_Step* step)
return NDBT_FAILED; return NDBT_FAILED;
} }
if(verifySlaveLoad(&table)!= NDBT_OK) if(verifySlaveLoad(table)!= NDBT_OK)
{ {
g_err << "Create Table -> Failed on verify slave load!" g_err << "Create Table -> Failed on verify slave load!"
<< endl; << endl;
...@@ -429,11 +405,13 @@ verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step) ...@@ -429,11 +405,13 @@ verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step)
{ {
BaseString sql; BaseString sql;
BaseString db; BaseString db;
BaseString column;
sql.assign("SELECT SUM(c3) FROM rep1"); sql.assign("SELECT SUM(c3) FROM rep1");
db.assign("TEST_DB"); db.assign("TEST_DB");
column.assign("c3");
if (verifySlave(sql,db) != NDBT_OK) if (verifySlave(sql,db,column) != NDBT_OK)
return NDBT_FAILED; return NDBT_FAILED;
return NDBT_OK; return NDBT_OK;
} }
...@@ -452,7 +430,7 @@ verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step) ...@@ -452,7 +430,7 @@ verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step)
dropTEST_DB() dropTEST_DB()
{Drops TEST_DB database on master} {Drops TEST_DB database on master}
verifySlave(BaseString& sql, BaseSting& db) verifySlave(BaseString& sql, BaseSting& db, BaseSting& column)
{The SQL statement must sum a column and will verify {The SQL statement must sum a column and will verify
that the sum of the column is equal on master & slave} that the sum of the column is equal on master & slave}
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment