List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:August 5 2009 9:54am
Subject:bzr commit into mysql-5.1-telco-6.3 branch (jonas:3005) Bug#46494
View as plain text  
#At file:///home/jonas/src/telco-6.3/ based on revid:jonas@stripped

 3005 Jonas Oreland	2009-08-05
      ndb - bug#46494 - test
        Add ability to do post upgrade verification
        This is done by restarting test-program binary in new version
        with the testcase being altered "X" becomes "X--post-upgrade"
     @ storage/ndb/test/run-test/command.cpp
        only append new value, don't clear entire env
     @ storage/ndb/test/run-test/db.cpp
        use "correct" variable
     @ storage/ndb/test/run-test/setup.cpp
        put atrt process id in environment

    modified:
      storage/ndb/test/include/AtrtClient.hpp
      storage/ndb/test/include/NDBT_Test.hpp
      storage/ndb/test/ndbapi/testUpgrade.cpp
      storage/ndb/test/run-test/command.cpp
      storage/ndb/test/run-test/db.cpp
      storage/ndb/test/run-test/setup.cpp
      storage/ndb/test/src/AtrtClient.cpp
=== modified file 'storage/ndb/test/include/AtrtClient.hpp'
--- a/storage/ndb/test/include/AtrtClient.hpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/test/include/AtrtClient.hpp	2009-08-05 09:54:52 +0000
@@ -43,6 +43,7 @@ public:
   bool getClusters(SqlResultSet& result);
   bool getMgmds(int cluster_id, SqlResultSet& result);
   bool getNdbds(int cluster_id, SqlResultSet& result);
