Skip to content

Commit d41506c

Browse files
authored
Merge pull request #122 from frf12/v1.4.0
V1.4.0
2 parents fa4c735 + 912f71b commit d41506c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2194
-380
lines changed

_arch.py

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,18 @@
11
# coding: utf-8
2-
# OceanBase Deploy.
3-
# Copyright (C) 2021 OceanBase
4-
#
5-
# This file is part of OceanBase Deploy.
6-
#
7-
# OceanBase Deploy is free software: you can redistribute it and/or modify
8-
# it under the terms of the GNU General Public License as published by
9-
# the Free Software Foundation, either version 3 of the License, or
10-
# (at your option) any later version.
11-
#
12-
# OceanBase Deploy is distributed in the hope that it will be useful,
13-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
# GNU General Public License for more details.
16-
#
17-
# You should have received a copy of the GNU General Public License
18-
# along with OceanBase Deploy. If not, see <https://www.gnu.org/licenses/>.
192
import os
203
import ctypes
214
import struct
225

236
_ppc64_native_is_best = True
247

258
# dict mapping arch -> ( multicompat, best personality, biarch personality )
26-
multilibArches = { "x86_64": ( "athlon", "x86_64", "athlon" ),
27-
"sparc64v": ( "sparcv9v", "sparcv9v", "sparc64v" ),
28-
"sparc64": ( "sparcv9", "sparcv9", "sparc64" ),
29-
"ppc64": ( "ppc", "ppc", "ppc64" ),
30-
"s390x": ( "s390", "s390x", "s390" ),
31-
}
9+
multilibArches = {
10+
"x86_64": ( "athlon", "x86_64", "athlon" ),
11+
"sparc64v": ( "sparcv9v", "sparcv9v", "sparc64v" ),
12+
"sparc64": ( "sparcv9", "sparcv9", "sparc64" ),
13+
"ppc64": ( "ppc", "ppc", "ppc64" ),
14+
"s390x": ( "s390", "s390x", "s390" ),
15+
}
3216
if _ppc64_native_is_best:
3317
multilibArches["ppc64"] = ( "ppc", "ppc64", "ppc64" )
3418

@@ -103,14 +87,15 @@
10387

10488
#itanium
10589
"ia64": "noarch",
106-
}
90+
}
10791

10892
# Will contain information parsed from /proc/self/auxv via _parse_auxv().
10993
# Should move into rpm really.
11094
_aux_vector = {
11195
"platform": "",
11296
"hwcap": 0,
113-
}
97+
}
98+
11499

115100
def _try_read_cpuinfo():
116101
""" Try to read /proc/cpuinfo ... if we can't ignore errors (ie. proc not
@@ -120,6 +105,7 @@ def _try_read_cpuinfo():
120105
except:
121106
return []
122107

108+
123109
def _parse_auxv():
124110
""" Read /proc/self/auxv and parse it into global dict for easier access
125111
later on, very similar to what rpm does. """
@@ -146,6 +132,7 @@ def _parse_auxv():
146132
_aux_vector["hwcap"] = at_val
147133
offset = offset + fmtlen
148134

135+
149136
def getCanonX86Arch(arch):
150137
#
151138
if arch == "i586":
@@ -171,6 +158,7 @@ def getCanonX86Arch(arch):
171158

172159
return arch
173160

161+
174162
def getCanonARMArch(arch):
175163
# the %{_target_arch} macro in rpm will let us know the abi we are using
176164
try:
@@ -182,6 +170,7 @@ def getCanonARMArch(arch):
182170
pass
183171
return arch
184172

173+
185174
def getCanonPPCArch(arch):
186175
# FIXME: should I do better handling for mac, etc?
187176
if arch != "ppc64":
@@ -212,6 +201,7 @@ def getCanonPPCArch(arch):
212201
return "ppc64iseries"
213202
return arch
214203

204+
215205
def getCanonSPARCArch(arch):
216206
# Deal with sun4v, sun4u, sun4m cases
217207
SPARCtype = None
@@ -253,7 +243,8 @@ def getCanonX86_64Arch(arch):
253243
if vendor.find("GenuineIntel") != -1:
254244
return "ia32e"
255245
return arch
256-
246+
247+
257248
def getCanonArch(skipRpmPlatform = 0):
258249
if not skipRpmPlatform and os.access("/etc/rpm/platform", os.R_OK):
259250
try:
@@ -282,8 +273,10 @@ def getCanonArch(skipRpmPlatform = 0):
282273
return getCanonX86_64Arch(arch)
283274
return arch
284275

276+
285277
canonArch = getCanonArch()
286278

279+
287280
def isMultiLibArch(arch=None):
288281
"""returns true if arch is a multilib arch, false if not"""
289282
if arch is None:
@@ -300,6 +293,7 @@ def isMultiLibArch(arch=None):
300293

301294
return 0
302295

296+
303297
def getBaseArch(myarch=None):
304298
"""returns 'base' arch for myarch, if specified, or canonArch if not.
305299
base arch is the arch before noarch in the arches dict if myarch is not
@@ -338,7 +332,8 @@ def getBaseArch(myarch=None):
338332
value = arches[basearch]
339333

