summaryrefslogtreecommitdiff
path: root/storage/ndb/test/run-test/atrt.hpp
blob: a6dd75b460e2cd406129ab77fc3eb44b8027d762 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* Copyright (c) 2003-2005, 2007 MySQL AB, 2008 Sun Microsystems, Inc.
   Use is subject to license terms

   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; version 2 of the License.

   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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA */

#ifndef atrt_config_hpp
#define atrt_config_hpp

#include <ndb_global.h>
#include <Vector.hpp>
#include <BaseString.hpp>
#include <Logger.hpp>
#include <mgmapi.h>
#include <CpcClient.hpp>
#include <Properties.hpp>

enum ErrorCodes 
{
  ERR_OK = 0,
  ERR_NDB_FAILED = 101,
  ERR_SERVERS_FAILED = 102,
  ERR_MAX_TIME_ELAPSED = 103
};

struct atrt_host 
{
  size_t m_index;
  BaseString m_user;
  BaseString m_basedir;
  BaseString m_hostname;
  SimpleCpcClient * m_cpcd;
  Vector<struct atrt_process*> m_processes;
};

struct atrt_options
{
  enum Feature {
    AO_REPLICATION = 1,
    AO_NDBCLUSTER = 2
  };
  
  int m_features;
  Properties m_loaded;
  Properties m_generated;
};

struct atrt_process 
{
  size_t m_index;
  struct atrt_host * m_host;
  struct atrt_cluster * m_cluster;

  enum Type {
    AP_ALL          = 255
    ,AP_NDBD         = 1
    ,AP_NDB_API      = 2
    ,AP_NDB_MGMD     = 4
    ,AP_MYSQLD       = 16
    ,AP_CLIENT       = 32
    ,AP_CLUSTER      = 256 // Used for options parsing for "cluster" options
  } m_type;

  SimpleCpcClient::Process m_proc;
  
  NdbMgmHandle m_ndb_mgm_handle;   // if type == ndb_mgm
  atrt_process * m_mysqld;         // if type == client
  atrt_process * m_rep_src;        // if type == mysqld
  Vector<atrt_process*> m_rep_dst; // if type == mysqld
  
  atrt_options m_options;
};

struct atrt_cluster
{
  BaseString m_name;
  BaseString m_dir;
  Vector<atrt_process*> m_processes;
  atrt_options m_options;
};

struct atrt_config 
{
  bool m_generated;
  BaseString m_key;
  BaseString m_replication;
  Vector<atrt_host*> m_hosts;
  Vector<atrt_cluster*> m_clusters;
  Vector<atrt_process*> m_processes;
};

struct atrt_testcase 
{
  bool m_report;
  bool m_run_all;
  time_t m_max_time;
  BaseString m_command;
  BaseString m_args;
  BaseString m_name;
};

extern Logger g_logger;

void require(bool x);
bool parse_args(int argc, char** argv);
bool setup_config(atrt_config&);
bool configure(atrt_config&, int setup);
bool setup_directories(atrt_config&, int setup);
bool setup_files(atrt_config&, int setup, int sshx);

bool deploy(atrt_config&);
bool sshx(atrt_config&, unsigned procmask);
bool start(atrt_config&, unsigned procmask);

bool remove_dir(const char *, bool incl = true);
bool connect_hosts(atrt_config&);
bool connect_ndb_mgm(atrt_config&);
bool wait_ndb(atrt_config&, int ndb_mgm_node_status);
bool start_processes(atrt_config&, int);
bool stop_processes(atrt_config&, int);
bool update_status(atrt_config&, int);
int is_running(atrt_config&, int);
bool gather_result(atrt_config&, int * result);

bool read_test_case(FILE *, atrt_testcase&, int& line);
bool setup_test_case(atrt_config&, const atrt_testcase&);

bool setup_hosts(atrt_config&);

/**
 * Global variables...
 */
extern Logger g_logger;
extern atrt_config g_config;

extern const char * g_cwd;
extern const char * g_my_cnf;
extern const char * g_user;
extern const char * g_basedir;
extern const char * g_prefix;
extern int          g_baseport;
extern int          g_fqpn;
extern int          g_default_ports;

extern const char * g_clusters;

extern const char *save_file;
extern const char *save_group_suffix;
extern char *save_extra_file;

#endif