+  int getOwnProcessId();
 
 private:
   int writeCommand(AtrtCommandType _type,

=== modified file 'storage/ndb/test/include/NDBT_Test.hpp'
--- a/storage/ndb/test/include/NDBT_Test.hpp	2009-07-03 14:15:09 +0000
+++ b/storage/ndb/test/include/NDBT_Test.hpp	2009-08-05 09:54:52 +0000
@@ -470,4 +470,8 @@ C##suitname():NDBT_TestSuite(#suitname){
 // Helper functions for retrieving variables from NDBT_Step
 #define GETNDB(ps) ((NDBT_NdbApiStep*)ps)->getNdb()
 
+#define POSTUPGRADE(testname) \
+  TESTCASE(testname "--post-upgrade", \
+           "checks being run after upgrade has completed")
+
 #endif

=== modified file 'storage/ndb/test/ndbapi/testUpgrade.cpp'
--- a/storage/ndb/test/ndbapi/testUpgrade.cpp	2009-07-02 13:57:30 +0000
+++ b/storage/ndb/test/ndbapi/testUpgrade.cpp	2009-08-05 09:54:52 +0000
@@ -452,21 +452,86 @@ int runUpgrade_Traffic(NDBT_Context* ctx
   return res;
 }
 
+int
+startPostUpgradeChecks(NDBT_Context* ctx, NDBT_Step* step)
+{
+  /**
+   * This will restart *self* in new version
+   */
+
+  /**
+   * mysql-getopt works so that passing "-n X -n Y" is ok
+   *   and is interpreted as "-n Y"
+   *
+   * so we restart ourselves with testcase-name and "--post-upgrade" appended
+   * e.g if testcase is "testUpgrade -n X"
+   *     this will restart it as "testUpgrade -n X -n X--post-upgrade"
+   */
+  BaseString tc;
+  tc.assfmt("-n %s--post-upgrade", ctx->getCase()->getName());
+
+  ndbout << "About to restart self with extra arg: " << tc.c_str() << endl;
+
+  AtrtClient atrt;
+  int process_id = atrt.getOwnProcessId();
+  if (process_id == -1)
+  {
+    g_err << "Failed to find own process id" << endl;
+    return NDBT_FAILED;
+  }
+
+  if (!atrt.changeVersion(process_id, tc.c_str()))
+    return NDBT_FAILED;
+
+  // Will not be reached...
+
+  return NDBT_OK;
+}
+
+int
+runPostUpgradeChecks(NDBT_Context* ctx, NDBT_Step* step)
+{
+  /**
+   * Table will be dropped/recreated
+   *   automatically by NDBT...
+   *   so when we enter here, this is already tested
+   */
+  return NDBT_OK;
+}
+
 NDBT_TESTSUITE(testUpgrade);
 TESTCASE("Upgrade_NR1",
 	 "Test that one node at a time can be upgraded"){
   INITIALIZER(runCheckStarted);
   STEP(runUpgrade_NR1);
+  VERIFIER(startPostUpgradeChecks);
+}
+POSTUPGRADE("Upgrade_NR1")
+{
+  INITIALIZER(runCheckStarted);
+  INITIALIZER(runPostUpgradeChecks);
 }
 TESTCASE("Upgrade_NR2",
 	 "Test that one node in each nodegroup can be upgradde simultaneously"){
   INITIALIZER(runCheckStarted);
   STEP(runUpgrade_NR2);
+  VERIFIER(startPostUpgradeChecks);
+}
+POSTUPGRADE("Upgrade_NR2")
+{
+  INITIALIZER(runCheckStarted);
+  INITIALIZER(runPostUpgradeChecks);
 }
 TESTCASE("Upgrade_NR3",
 	 "Test that one node in each nodegroup can be upgradde simultaneously"){
   INITIALIZER(runCheckStarted);
   STEP(runUpgrade_NR3);
+  VERIFIER(startPostUpgradeChecks);
+}
+POSTUPGRADE("Upgrade_NR3")
+{
+  INITIALIZER(runCheckStarted);
+  INITIALIZER(runPostUpgradeChecks);
 }
 TESTCASE("Upgrade_FS",
 	 "Test that one node in each nodegroup can be upgrade simultaneously")
@@ -476,6 +541,12 @@ TESTCASE("Upgrade_FS",
   INITIALIZER(runCreateAllTables);
   INITIALIZER(runLoadAll);
   STEP(runUpgrade_Traffic);
+  VERIFIER(startPostUpgradeChecks);
+}
+POSTUPGRADE("Upgrade_FS")
+{
+  INITIALIZER(runCheckStarted);
+  INITIALIZER(runPostUpgradeChecks);
 }
 TESTCASE("Upgrade_Traffic",
 	 "Test upgrade with traffic, all tables and restart --initial")
@@ -484,6 +555,12 @@ TESTCASE("Upgrade_Traffic",
   INITIALIZER(runCreateAllTables);
   STEP(runUpgrade_Traffic);
   STEP(runBasic);
+  VERIFIER(startPostUpgradeChecks);
+}
+POSTUPGRADE("Upgrade_Traffic")
+{
+  INITIALIZER(runCheckStarted);
+  INITIALIZER(runPostUpgradeChecks);
 }
 TESTCASE("Upgrade_Traffic_FS",
 	 "Test upgrade with traffic, all tables and restart using FS")
@@ -493,6 +570,12 @@ TESTCASE("Upgrade_Traffic_FS",
   INITIALIZER(runCreateAllTables);
   STEP(runUpgrade_Traffic);
   STEP(runBasic);
+  VERIFIER(startPostUpgradeChecks);
+}
+POSTUPGRADE("Upgrade_Traffic_FS")
+{
+  INITIALIZER(runCheckStarted);
+  INITIALIZER(runPostUpgradeChecks);
 }
 TESTCASE("Upgrade_Traffic_one",
 	 "Test upgrade with traffic, *one* table and restart --initial")
@@ -501,6 +584,12 @@ TESTCASE("Upgrade_Traffic_one",
   INITIALIZER(runCreateOneTable);
   STEP(runUpgrade_Traffic);
   STEP(runBasic);
+  VERIFIER(startPostUpgradeChecks);
+}
+POSTUPGRADE("Upgrade_Traffic_one")
+{
+  INITIALIZER(runCheckStarted);
+  INITIALIZER(runPostUpgradeChecks);
 }
 TESTCASE("Upgrade_Traffic_FS_one",
 	 "Test upgrade with traffic, all tables and restart using FS")
@@ -510,6 +599,12 @@ TESTCASE("Upgrade_Traffic_FS_one",
   INITIALIZER(runCreateOneTable);
   STEP(runUpgrade_Traffic);
   STEP(runBasic);
+  VERIFIER(startPostUpgradeChecks);
+}
+POSTUPGRADE("Upgrade_Traffic_FS_one")
+{
+  INITIALIZER(runCheckStarted);
+  INITIALIZER(runPostUpgradeChecks);
 }
 NDBT_TESTSUITE_END(testUpgrade);
 

=== modified file 'storage/ndb/test/run-test/command.cpp'
--- a/storage/ndb/test/run-test/command.cpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/test/run-test/command.cpp	2009-08-05 09:54:52 +0000
@@ -98,7 +98,7 @@ do_change_version(atrt_config& config, S
 
   const char* new_prefix= g_prefix1 ? g_prefix1 : g_prefix;
   const char* old_prefix= g_prefix;
-  proc.m_proc.m_env.assfmt("MYSQL_BASE_DIR=%s", new_prefix);
+  proc.m_proc.m_env.appfmt(" MYSQL_BASE_DIR=%s", new_prefix);
   const char *start= strstr(proc.m_proc.m_path.c_str(), old_prefix);
   if (!start){
     g_logger.critical("Could not find '%s' in '%s'",

=== modified file 'storage/ndb/test/run-test/db.cpp'
--- a/storage/ndb/test/run-test/db.cpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/test/run-test/db.cpp	2009-08-05 09:54:52 +0000
@@ -402,11 +402,11 @@ populate_db(atrt_config& config, atrt_pr
 	return false;
       }
 
-      if (populate_options(&mysqld->m_mysql, stmtopt, &option_id, i,
+      if (populate_options(&mysqld->m_mysql, stmtopt, &option_id, id,
 			   &proc->m_options.m_loaded) == false)
 	return false;
       
-      if (populate_options(&mysqld->m_mysql, stmtopt, &option_id, i,
+      if (populate_options(&mysqld->m_mysql, stmtopt, &option_id, id,
 			   &proc->m_cluster->m_options.m_loaded) == false)
 	return false;
       

=== modified file 'storage/ndb/test/run-test/setup.cpp'
--- a/storage/ndb/test/run-test/setup.cpp	2008-12-12 08:04:28 +0000
+++ b/storage/ndb/test/run-test/setup.cpp	2009-08-05 09:54:52 +0000
@@ -204,13 +204,13 @@ load_process(atrt_config& config, atrt_c
   atrt_host * host_ptr = find(hostname, config.m_hosts);
   atrt_process *proc_ptr = new atrt_process;
 
+  const size_t proc_no = config.m_processes.size();
   config.m_processes.push_back(proc_ptr);
   host_ptr->m_processes.push_back(proc_ptr);
   cluster.m_processes.push_back(proc_ptr);
   
   atrt_process& proc = *proc_ptr;
   
-  const size_t proc_no = config.m_processes.size();
   proc.m_index = idx;
   proc.m_type = type;
   proc.m_host = host_ptr;
@@ -232,6 +232,7 @@ load_process(atrt_config& config, atrt_c
   proc.m_proc.m_ulimit = "c:unlimited";
   proc.m_proc.m_env.assfmt("MYSQL_BASE_DIR=%s", g_prefix);
   proc.m_proc.m_env.appfmt(" MYSQL_HOME=%s", g_basedir);
+  proc.m_proc.m_env.appfmt(" ATRT_PID=%u", (unsigned)proc_no);
   proc.m_proc.m_shutdown_options = "";
 
   int argc = 1;

=== modified file 'storage/ndb/test/src/AtrtClient.cpp'
--- a/storage/ndb/test/src/AtrtClient.cpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/test/src/AtrtClient.cpp	2009-08-05 09:54:52 +0000
@@ -19,6 +19,7 @@
 #include <AtrtClient.hpp>
 #include <NDBT_Output.hpp>
 #include <NdbSleep.h>
+#include <NdbEnv.h>
 
 AtrtClient::AtrtClient(const char* _group_suffix)
   : DbUtil("atrt", _group_suffix)
@@ -210,7 +211,16 @@ AtrtClient::getNdbds(int cluster_id, Sql
                   result);
 }
 
-
-
-
-
+int
+AtrtClient::getOwnProcessId()
+{
+  /**
+   * Put in env for simplicity
+   */
+  char buf[100];
+  if (NdbEnv_GetEnv("ATRT_PID", buf, sizeof(buf)))
+  {
+    return atoi(buf);
+  }
+  return -1;
+}


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20090805095452-tbsj81zqii16du1c.bundle
Thread
bzr commit into mysql-5.1-telco-6.3 branch (jonas:3005) Bug#46494Jonas Oreland5 Aug