340334
return basearch
341-
335+
336+
342337
def getArchList(thisarch=None):
343338
# this returns a list of archs that are compatible with arch given
344339
if not thisarch:

_cmd.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,27 @@ def warn(self, msg, file=None):
6969

7070
def _process_long_opt(self, rargs, values):
7171
try:
72+
value = rargs[0]
7273
OptionParser._process_long_opt(self, rargs, values)
7374
except BadOptionError as e:
7475
if self.allow_undefine:
76+
key = e.opt_str
77+
value = value[len(key)+1:]
78+
setattr(values, key.strip('-').replace('-', '_'), value if value != '' else True)
7579
return self.warn(e)
7680
else:
7781
raise e
7882

7983
def _process_short_opts(self, rargs, values):
8084
try:
85+
value = rargs[0]
8186
OptionParser._process_short_opts(self, rargs, values)
8287
except BadOptionError as e:
8388
if self.allow_undefine:
89+
key = e.opt_str
90+
value = value[len(key)+1:]
91+
setattr(values, key.strip('-').replace('-', '_'), value if value != '' else True)
8492
return self.warn(e)
85-
return
8693
else:
8794
raise e
8895

@@ -787,6 +794,7 @@ def __init__(self):
787794
self.parser.add_option('--obclient-bin', type='string', help='OBClient bin path. [obclient]', default='obclient')
788795
self.parser.add_option('--test-dir', type='string', help='Test case file directory. [./mysql_test/t]', default='./mysql_test/t')
789796
self.parser.add_option('--result-dir', type='string', help='Result case file directory. [./mysql_test/r]', default='./mysql_test/r')
797+
self.parser.add_option('--record', action='store_true', help='record mysqltest execution results', default=False)
790798
self.parser.add_option('--record-dir', type='string', help='The directory of the result file for mysqltest.')
791799
self.parser.add_option('--log-dir', type='string', help='The log file directory. [./log]', default='./log')
792800
self.parser.add_option('--tmp-dir', type='string', help='Temporary directory for mysqltest. [./tmp]', default='./tmp')
@@ -910,7 +918,7 @@ def __init__(self):
910918
self.register_command(MySQLTestCommand())
911919
self.register_command(SysBenchCommand())
912920
self.register_command(TPCHCommand())
913-
# self.register_command(TPCCCommand())
921+
self.register_command(TPCCCommand())
914922

915923

916924
class BenchMajorCommand(MajorCommand):

_deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ def get_parser(self, component='', style=''):
10831083
return parser
10841084
parser = self._get_global_parser(style)
10851085
if not parser:
1086-
raise ParserError('Unsupported configuration style: %s' % style)
1086+
raise ParserError('Unsupported configuration style: %s %s' % (component, style))
10871087
return parser
10881088

10891089

_errno.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ class InitDirFailedErrorMessage(object):
4949
PERMISSION_DENIED = ': {path} permission denied .'
5050

5151

52-
DOC_LINK_MSG = 'See https://open.oceanbase.com/docs/obd-cn/V1.3.0/10000000000099584.'
52+
DOC_LINK_MSG = 'See https://open.oceanbase.com/docs/obd-cn/V1.4.0/10000000000436999 .'
5353

5454
EC_CONFIG_CONFLICT_PORT = OBDErrorCode(1000, 'Configuration conflict {server1}:{port} port is used for {server2}\'s {key}')
5555
EC_CONFLICT_PORT = OBDErrorCode(1001, '{server}:{port} port is already used')
5656
EC_FAIL_TO_INIT_PATH = OBDErrorCode(1002, 'Fail to init {server} {key}{msg}')
5757
EC_CLEAN_PATH_FAILED = OBDErrorCode(1003, 'Fail to clean {server}:{path}')
5858
EC_CONFIG_CONFLICT_DIR = OBDErrorCode(1004, 'Configuration conflict {server1}: {path} is used for {server2}\'s {key}')
5959
EC_SOME_SERVER_STOPED = OBDErrorCode(1005, 'Some of the servers in the cluster have been stopped')
60+
EC_FAIL_TO_CONNECT = OBDErrorCode(1006, 'Failed to connect to {component}')
61+
EC_ULIMIT_CHECK = OBDErrorCode(1007, '({server}) {key} must not be less than {need} (Current value: {now})')
6062

