[asterisk-scf-commits] asterisk-scf/integration/testsuite.git branch "review" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed May 25 20:00:15 CDT 2011
branch "review" has been updated
via 099666fb9bc7a9ece2c93ed40b4d7b8f1110632c (commit)
from 12aca01bf526848db24f8ecc11e3593319dc215e (commit)
Summary of changes:
plugins/failover.py | 226 +++++++++++---------
remote.py | 2 +-
.../testcase.yaml | 6 +-
3 files changed, 128 insertions(+), 106 deletions(-)
- Log -----------------------------------------------------------------
commit 099666fb9bc7a9ece2c93ed40b4d7b8f1110632c
Author: Darren Sessions <dsessions at digium.com>
Date: Wed May 25 20:00:13 2011 -0500
Heavy work on the failover plugin.
diff --git a/plugins/failover.py b/plugins/failover.py
index b5a06cc..425501b 100644
--- a/plugins/failover.py
+++ b/plugins/failover.py
@@ -10,12 +10,15 @@
'''
import util
+import time
class testsuite(util.TestSuiteBaseClass):
def main(self, testData, testPath):
corosyncExec = ['corosync','-f']
pacemakerExec = ['pacemaker']
+ shutdownList = [testData['cmd']['testsuite_remote_active'], testData['cmd']['testsuite_remote_standby']]
+
activeNode = {}
standbyNode = {}
@@ -27,124 +30,145 @@ class testsuite(util.TestSuiteBaseClass):
if not 'ipv4oripv6' in testData['cmd']:
return {'success':False,'msg':'No ip version specified.'}
+ else:
+ if not testData['cmd']['ipv4oripv6'] == 'ipv4' and not testData['cmd']['ipv4oripv6'] == 'ipv6':
+ return {'success':False,'msg':'IP version must be ipv4 or ipv6.'}
+ else:
+ ipv = testData['cmd']['ipv4oripv6']
+
+ if not 'shared_ip' in testData['cmd']:
+ return {'success':False,'msg':'No shared IP address specified.'}
+ else:
+ sharedIP = testData['cmd']['shared_ip']
+ if ipv and not 'ipv4_network_addr' in testData['cmd']:
+ return {'success':False,'msg':'The ipv4_network_addr must be specified on IPv4 networks.'}
+ else:
+ if ipv == 'ipv4':
+ activeNode['nAddr'] = testData['cmd']['ipv4_network_addr']
+ standbyNode['nAddr'] = testData['cmd']['ipv4_network_addr']
+ elif ipv == 'ipv6':
+ activeNode['nAddr'] = 'fc00:1::1'
+ standbyNode['nAddr'] = 'fc00:1::2'
results = self.rpc(testData['cmd']['testsuite_remote_active'])
if not results['success'] == True:
- return results
+ return self._addShutdownList(results, shutdownList)
+ else:
activeNode['rpc'] = results['rpc']
activeNode['nodeID'] = '0'
(activeNode['ipv4'], activeNode['ipv6']) = activeNode['rpc'].whatAreMyIps()
results = self.rpc(testData['cmd']['testsuite_remote_standby'])
if not results['success'] == True:
- return results
+ return self._addShutdownList(results, shutdownList)
else:
standbyNode['rpc'] = results['rpc']
- activeNode['nodeID'] = '1'
+ standbyNode['nodeID'] = '1'
(standbyNode['ipv4'], standbyNode['ipv6']) = standbyNode['rpc'].whatAreMyIps()
-
- print self._corosyncConfig(
-
+ print activeNode['ipv4'], activeNode['ipv6']
+ print standbyNode['ipv4'], standbyNode['ipv6']
- return {'success':True,'shutdownList':[testData['cmd']['testsuite_remote_active'], testData['cmd']['testsuite_remote_standby']]}
-
- ''' start and stop individual components. shutdown is implemented in the main testsuite code '''
- for cmd in testData['cmd']:
- if cmd == 'start':
- for component in testData['cmd']['start']:
- print component
- #results = rpc.writeFile('%s.conf' % component, '\n'.join(self._componentConfig(component)))
- #if results['success'] == False:
- # return results
- #results = rpc.setEnvVar('libpath', '!!TMP!!/gitall/build/lib')
- #if results['success'] == False:
- # return results
- #results = rpc.run('asteriskscf_icebox', component, [iceBoxCmd[0], "%s%s.conf" % (iceBoxCmd[1], component)])
- #if results['success'] == False:
- # return results
- elif cmd == 'stop':
- print 'stop'
- else:
- return {'success':False,'msg':'The %s command is invalid.' % cmd}
- return {'success':True}
-
- def _corosyncConfig(self, ipV, nodeID, hostIP):
- if ipV == 4:
- config = [
- 'totem {',
- ' version: 2',
- ' token: 160',
- ' token_retransmits_before_loss_const: 3',
- ' join: 30',
- ' consensus: 300',
- ' vsftype: none',
- ' max_messages: 20',
- ' clear_node_high_bit: yes',
- ' secauth: off',
- ' threads: 0',
- ' nodeid: %s' % nodeID,
- ' rrp_mode: none',
- ' interface {',
- ' member {',
- ' memberaddr: %s' % node1,
- ' }',
- ' member {',
- ' memberaddr: %s' % node2,
- ' }',
- ' ringnumber: 0',
- ' bindnetaddr: %s' % networkAddr,
- ' mcastport: 5405',
- ' ttl: 1',
- ' }',
- ' transport: udpu',
- '}',
- 'amf {',
- ' mode: disabled',
- '}',
- 'service {',
- ' ver: 0',
- ' name: pacemaker',
- '}',
- 'aisexec {',
- ' user: root',
- ' group: root',
- '}',
- 'logging {',
- ' fileline: off',
- ' to_stderr: yes',
- ' to_logfile: no',
- ' to_syslog: yes',
- ' syslog_facility: daemon',
- ' debug: off',
- ' timestamp: on',
- ' logger_subsys {',
- ' subsys: AMF',
- ' debug: off',
- ' tags: enter|leave|trace1|trace2|trace3|trace4|trace6',
- ' }',
- '}']
+ results = activeNode['rpc'].wFile('/etc/corosync/corosync.conf', '\n'.join(self._corosyncConfig(activeNode[ipv], standbyNode[ipv], activeNode['nodeID'], activeNode['nAddr'])))
+ if not results['success'] == True:
+ return self._addShutdownList(results, shutdownList)
+ results = activeNode['rpc'].run('failover', 'corosync', ['corosync', '-f'])
+ if not results['success'] == True:
+ return self._addShutdownList(results, shutdownList)
+
+ standbyNode['rpc'].wFile('/etc/corosync/corosync.conf', '\n'.join(self._corosyncConfig(activeNode[ipv], standbyNode[ipv], standbyNode['nodeID'], standbyNode['nAddr'])))
+ if not results['success'] == True:
+ return self._addShutdownList(results, shutdownList)
+ results = standbyNode['rpc'].run('failover', 'corosync', ['corosync', '-f'])
+ if not results['success'] == True:
+ return self._addShutdownList(results, shutdownList)
+ activeNode['rpc'].writeFile('pacemaker.cli', '\n'.join(self._pacemakerConfig(activeNode[ipv], standbyNode[ipv], sharedIP)))
+ if not results['success'] == True:
+ return self._addShutdownList(results, shutdownList)
+ results = activeNode['rpc'].run('failover', 'crm', ['crm', '-f', '!!TMP!!/pacemaker.cli'], True)
+
+
+ results = activeNode['rpc'].run('failover', 'cibadmin', ['cibadmin', '-E', '--force'], True)
+ if not results['success'] == True:
+ return self._addShutdownList(results, shutdownList)
+ results = standbyNode['rpc'].run('failover', 'cibadmin', ['cibadmin', '-E', '--force'], True)
+ if not results['success'] == True:
+ return self._addShutdownList(results, shutdownList)
+
+ time.sleep(100)
+
+ return {'success':True,'shutdownList':shutdownList}
+
+
+ def _addShutdownList(self, results, shutdownList):
+ results['shutdownList'] = shutdownList
+ return results
+
+ def _corosyncConfig(self, activeIP, standbyIP, nodeID, networkAddr):
+ config = [
+ 'compatibility: whitetank',
+ 'totem {',
+ ' version: 2',
+ ' secauth: off',
+ ' nodeid: %s' % nodeID,
+ ' interface {',
+ ' member {',
+ ' memberaddr: %s' % activeIP,
+ ' }',
+ ' member {',
+ ' memberaddr: %s' % standbyIP,
+ ' }',
+ ' ringnumber: 0',
+ ' bindnetaddr: %s' % networkAddr,
+ ' mcastaddr: 226.94.1.1',
+ ' mcastport: 5405',
+ ' ttl: 1',
+ ' }',
+ ' transport: udpu',
+ '}',
+ 'amf {',
+ ' mode: disabled',
+ '}',
+ 'service {',
+ ' ver: 0',
+ ' name: pacemaker',
+ '}',
+ 'aisexec {',
+ ' user: root',
+ ' group: root',
+ '}',
+ 'logging {',
+ ' fileline: off',
+ ' to_stderr: no',
+ ' to_logfile: no',
+ ' to_syslog: yes',
+ ' syslog_facility: daemon',
+ ' debug: off',
+ ' timestamp: on',
+ ' logger_subsys {',
+ ' subsys: AMF',
+ ' debug: off',
+ ' tags: enter|leave|trace1|trace2|trace3|trace4|trace6',
+ ' }',
+ '}']
return config
- def _pacemakerConfig(self, ipV, node1, node2, sharedIP):
- if ipV == 4:
- config = [
- 'node %s\n' % node1,
- 'node %s\n' % node2,
- 'primitive failover-ip ocf:heartbeat:IPaddr \\',
- ' params ip="%s" \\' % sharedIP,
- ' op monitor interval="1s" \\',
- ' meta is-managed="true" target-role="Started"',
- 'location cli-prefer-failover-ip failover-ip \\',
- ' rule $id="cli-prefer-rule-failover-ip" inf: #uname eq %s' % node1,
- 'property $id="cib-bootstrap-options" \\',
- ' dc-version="1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd" \\',
- ' cluster-infrastructure="openais" \\',
- ' expected-quorum-votes="2" \\',
- ' stonith-enabled="false" \\',
- ' no-quorum-policy="ignore" \\',
- ' default-resource-stickiness="infinity"']
+ def _pacemakerConfig(self, activeIP, standbyIP, sharedIP):
+ config = [
+ 'primitive failover-ip ocf:heartbeat:IPaddr \\',
+ ' params ip="%s" \\' % sharedIP,
+ ' op monitor interval="1s" \\',
+ ' meta is-managed="true" target-role="Started"',
+ 'location cli-prefer-failover-ip failover-ip \\',
+ ' rule $id="cli-prefer-rule-failover-ip" inf: #uname eq %s' % activeIP,
+ 'property $id="cib-bootstrap-options" \\',
+ ' dc-version="1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd" \\',
+ ' cluster-infrastructure="openais" \\',
+ ' expected-quorum-votes="2" \\',
+ ' stonith-enabled="false" \\',
+ ' no-quorum-policy="ignore" \\',
+ ' default-resource-stickiness="infinity"']
return config
diff --git a/remote.py b/remote.py
index a3cc87a..d930f33 100755
--- a/remote.py
+++ b/remote.py
@@ -191,7 +191,7 @@ class RemoteManagement(object):
return results
def writeFile(self, fn, fd):
- return self._wFile("%s/tmp/%s" % (cwd, fn), fd)
+ return self.wFile("%s/tmp/%s" % (cwd, fn), fd)
def wFile(self, fn, fd):
try:
diff --git a/tests/failover/SysTest_Functional_Basic_Call_Setup_w_Failover/testcase.yaml b/tests/failover/SysTest_Functional_Basic_Call_Setup_w_Failover/testcase.yaml
index 984582b..a41be9d 100644
--- a/tests/failover/SysTest_Functional_Basic_Call_Setup_w_Failover/testcase.yaml
+++ b/tests/failover/SysTest_Functional_Basic_Call_Setup_w_Failover/testcase.yaml
@@ -12,7 +12,5 @@ tests :
testsuite_remote_active : testsuite-remote-1.digium.internal
testsuite_remote_standby : testsuite-remote-2.digium.internal
ipv4oripv6 : ipv4
- start :
- - corosync
- - pacemaker :
- shared_ip : 10.19.139.44
+ ipv4_network_addr : 10.19.136.0
+ shared_ip : 10.19.139.44
-----------------------------------------------------------------------
--
asterisk-scf/integration/testsuite.git
More information about the asterisk-scf-commits
mailing list