-class CTSvars:
+class CTSvars(object):
CTS_home="@prefix@/share/pacemaker/tests/cts"
INITDIR="/etc/init.d"
'''CTS: Cluster Testing System: Lab environment module
'''
+from __future__ import print_function
+
__copyright__='''
Copyright (c) 2010 Red Hat, Inc.
def usage(arg):
- print "Illegal argument " + arg
- print "usage: " + sys.argv[0] +" [options] number-of-iterations"
- print "\nCommon options: "
- print "\t [--at-boot (1|0)], does the cluster software start at boot time"
- print "\t [--nodes 'node list'], list of cluster nodes separated by whitespace"
- print "\t [--limit-nodes max], only use the first 'max' cluster nodes supplied with --nodes"
- print "\t [--logfile path], where should the test software look for logs from cluster nodes"
- print "\t [--rrp-bindaddr addr], extra interface used for rrp, provide the bindaddr"
- print "\t [--outputfile path], optional location for the test software to write logs to"
- print "\t [--syslog-facility name], which syslog facility should the test software log to"
- print "\t [--choose testcase-name], run only the named test"
- print "\t [--list-tests], list the valid tests"
- print "\t [--benchmark], add the timing information"
- print "\t "
- print "Additional (less common) options: "
- print "\t [--trunc (truncate logfile before starting)]"
- print "\t [--xmit-loss lost-rate(0.0-1.0)]"
- print "\t [--recv-loss lost-rate(0.0-1.0)]"
- print "\t [--standby (1 | 0 | yes | no)]"
- print "\t [--fencing (1 | 0 | yes | no)]"
- print "\t [--once], run all valid tests once"
- print "\t [--no-loop-tests], dont run looping/time-based tests"
- print "\t [--no-unsafe-tests], dont run tests that are unsafe for use with ocfs2/drbd"
- print "\t [--valgrind-tests], include tests using valgrind"
- print "\t [--experimental-tests], include experimental tests"
- print "\t [--oprofile 'node list'], list of cluster nodes to run oprofile on]"
- print "\t [--qarsh] Use the QARSH backdoor to access nodes instead of SSH"
- print "\t [--seed random_seed]"
- print "\t [--set option=value]"
+ print("Illegal argument " + arg)
+ print("usage: " + sys.argv[0] +" [options] number-of-iterations")
+ print("\nCommon options: ")
+ print("\t [--at-boot (1|0)], does the cluster software start at boot time")
+ print("\t [--nodes 'node list'], list of cluster nodes separated by whitespace")
+ print("\t [--limit-nodes max], only use the first 'max' cluster nodes supplied with --nodes")
+ print("\t [--logfile path], where should the test software look for logs from cluster nodes")
+ print("\t [--rrp-bindaddr addr], extra interface used for rrp, provide the bindaddr")
+ print("\t [--outputfile path], optional location for the test software to write logs to")
+ print("\t [--syslog-facility name], which syslog facility should the test software log to")
+ print("\t [--choose testcase-name], run only the named test")
+ print("\t [--list-tests], list the valid tests")
+ print("\t [--benchmark], add the timing information")
+ print("\t ")
+ print("Additional (less common) options: ")
+ print("\t [--trunc (truncate logfile before starting)]")
+ print("\t [--xmit-loss lost-rate(0.0-1.0)]")
+ print("\t [--recv-loss lost-rate(0.0-1.0)]")
+ print("\t [--standby (1 | 0 | yes | no)]")
+ print("\t [--fencing (1 | 0 | yes | no)]")
+ print("\t [--once], run all valid tests once")
+ print("\t [--no-loop-tests], dont run looping/time-based tests")
+ print("\t [--no-unsafe-tests], dont run tests that are unsafe for use with ocfs2/drbd")
+ print("\t [--valgrind-tests], include tests using valgrind")
+ print("\t [--experimental-tests], include experimental tests")
+ print("\t [--oprofile 'node list'], list of cluster nodes to run oprofile on]")
+ print("\t [--qarsh] Use the QARSH backdoor to access nodes instead of SSH")
+ print("\t [--seed random_seed]")
+ print("\t [--set option=value]")
sys.exit(1)
class CoroLabEnvironment(CtsLab):
Environment["logger"].append(FileLog(Environment, Environment["OutputFile"]))
if len(node_list) < 1:
- print "No nodes specified!"
+ print("No nodes specified!")
sys.exit(1)
if LimitNodes > 0:
for c in self.applied_config:
if 'bindnetaddr' in c:
continue
- elif not self.config.original.has_key(c):
+ elif c not in self.config.original:
# new config option (non default)
pass
elif self.applied_config[c] is not self.config.original[c]:
self.install_all_config()
def key_for_node(self, node):
- if not self.node_to_ip.has_key(node):
+ if node not in self.node_to_ip:
self.node_to_ip[node] = socket.gethostbyname (node)
return self.node_to_ip[node]
def StartaCM(self, node, verbose=False):
- if not self.ShouldBeStatus.has_key(node):
+ if node not in self.ShouldBeStatus:
self.ShouldBeStatus[node] = "down"
if self.ShouldBeStatus[node] != "down":
self.debug('starting corosync on : ' + node)
ret = ClusterManager.StartaCM(self, node)
if self.start_cpg:
- if self.cpg_agent.has_key(node):
+ if node in self.cpg_agent:
self.cpg_agent[node].restart()
else:
self.cpg_agent[node] = CpgTestAgent(node, self.Env)
self.cpg_agent[node].start()
- if self.sam_agent.has_key(node):
+ if node in self.sam_agent:
self.sam_agent[node].restart()
# votequorum agent started as needed.
- if self.applied_config.has_key('quorum/provider'):
+ if 'quorum/provider' in self.applied_config:
if self.applied_config['quorum/provider'] is 'corosync_votequorum':
- if self.votequorum_agent.has_key(node):
+ if node in self.votequorum_agent:
self.votequorum_agent[node].restart()
else:
self.votequorum_agent[node] = VoteQuorumTestAgent(node, self.Env)
return 1
self.debug('stoping corosync on : ' + node)
- if self.cpg_agent.has_key(node):
+ if node in self.cpg_agent:
self.cpg_agent[node].stop()
- if self.sam_agent.has_key(node):
+ if node in self.sam_agent:
self.sam_agent[node].stop()
- if self.votequorum_agent.has_key(node):
+ if node in self.votequorum_agent:
self.votequorum_agent[node].stop()
return ClusterManager.StopaCM(self, node)
raise RuntimeError ("corosync not up")
if self.CM.start_cpg:
- if self.CM.cpg_agent.has_key(node):
+ if node in self.CM.cpg_agent:
self.CM.cpg_agent[node].clean_start()
else:
self.CM.cpg_agent[node] = CpgTestAgent(node, CM.Env)
self.CM.cpg_agent[node].start()
- if self.CM.sam_agent.has_key(node):
+ if node in self.CM.sam_agent:
self.CM.sam_agent[node].clean_start()
else:
self.CM.sam_agent[node] = SamTestAgent(node, CM.Env)
self.CM.sam_agent[node].start()
# votequorum agent started as needed.
- if self.CM.applied_config.has_key('quorum/provider'):
+ if 'quorum/provider' in self.CM.applied_config:
if CM.applied_config['quorum/provider'] is 'corosync_votequorum':
self.CM.votequorum_agent[node] = VoteQuorumTestAgent(node, CM.Env)
self.CM.votequorum_agent[node].start()
'''Tear down (undo) the given ScenarioComponent'''
self.CM = CM
for node in self.Env["nodes"]:
- if self.CM.cpg_agent.has_key(node):
+ if node in self.CM.cpg_agent:
self.CM.cpg_agent[node].stop()
self.CM.sam_agent[node].stop()
- if self.CM.votequorum_agent.has_key(node):
+ if node in self.CM.votequorum_agent:
self.CM.votequorum_agent[node].stop()
###################################################################
self.started = False
resh = RemoteFactory.rsh
self.rsh = RemoteExec(resh)
- self.func_name = None
+ self.__name__ = None
self.used = False
self.env = Env
self.send_recv = False
self.read()
self.started = True
return True
- except RuntimeError, msg:
+ except RuntimeError as msg:
self.started = False
return False
retries = retries + 1
self.sock.connect ((ip, self.port))
is_connected = True
- except socket.error, msg:
+ except socket.error as msg:
if retries > 10:
LogFactory().log("%s:%s Tried connecting %d times. %s" % (self.node, self.binary, retries, str(msg)))
if retries > 30:
a_str = str(a)
real_msg += ":" + str (len (a_str)) + ":" + a_str
real_msg += ";"
+ if sys.version_info > (3,):
+ real_msg = real_msg.encode("utf8")
try:
return self.sock.send (real_msg)
- except socket.error, msg:
+ except socket.error as msg:
LogFactory().log("send(%s): %s; error: %s" % (self.node, real_msg, msg))
return 0
try:
return object.__getattribute__(self, name)
except:
- self.func_name = name
+ self.__name__ = name
if self.send_recv:
return self.send_recv_dynamic
else:
try:
res = self.read ()
- except RuntimeError, msg:
+ except RuntimeError as msg:
res = None
- LogFactory().log("send_recv_dynamic: %s(); error: %s" % (self.func_name, msg))
+ LogFactory().log("send_recv_dynamic: %s(); error: %s" % (self.__name__, msg))
return res
raise RuntimeError ("agent not started")
# number of args+func
- real_msg = str (len (args) + 1) + ":" + str(len(self.func_name)) + ":" + self.func_name
+ real_msg = str (len (args) + 1) + ":" + str(len(self.__name__)) + ":" + self.__name__
for a in args:
a_str = str(a)
real_msg += ":" + str (len (a_str)) + ":" + a_str
real_msg += ";"
sent = 0
+ if sys.version_info > (3,):
+ real_msg = bytes(real_msg, encoding = "utf8")
try:
sent = self.sock.send (real_msg)
- except socket.error, msg:
+ except socket.error as msg:
LogFactory().log("send_dynamic(%s): %s; error: %s" % (self.node, real_msg, msg))
if sent == 0:
try:
msg = self.sock.recv (4096)
- except socket.error, msg:
+ except socket.error as msg:
raise RuntimeError(msg)
+ if sys.version_info > (3,):
+ msg = msg.decode("utf8")
if msg == '':
raise RuntimeError("socket connection broken")
return msg
-class CpgConfigEvent:
+class CpgConfigEvent(object):
def __init__(self, msg):
info = msg.split(',')
self.group_name = info[0]
+from __future__ import division
+from __future__ import print_function
+
__copyright__='''
Copyright (c) 2010 Red Hat, Inc.
'''
import random
import socket
-from UserDict import UserDict
+import sys
+if sys.version_info < (3,):
+ from UserDict import UserDict
+else:
+ from collections import UserDict
from cts.CTStests import *
from corosync import CpgTestAgent
elif self.listener is None:
self.listener = n
- if self.CM.cpg_agent.has_key(self.wobbly):
+ if self.wobbly in self.CM.cpg_agent:
self.wobbly_id = self.CM.cpg_agent[self.wobbly].cpg_local_get()
- if self.CM.cpg_agent.has_key(self.listener):
+ if self.listener in self.CM.cpg_agent:
self.CM.cpg_agent[self.listener].record_config_events(truncate=True)
return ret
waited = waited + 1
printit = printit + 1
if printit is 60:
- print 'waited ' + str(waited) + ' seconds'
+ print('waited ' + str(waited) + ' seconds')
printit = 0
elif str(event.node_id) in str(self.wobbly_id) and not event.is_member:
self.name="CpgCfgChgOnNodeIsolate"
def config_valid(self, config):
- if config.has_key('totem/rrp_mode'):
+ if 'totem/rrp_mode' in config:
return False
else:
return True
self.CM.start_cpg = False
def config_valid(self, config):
- if config.has_key('totem/secauth'):
+ if 'totem/secauth' in config:
if config['totem/secauth'] is 'on':
return False
else:
return True
- if config.has_key('totem/rrp_mode'):
+ if 'totem/rrp_mode' in config:
return False
else:
return True
assert(info != 'NOT_SUPPORTED')
#self.CM.log('refresh: ' + info)
+ if info is None:
+ return
params = info.split(':')
self.node_votes = int(params[0])
return ret
def config_valid(self, config):
- if config.has_key('totem/rrp_mode'):
+ if 'totem/rrp_mode' in config:
return False
- if config.has_key('quorum/provider'):
+ if 'quorum/provider' in config:
return False
return True
if state.total_votes != nodes_alive:
self.failure('unexpected number of total votes:%d, nodes_alive:%d' % (state.total_votes, nodes_alive))
- min = ((len(self.CM.Env["nodes"]) + 2) / 2)
+ min = int((len(self.CM.Env["nodes"]) + 2) / 2)
if min != state.quorum:
self.failure('we should have %d (not %d) as quorum' % (min, state.quorum))
ret = self.stopall(None)
if not ret:
return self.failure("Setup failed")
-
- self.CM.clear_all_caches()
+ #clear_all_caches was removed
+ #self.CM.clear_all_caches()
if not self.startall(None):
return self.failure("Startall failed")
self.need_all_up = False
def config_valid(self, config):
- return not config.has_key('resources')
+ return 'resources' not in config
def __call__(self, node):
'''Perform the 'NoWDConfig' test. '''
h['totem/interface[2]/mcastport'] = '5405'
configs.append(h)
else:
- print 'Not including rrp tests. Use --rrp-binaddr to enable them.'
+ print('Not including rrp tests. Use --rrp-binaddr to enable them.')
num=1
for cfg in configs:
bound_test = testclass(cm)
if bound_test.is_applicable() and bound_test.config_valid(cfg):
bound_test.Audits = audits
- for c in cfg.keys():
+ for c in list(cfg.keys()):
bound_test.config[c] = cfg[c]
bound_test.name = bound_test.name + '_' + cfg.name
result.append(bound_test)