6163
EC_OBSERVER_NOT_ENOUGH_MEMORY = OBDErrorCode(2000, '({ip}) not enough memory. (Free: {free}, Need: {need})')
6264
EC_OBSERVER_CAN_NOT_MIGRATE_IN = OBDErrorCode(2001, 'server can not migrate in')
@@ -66,7 +68,11 @@ class InitDirFailedErrorMessage(object):
6668

6769
EC_MYSQLTEST_PARSE_CMD_FAILED = OBDErrorCode(3000, 'parse cmd failed: {path}')
6870
EC_MYSQLTEST_FAILE_NOT_FOUND = OBDErrorCode(3001, '{file} not found in {path}')
71+
EC_TPCC_LOAD_DATA_FAILED = OBDErrorCode(3002, 'Failed to load data.')
72+
EC_TPCC_RUN_TEST_FAILED = OBDErrorCode(3003, 'Failed to run TPC-C benchmark.')
6973

7074
EC_OBAGENT_RELOAD_FAILED = OBDErrorCode(4000, 'Fail to reload {server}')
7175
EC_OBAGENT_SEND_CONFIG_FAILED = OBDErrorCode(4001, 'Fail to send config file to {server}')
7276

77+
# WARN CODE
78+
WC_ULIMIT_CHECK = OBDErrorCode(1007, '({server}) The recommended number of {key} is {need} (Current value: %s)')

core.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,6 @@ def check_for_ocp(self, name, options=Values()):
939939
db = ret.get_return('connect')
940940
cursor = ret.get_return('cursor')
941941
else:
942-
self._call_stdio('error', 'Failed to connect %s' % repository.name)
943942
break
944943

945944
self._call_stdio('verbose', 'Call %s for %s' % (ocp_check[repository], repository))
@@ -1257,7 +1256,6 @@ def start_cluster(self, name, cmd=[], options=Values()):
12571256
db = ret.get_return('connect')
12581257
cursor = ret.get_return('cursor')
12591258
else:
1260-
self._call_stdio('error', 'Failed to connect %s' % repository.name)
12611259
break
12621260

12631261
if need_bootstrap and start_all:
@@ -1329,7 +1327,6 @@ def create_tenant(self, name, options=Values()):
13291327
db = ret.get_return('connect')
13301328
cursor = ret.get_return('cursor')
13311329
if not db:
1332-
self._call_stdio('error', 'Failed to connect %s' % repository.name)
13331330
return False
13341331

13351332
self._call_stdio('verbose', 'Call %s for %s' % (create_tenant_plugins[repository], repository))
@@ -1376,7 +1373,6 @@ def drop_tenant(self, name, options=Values()):
13761373
db = ret.get_return('connect')
13771374
cursor = ret.get_return('cursor')
13781375
if not db:
1379-
self._call_stdio('error', 'Failed to connect %s' % repository.name)
13801376
return False
13811377

13821378
self._call_stdio('verbose', 'Call %s for %s' % (drop_tenant_plugins[repository], repository))
@@ -1466,7 +1462,6 @@ def _reload_cluster(self, deploy):
14661462
db = ret.get_return('connect')
14671463
cursor = ret.get_return('cursor')
14681464
else:
1469-
self._call_stdio('error', 'Failed to connect %s' % repository.name)
14701465
continue
14711466

14721467
self._call_stdio('verbose', 'Call %s for %s' % (reload_plugins[repository], repository))
@@ -1537,7 +1532,6 @@ def display_cluster(self, name):
15371532
db = ret.get_return('connect')
15381533
cursor = ret.get_return('cursor')
15391534
if not db:
1540-
self._call_stdio('error', 'Failed to connect %s' % repository.name)
15411535
return False
15421536

