Add amulet test that runs 'killall -9 mysqld' in the master node

This commit is contained in:
Felipe Reyes 2015-04-15 16:24:59 +02:00
parent 65d942d1d0
commit 36997f7d6e
2 changed files with 40 additions and 1 deletions

38
tests/30-kill-9-mysqld.py Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/python3
# test percona-cluster (3 nodes)
import basic_deployment
import time
class ThreeNode(basic_deployment.BasicDeployment):
def __init__(self):
super(ThreeNode, self).__init__(units=3)
def run(self):
super(ThreeNode, self).run()
# we are going to kill the master
old_master = self.master_unit
print('kill-9 mysqld in %s' % str(self.master_unit.info))
self.master_unit.run('sudo killall -9 mysqld')
print('looking for the new master')
i = 0
changed = False
while i < 10 and not changed:
i += 1
time.sleep(5) # give some time to pacemaker to react
new_master = self.find_master()
if (new_master and new_master.info['unit_name'] !=
old_master.info['unit_name']):
changed = True
assert changed, "The master didn't change"
assert self.is_port_open(address=self.vip), 'cannot connect to vip'
if __name__ == "__main__":
t = ThreeNode()
t.run()

View File

@ -3,6 +3,7 @@ import os
import telnetlib
import unittest
import yaml
from charmhelpers.contrib.amulet.deployment import AmuletDeployment
class BasicDeployment(unittest.TestCase):
@ -39,7 +40,7 @@ class BasicDeployment(unittest.TestCase):
cfg_percona = {'sst-password': 'ubuntu',
'root-password': 't00r',
'dataset-size': '128M',
'dataset-size': '512M',
'vip': self.vip}
cfg_ha = {'debug': True,