示例#1
0
class RecoveryCreateClusterTest(unittest.TestCase):

    def setUp(self):
        Recovery.clusterList = {}
        self.recovery = Recovery()
        self.trueNodeList = ["compute1", "compute2"]
        self.falseNodeList = ["compute426", "compute321"]
        self.clusterName = "TestCluster-%s" % datetime.datetime.now().strftime("%Y/%m/%d-%H:%M")
        self.uuid = self.recovery.createCluster(self.clusterName).split(";")[1]
    
    def test_addNode_Success(self):
        self.assertEqual(self.recovery.addNode(self.uuid, self.trueNodeList).split(";")[0], "0")
    
    def test_addNode_WrongId(self):
        self.assertEqual(self.recovery.addNode("123456789", self.trueNodeList).split(";")[0], "1")
    
    def test_addNode_WrongNodeList(self):
        self.assertEqual(self.recovery.addNode("123456789", self.falseNodeList).split(";")[0], "1")
    
    def tearDown(self):
        import MySQLdb
        Recovery.clusterList = {}
        dbconn = MySQLdb.connect(  host = config.get("mysql", "mysql_ip"),
                                        user = config.get("mysql", "mysql_username"),
                                        passwd = config.get("mysql", "mysql_password"),
                                        db = "hass",
                                )
        db = dbconn.cursor()
        db.execute("DELETE FROM ha_node;")
        db.execute("DELETE FROM ha_cluster;")
示例#2
0
class RecoveryDeleteClusterTest(unittest.TestCase):
    def setUp(self):
        Recovery.clusterList = {}
        self.recovery = Recovery()
        self.clusterName = "TestCluster-%s" % datetime.datetime.now().strftime("%Y/%m/%d-%H:%M")
        self.uuid = self.recovery.createCluster(self.clusterName).split(";")[1]
    
    def test_deleteCluster_Sucess(self):
        self.assertEqual(self.recovery.deleteCluster(self.uuid).split(";")[0], "0")
        
    def test_deleteCluster_Exception(self):
        self.assertEqual(self.recovery.deleteCluster("123456789").split(";")[0], "1")
示例#3
0
 def setUp(self):
     Recovery.clusterList = {}
     self.recovery = Recovery()
     self.trueNodeList = ["compute1", "compute2"]
     self.falseNodeList = ["compute426", "compute321"]
     self.clusterName = "TestCluster-%s" % datetime.datetime.now().strftime("%Y/%m/%d-%H:%M")
     self.uuid = self.recovery.createCluster(self.clusterName).split(";")[1]
示例#4
0
 def setUp(self):
     Recovery.clusterList = {}
     self.recovery = Recovery()
     self.clusterName = "TestCluster-%s" % datetime.datetime.now().strftime("%Y/%m/%d-%H:%M")
     self.uuid = self.recovery.createCluster(self.clusterName).split(";")[1]