15431537
self._call_stdio('verbose', 'Call %s for %s' % (display_plugins[repository], repository))
@@ -2135,7 +2129,6 @@ def upgrade_cluster(self, name, options=Values()):
21352129
db = ret.get_return('connect')
21362130
cursor = ret.get_return('cursor')
21372131
if not db:
2138-
self._call_stdio('error', 'Failed to connect %s' % current_repository.name)
21392132
return False
21402133
self._call_stdio('verbose', 'Call %s for %s' % (upgrade_check_plugins[current_repository], current_repository))
21412134
if not upgrade_check_plugins[current_repository](
@@ -2369,7 +2362,6 @@ def mysqltest(self, name, opts):
23692362
connect_plugin = self.search_py_script_plugin(repositories, 'connect')[repository]
23702363
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server, sys_root=False)
23712364
if not ret or not ret.get_return('connect'):
2372-
self._call_stdio('error', 'Failed to connect to the server')
23732365
return False
23742366
db = ret.get_return('connect')
23752367
cursor = ret.get_return('cursor')
@@ -2430,7 +2422,6 @@ def mysqltest(self, name, opts):
24302422
connect_plugin = self.search_py_script_plugin(repositories, 'connect')[repository]
24312423
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server, sys_root=False)
24322424
if not ret or not ret.get_return('connect'):
2433-
self._call_stdio('error', 'Failed to connect server')
24342425
break
24352426
db = ret.get_return('connect')
24362427
cursor = ret.get_return('cursor')
@@ -2482,6 +2473,14 @@ def sysbench(self, name, opts):
24822473
if opts.component is None:
24832474
for component_name in allow_components:
24842475
if component_name in deploy_config.components:
2476+
if opts.test_server is not None:
2477+
cluster_config = deploy_config.components[component_name]
2478+
for server in cluster_config.servers:
2479+
if server.name == opts.test_server:
2480+
break
2481+
else:
2482+
continue
2483+
self._call_stdio('verbose', 'Select component %s' % component_name)
24852484
opts.component = component_name
24862485
break
24872486
elif opts.component not in allow_components:
@@ -2556,14 +2555,12 @@ def sysbench(self, name, opts):
25562555
break
25572556
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server)
25582557
if not ret or not ret.get_return('connect'):
2559-
self._call_stdio('error', 'Failed to connect to the server')
25602558
return False
25612559
odp_db = ret.get_return('connect')
25622560
odp_cursor = ret.get_return('cursor')
25632561

25642562
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server, **env)
25652563
if not ret or not ret.get_return('connect'):
2566-
self._call_stdio('error', 'Failed to connect to the server')
25672564
return False
25682565
db = ret.get_return('connect')
25692566
cursor = ret.get_return('cursor')
@@ -2650,7 +2647,6 @@ def tpch(self, name, opts):
26502647
connect_plugin = self.search_py_script_plugin(repositories, 'connect')[repository]
26512648
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio, target_server=opts.test_server)
26522649
if not ret or not ret.get_return('connect'):
2653-
self._call_stdio('error', 'Failed to connect to the server')
26542650
return False
26552651
db = ret.get_return('connect')
26562652
cursor = ret.get_return('cursor')
@@ -2786,7 +2782,6 @@ def tpcc(self, name, opts):
27862782
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio,
27872783
target_server=opts.test_server)
27882784
if not ret or not ret.get_return('connect'):
2789-
self._call_stdio('error', 'Failed to connect to the server')
27902785
return False
27912786
odp_db = ret.get_return('connect')
27922787
odp_cursor = ret.get_return('cursor')
@@ -2798,7 +2793,6 @@ def tpcc(self, name, opts):
27982793
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {}, self.stdio,
27992794
target_server=opts.test_server, **env)
28002795
if not ret or not ret.get_return('connect'):
2801-
self._call_stdio('error', 'Failed to connect to the server')
28022796
return False
28032797
db = ret.get_return('connect')
28042798
cursor = ret.get_return('cursor')
@@ -2867,15 +2861,13 @@ def tpcc(self, name, opts):
28672861
self.stdio,
28682862
target_server=opts.test_server)
28692863
if not ret or not ret.get_return('connect'):
2870-
self._call_stdio('error', 'Failed to connect to the server')
28712864
return False
28722865
odp_db = ret.get_return('connect')
28732866
odp_cursor = ret.get_return('cursor')
28742867
ret = connect_plugin(deploy_config.components.keys(), ssh_clients, cluster_config, [], {},
28752868
self.stdio,
28762869
target_server=opts.test_server, **env)
28772870
if not ret or not ret.get_return('connect'):
2878-
self._call_stdio('error', 'Failed to connect to the server')
28792871
return False
28802872
db = ret.get_return('connect')
28812873
cursor = ret.get_return('cursor')

0 commit comments

Comments
 (0)