#At file:///home/jonas/src/telco-6.3/ based on revid:jonas@stripped
3083 Jonas Oreland 2009-10-01
ndb - bug#47740 - testcase only (cause bug should be fixed in 7.0)
modified:
storage/ndb/test/ndbapi/testUpgrade.cpp
=== modified file 'storage/ndb/test/ndbapi/testUpgrade.cpp'
--- a/storage/ndb/test/ndbapi/testUpgrade.cpp 2009-08-05 09:54:52 +0000
+++ b/storage/ndb/test/ndbapi/testUpgrade.cpp 2009-10-01 09:35:01 +0000
@@ -33,6 +33,127 @@ struct NodeInfo
int nodeGroup;
};
+static
+int
+createEvent(Ndb *pNdb,
+ const NdbDictionary::Table &tab,
+ bool merge_events = true,
+ bool report = true)
+{
+ char eventName[1024];
+ sprintf(eventName,"%s_EVENT",tab.getName());
+
+ NdbDictionary::Dictionary *myDict = pNdb->getDictionary();
+
+ if (!myDict) {
+ g_err << "Dictionary not found "
+ << pNdb->getNdbError().code << " "
+ << pNdb->getNdbError().message << endl;
+ return NDBT_FAILED;
+ }
+
+ myDict->dropEvent(eventName);
+
+ NdbDictionary::Event myEvent(eventName);
+ myEvent.setTable(tab.getName());
+ myEvent.addTableEvent(NdbDictionary::Event::TE_ALL);
+ for(int a = 0; a < tab.getNoOfColumns(); a++){
+ myEvent.addEventColumn(a);
+ }
+ myEvent.mergeEvents(merge_events);
+
+ if (report)
+ myEvent.setReport(NdbDictionary::Event::ER_SUBSCRIBE);
+
+ int res = myDict->createEvent(myEvent); // Add event to database
+
+ if (res == 0)
+ myEvent.print();
+ else if (myDict->getNdbError().classification ==
+ NdbError::SchemaObjectExists)
+ {
+ g_info << "Event creation failed event exists\n";
+ res = myDict->dropEvent(eventName);
+ if (res) {
+ g_err << "Failed to drop event: "
+ << myDict->getNdbError().code << " : "
+ << myDict->getNdbError().message << endl;
+ return NDBT_FAILED;
+ }
+ // try again
+ res = myDict->createEvent(myEvent); // Add event to database
+ if (res) {
+ g_err << "Failed to create event (1): "
+ << myDict->getNdbError().code << " : "
+ << myDict->getNdbError().message << endl;
+ return NDBT_FAILED;
+ }
+ }
+ else
+ {
+ g_err << "Failed to create event (2): "
+ << myDict->getNdbError().code << " : "
+ << myDict->getNdbError().message << endl;
+ return NDBT_FAILED;
+ }
+
+ return NDBT_OK;
+}
+
+static
+int
+dropEvent(Ndb *pNdb, const NdbDictionary::Table &tab)
+{
+ char eventName[1024];
+ sprintf(eventName,"%s_EVENT",tab.getName());
+ NdbDictionary::Dictionary *myDict = pNdb->getDictionary();
+ if (!myDict) {
+ g_err << "Dictionary not found "
+ << pNdb->getNdbError().code << " "
+ << pNdb->getNdbError().message << endl;
+ return NDBT_FAILED;
+ }
+ if (myDict->dropEvent(eventName)) {
+ g_err << "Failed to drop event: "
+ << myDict->getNdbError().code << " : "
+ << myDict->getNdbError().message << endl;
+ return NDBT_FAILED;
+ }
+ return NDBT_OK;
+}
+
+
+static
+int
+createDropEvent(NDBT_Context* ctx, NDBT_Step* step)
+{
+ Ndb* pNdb = GETNDB(step);
+ NdbDictionary::Dictionary *myDict = pNdb->getDictionary();
+
+ for (unsigned i = 0; i<table_list.size(); i++)
+ {
+ int res = NDBT_OK;
+ const NdbDictionary::Table* tab = myDict->getTable(table_list[i].c_str());
+ if (tab == 0)
+ {
+ continue;
+ }
+ if ((res = createEvent(pNdb, *tab) != NDBT_OK))
+ {
+ return res;
+ }
+
+
+
+ if ((res = dropEvent(pNdb, *tab)) != NDBT_OK)
+ {
+ return res;
+ }
+ }
+
+ return NDBT_OK;
+}
+
/**
Test that one node at a time can be upgraded
*/
@@ -103,6 +224,8 @@ int runUpgrade_NR1(NDBT_Context* ctx, ND
if (restarter.waitNodesStarted(&nodeId, 1))
return NDBT_FAILED;
+ if (createDropEvent(ctx, step))
+ return NDBT_FAILED;
}
}
@@ -119,6 +242,7 @@ runUpgrade_Half(NDBT_Context* ctx, NDBT_
AtrtClient atrt;
const bool waitNode = ctx->getProperty("WaitNode", Uint32(0)) != 0;
+ const bool event = ctx->getProperty("CreateDropEvent", Uint32(0)) != 0;
const char * args = "";
if (ctx->getProperty("KeepFS", Uint32(0)) != 0)
{
@@ -221,6 +345,11 @@ runUpgrade_Half(NDBT_Context* ctx, NDBT_
if (restarter.waitClusterStarted())
return NDBT_FAILED;
+ if (event && createDropEvent(ctx, step))
+ {
+ return NDBT_FAILED;
+ }
+
// Restart the remaining nodes
cnt= 0;
for (Uint32 i = 0; i<nodes.size(); i++)
@@ -256,6 +385,11 @@ runUpgrade_Half(NDBT_Context* ctx, NDBT_
if (restarter.waitClusterStarted())
return NDBT_FAILED;
+
+ if (event && createDropEvent(ctx, step))
+ {
+ return NDBT_FAILED;
+ }
}
return NDBT_OK;
@@ -273,6 +407,7 @@ int runUpgrade_NR2(NDBT_Context* ctx, ND
// Assuming 2 replicas
ctx->setProperty("WaitNode", 1);
+ ctx->setProperty("CreateDropEvent", 1);
int res = runUpgrade_Half(ctx, step);
ctx->stopTest();
return res;
@@ -287,6 +422,7 @@ int runUpgrade_NR2(NDBT_Context* ctx, ND
int runUpgrade_NR3(NDBT_Context* ctx, NDBT_Step* step){
// Assuming 2 replicas
+ ctx->setProperty("CreateDropEvent", 1);
int res = runUpgrade_Half(ctx, step);
ctx->stopTest();
return res;
@@ -384,7 +520,7 @@ runBasic(NDBT_Context* ctx, NDBT_Step* s
{
const NdbDictionary::Table* tab = pDict->getTable(table_list[i].c_str());
HugoTransactions trans(* tab);
- switch(l % 3){
+ switch(l % 4){
case 0:
trans.loadTable(pNdb, records);
trans.scanUpdateRecords(pNdb, records);
@@ -404,6 +540,12 @@ runBasic(NDBT_Context* ctx, NDBT_Step* s
trans.loadTable(pNdb, records/2);
trans.clearTable(pNdb, records/2);
break;
+ case 3:
+ if (createDropEvent(ctx, step))
+ {
+ return NDBT_FAILED;
+ }
+ break;
}
}
}
Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20091001093501-6xq5vewcwdzteulp.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.3 branch (jonas:3083) Bug#47740 | Jonas Oreland | 1 Oct |