Commit f2f1e4d8 authored by unknown's avatar unknown
Browse files

Patch for IM in scope of working on BUG#24415: Instance manager test

im_daemon_life_cycle fails randomly.

1. Move IM-angel functionality into a separate file, create Angel class.
2. Be more verbose;
3. Fix typo in FLUSH INSTANCES implementation;
4. Polishing.


mysql-test/r/im_options.result:
  Updated result file.
mysql-test/t/im_cmd_line.imtest:
  Updated test.
server-tools/instance-manager/IMService.cpp:
  Move HandleServiceOptions() into IMService::main().
server-tools/instance-manager/IMService.h:
  Move HandleServiceOptions() into IMService::main().
server-tools/instance-manager/Makefile.am:
  Added angel.cc and angel.h.
server-tools/instance-manager/WindowsService.cpp:
  Initialize class-members in constructor.
server-tools/instance-manager/WindowsService.h:
  Initialize class-members in constructor.
server-tools/instance-manager/commands.cc:
  Return actual error code (ER_OUT_OF_RESOURCES or ER_THERE_IS_ACTIVE_INSTANCE)
  from FLUSH INSTANCES.
server-tools/instance-manager/manager.cc:
  1. Return actual error code from Manager::flush_instances().
  2. Be more verbose.
server-tools/instance-manager/manager.h:
  Return actual error code from Manager::flush_instances().
server-tools/instance-manager/mysqlmanager.cc:
  Move IM-angel functionality into separate file (angel.cc).
server-tools/instance-manager/priv.cc:
  Use return bool datatype instead int{ 0, 1 }.
server-tools/instance-manager/priv.h:
  Use return bool datatype instead int{ 0, 1 }.
server-tools/instance-manager/angel.cc:
  IM-angel functionality.
server-tools/instance-manager/angel.h:
  IM-angel functionality.
parent 64a60185
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
--------------------------------------------------------------------
server_id           = 1
server_id           = 2
--------------------------------------------------------------------
SHOW VARIABLES LIKE 'server_id';
Variable_name	Value
server_id	1
SHOW INSTANCES;
instance_name	state
mysqld1	starting
mysqld1	XXXXX
mysqld2	offline
UNSET mysqld1.server_id;
ERROR HY000: The instance is active. Stop the instance first
@@ -86,7 +82,7 @@ UNSET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc, mysqld3.ddd;
--------------------------------------------------------------------
--------------------------------------------------------------------
SET mysqld2.aaa, mysqld3.bbb, mysqld.ccc = 0010;
ERROR HY000: Bad instance name. Check that the instance with such a name exists
ERROR HY000: Unknown instance name
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
@@ -98,7 +94,7 @@ ERROR HY000: The instance is active. Stop the instance first
--------------------------------------------------------------------
--------------------------------------------------------------------
UNSET mysqld2.server_id, mysqld3.server_id, mysqld.ccc;
ERROR HY000: Bad instance name. Check that the instance with such a name exists
ERROR HY000: Unknown instance name
--------------------------------------------------------------------
server_id           = 1
server_id=2
+2 −2
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
--echo

--echo --> Printing out line for 'testuser'...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=abc | tail -1
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=abc | tail -2 | head -1
--echo

--echo --> Listing users...
@@ -45,7 +45,7 @@
--echo

--echo --> Printing out line for 'testuser'...
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=xyz | tail -1
--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --print-password-line --username=testuser --password=xyz | tail -2 | head -1
--echo

--echo --> Listing users...
+42 −27
Original line number Diff line number Diff line
@@ -15,17 +15,19 @@

#include <windows.h>
#include <signal.h>
#include "log.h"
#include "options.h"

#include "IMService.h"

#include "log.h"
#include "manager.h"
#include "options.h"

static const char * const IM_SVC_USERNAME= NULL;
static const char * const IM_SVC_PASSWORD= NULL;

IMService::IMService(void)
  :WindowsService("MySqlManager", "MySQL Manager")
{
  serviceName= "MySqlManager";
  displayName= "MySQL Manager";
  username= NULL;
  password= NULL;
}

IMService::~IMService(void)
@@ -60,50 +62,63 @@ void IMService::Log(const char *msg)
  log_info(msg);
}

int HandleServiceOptions()
int IMService::main()
{
  int ret_val= 0;

  IMService winService;

  if (Options::Service::install_as_service)
  {
    if (winService.IsInstalled())
    {
      log_info("Service is already installed.");
    else if (winService.Install())
      return 1;
    }

    if (winService.Install(IM_SVC_USERNAME, IM_SVC_PASSWORD))
    {
      log_info("Service installed successfully.");
      return 0;
    }
    else
    {
      log_error("Service failed to install.");
      ret_val= 1;
      return 1;
    }
  }
  else if (Options::Service::remove_service)

  if (Options::Service::remove_service)
  {
    if (!winService.IsInstalled())
    {
      log_info("Service is not installed.");
    else if (winService.Remove())
      return 1;
    }

    if (winService.Remove())
    {
      log_info("Service removed successfully.");
      return 0;
    }
    else
    {
      log_error("Service failed to remove.");
      ret_val= 1;
      return 1;
    }
  }
  else
  {

  log_info("Initializing Instance Manager service...");

  if (!winService.Init())
  {
    log_error("Service failed to initialize.");

    fprintf(stderr,
      "The service should be started by Windows Service Manager.\n"
      "The MySQL Manager should be started with '--standalone'\n"
      "to run from command line.");
      ret_val= 1;
    }

    return 1;
  }

  return ret_val;
  return 0;
}
+4 −3
Original line number Diff line number Diff line
@@ -14,11 +14,14 @@
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */

#pragma once
#include "windowsservice.h"
#include "WindowsService.h"

class IMService: public WindowsService
{
public:
  static int main();

private:
  IMService(void);
  ~IMService(void);

@@ -27,5 +30,3 @@ class IMService: public WindowsService
  void Stop();
  void Run(DWORD argc, LPTSTR *argv);
};

extern int HandleServiceOptions();
+3 −1
Original line number Diff line number Diff line
@@ -80,7 +80,9 @@ mysqlmanager_SOURCES= command.cc command.h mysqlmanager.cc \
                        portability.h \
			exit_codes.h \
			user_management_commands.h \
			user_management_commands.cc
			user_management_commands.cc \
			angel.h \
			angel.cc

mysqlmanager_LDADD=	@CLIENT_EXTRA_LDFLAGS@ \
			liboptions.la \
Loading