Пример #1
0
 def connectToDatabases(self, mysqlRootsPassword, statusDBName, commandsDBName, statusdbSQLFilePath, commandsDBSQLFilePath,
                        websiteUser, websiteUserPassword, endpointUser, endpointUserPassword, minCommandInterval):
     """
     Establece la conexión con la base de datos de estado y con la base de datos de comandos.
     Argumentos:
         mysqlRootsPassword: la contraseña de root de MySQL
         statusDBName: el nombre de la base de datos de estado
         statusdbSQLFilePath: la ruta del script que crea la base de datos de estado
         websiteUser: nombre de usuario que usará la web para manipular las bases de datos
         websiteUserPassword: contraseña del usuario de la web
         endpointUser: usuario que utilizará en eldpoint para manipular las bases de datos de estado. Será el único
         que puede escribir en la base de datos de estado.
         endpointUserPassword: contraseña del usuario del endpoint
     """        
     # Crear las bases de datos
     self.__rootsPassword = mysqlRootsPassword
     self.__statusDatabaseName = statusDBName
     self.__commandsDatabaseName = commandsDBName
     configurator = DBConfigurator(mysqlRootsPassword)
     configurator.runSQLScript(statusDBName, statusdbSQLFilePath)
     configurator.runSQLScript(commandsDBName, commandsDBSQLFilePath)
     # Registrar en ellas los usuarios
     configurator.addUser(websiteUser, websiteUserPassword, statusDBName, False)
     configurator.addUser(endpointUser, endpointUserPassword, statusDBName, True)
     configurator.addUser(websiteUser, websiteUserPassword, commandsDBName, True)
     configurator.addUser(endpointUser, endpointUserPassword, commandsDBName, True)
     # Crear los conectores
     self.__commandsDBConnector = CommandsDatabaseConnector(endpointUser, endpointUserPassword, 
                                                            commandsDBName, minCommandInterval) 
     self.__endpointDBConnector = ClusterEndpointDBConnector(endpointUser, endpointUserPassword, statusDBName)
Пример #2
0
 def connectToDatabases(self, mysqlRootsPassword, statusDBName, commandsDBName, statusdbSQLFilePath, commandsDBSQLFilePath,
                        websiteUser, websiteUserPassword, endpointUser, endpointUserPassword):
     """
     Establishes a connection with the system status database.
     Args:
         mysqlRootsPassword: MySQL root's password
         statusDBName: the status database name
         statusdbSQLFilePath: the database schema definition SQL file path
         websiteUser: the website user's name. 
         websiteUserPassword: the website user's password
         endpointUser: the update user's name. This user will have ALL privileges on the status database.
         endpointUserPassword: the update user's password.
     """        
     # Create the status database
     self.__rootsPassword = mysqlRootsPassword
     self.__statusDatabaseName = statusDBName
     self.__commandsDatabaseName = commandsDBName
     configurator = DBConfigurator(mysqlRootsPassword)
     configurator.runSQLScript(statusDBName, statusdbSQLFilePath)
     configurator.runSQLScript(commandsDBName, commandsDBSQLFilePath)
     # Register the website and the endpoint users
     configurator.addUser(websiteUser, websiteUserPassword, statusDBName, False)
     configurator.addUser(endpointUser, endpointUserPassword, statusDBName, True)
     configurator.addUser(websiteUser, websiteUserPassword, commandsDBName, True)
     configurator.addUser(endpointUser, endpointUserPassword, commandsDBName, True)
     # Create the database connectors
     self.__commandsDBConnector = CommandsDatabaseConnector(endpointUser, endpointUserPassword, 
                                                            commandsDBName, 1) 
     self.__writer = SystemStatusDatabaseWriter(endpointUser, endpointUserPassword, statusDBName)
     # Connect to the database
     self.__writer.connect()
     self.__commandsDBConnector.connect()
Пример #3
0
 def setUp(self):
     dbConfigurator = DBConfigurator("")
     dbConfigurator.runSQLScript("SystemStatusDBTest", "./SystemStatusDBTest.sql")
     dbConfigurator.addUser("website", "cygnuscloud", "SystemStatusDBTest", False)
     dbConfigurator.addUser("statusDBUpdater", "cygnuscloud", "SystemStatusDBTest", True)
     self.__reader = SystemStatusDatabaseReader("website", "cygnuscloud", "SystemStatusDBTest")
     self.__reader.connect()
     self.__writer = SystemStatusDatabaseWriter("statusDBUpdater", "cygnuscloud", "SystemStatusDBTest")
     self.__writer.connect()
 def setUp(self):
     '''
     This method will be ran before EVERY unit test.
     '''
     # Create the database
     dbConfigurator = DBConfigurator("")
     dbConfigurator.runSQLScript("ClusterServerDBTest", "./ClusterServerDBTest.sql")
     # Add a user to it
     dbConfigurator.addUser("cygnuscloud", "cygnuscloud", "ClusterServerDBTest")
     self.__connector = ClusterServerDatabaseConnector("cygnuscloud", "cygnuscloud", "ClusterServerDBTest")     
 def setUp(self):
     '''
     This method will be ran before EVERY unit test.
     '''
     # Create the database
     dbConfigurator = DBConfigurator("")
     dbConfigurator.runSQLScript("ImageRepositoryDBTest", "./ImageRepositoryDBTest.sql")
     # Add a user to it
     dbConfigurator.addUser("cygnuscloud", "cygnuscloud", "ImageRepositoryDBTest")
     self.__connector = ImageRepositoryDBConnector("cygnuscloud", "cygnuscloud", "ImageRepositoryDBTest")     
     self.__connector.connect()   
Пример #6
0
class CommandsDBTests(unittest.TestCase):
    def setUp(self):
        # Create the database
        self.__dbConfigurator = DBConfigurator("")
        self.__dbConfigurator.runSQLScript("CommandsDBTest",
                                           "./CommandsDBTest.sql")
        # Add a user to it
        self.__dbConfigurator.addUser("cygnuscloud", "cygnuscloud",
                                      "CommandsDBTest")
        self.__connector = CommandsDatabaseConnector("cygnuscloud",
                                                     "cygnuscloud",
                                                     "CommandsDBTest", 1)
        self.__connector.connect()

    def tearDown(self):
        self.__connector.disconnect()
        self.__dbConfigurator.dropDatabase("CommandsDBTest")

    def test_addAndRemoveCommands(self):
        self.__connector.addCommand(1, 0, "command arguments")
        result = self.__connector.popCommand()
        expectedResult = (1, 0, 'command arguments')
        self.assertEquals(result[0][0], expectedResult[0],
                          "either addCommand or popCommand does not work")
        self.assertEquals(result[1], expectedResult[1],
                          "either addCommand or popCommand does not work")
        self.assertEquals(result[2], expectedResult[2],
                          "either addCommand or popCommand does not work")
        result = self.__connector.addCommand(1, 1, "command2 arguments")
        self.assertEquals(result, None, "addCommand does not work")
        self.__connector.addCommand(2, 2, "command4 arguments")
        self.__connector.addCommand(3, 3, "command5 arguments")
        expectedResults = [(2, 2, "command4 arguments"),
                           (3, 3, "command5 arguments")]
        for expectedResult in expectedResults:
            result = self.__connector.popCommand()
            self.assertEquals(result[0][0], expectedResult[0],
                              "either addCommand or popCommand does not work")
            self.assertEquals(result[1], expectedResult[1],
                              "either addCommand or popCommand does not work")
            self.assertEquals(result[2], expectedResult[2],
                              "either addCommand or popCommand does not work")

    def test_addAndRemoveCommandOutputs(self):
        commandID = self.__connector.addCommand(1, 0, "command arguments")
        self.__connector.popCommand()
        self.__connector.addCommandOutput(commandID, 0, "commandOutput")
        result = self.__connector.getCommandOutput(commandID)
        expectedResult = (0, "commandOutput")
        self.assertEquals(
            result, expectedResult,
            "either addCommandOutput or getCommandOutput does not work")
 def setUp(self):
     '''
     This method will be ran before EVERY unit test.
     '''
     # Create the database
     dbConfigurator = DBConfigurator("")
     dbConfigurator.runSQLScript("ClusterServerDBTest",
                                 "./ClusterServerDBTest.sql")
     # Add a user to it
     dbConfigurator.addUser("cygnuscloud", "cygnuscloud",
                            "ClusterServerDBTest")
     self.__connector = ClusterServerDatabaseConnector(
         "cygnuscloud", "cygnuscloud", "ClusterServerDBTest")
Пример #8
0
 def setUp(self):
     '''
     This method will be ran before EVERY unit test.
     '''
     # Create the database
     dbConfigurator = DBConfigurator("")
     dbConfigurator.runSQLScript("ImageRepositoryDBTest",
                                 "./ImageRepositoryDBTest.sql")
     # Add a user to it
     dbConfigurator.addUser("cygnuscloud", "cygnuscloud",
                            "ImageRepositoryDBTest")
     self.__connector = ImageRepositoryDBConnector("cygnuscloud",
                                                   "cygnuscloud",
                                                   "ImageRepositoryDBTest")
     self.__connector.connect()
Пример #9
0
 def setUp(self):
     dbConfigurator = DBConfigurator("")
     dbConfigurator.runSQLScript("SystemStatusDBTest",
                                 "./SystemStatusDBTest.sql")
     dbConfigurator.addUser("website", "cygnuscloud", "SystemStatusDBTest",
                            False)
     dbConfigurator.addUser("statusDBUpdater", "cygnuscloud",
                            "SystemStatusDBTest", True)
     self.__reader = SystemStatusDatabaseReader("website", "cygnuscloud",
                                                "SystemStatusDBTest")
     self.__reader.connect()
     self.__writer = SystemStatusDatabaseWriter("statusDBUpdater",
                                                "cygnuscloud",
                                                "SystemStatusDBTest")
     self.__writer.connect()
Пример #10
0
 def connectToDatabase(self, rootsPassword, databaseName, websiteUser, websiteUserPassword, updateUser, updateUserPassword):
     # Create the status database
     self.__rootsPassword = rootsPassword
     self.__databaseName = databaseName
     configurator = DBConfigurator(rootsPassword)
     configurator.runSQLScript(databaseName, "../../database/SystemStatusDB.sql")
     # Register the website and the update users
     configurator.addUser(websiteUser, websiteUserPassword, databaseName, False)
     configurator.addUser(updateUser, updateUserPassword, databaseName, True)
     # Create the database connectors
     self.__reader = SystemStatusDatabaseReader(websiteUser, websiteUserPassword, databaseName)
     self.__writer = SystemStatusDatabaseWriter(updateUser, updateUserPassword, databaseName)
     # Connect to the database
     self.__reader.connect()
     self.__writer.connect()
Пример #11
0
 def connectToDatabase(self, mysqlRootsPassword, dbName, dbUser, dbPassword, scriptPath):
     """
     Establishes a connection with the cluster server database.
     Args:
         mysqlRootsPassword: MySQL root's password
         dbName: the cluster server database's name
         dbUser: the cluster server database's user name
         dbPassword: the cluster server database's user password
         scriptPath: the cluster server database's initialization script path
     """
     configurator = DBConfigurator(mysqlRootsPassword)
     configurator.runSQLScript(dbName, scriptPath)
     configurator.addUser(dbUser, dbPassword, dbName, True)
     self.__dbConnector = ClusterServerDatabaseConnector(dbUser, dbPassword, dbName)
     self.__dbConnector.connect()
     self.__dbConnector.resetVMServersStatus()
Пример #12
0
 def connectToDatabase(self, mysqlRootsPassword, dbName, dbUser, dbPassword,
                       scriptPath):
     """
     Establishes a connection with the cluster server database.
     Args:
         mysqlRootsPassword: MySQL root's password
         dbName: the cluster server database's name
         dbUser: the cluster server database's user name
         dbPassword: the cluster server database's user password
         scriptPath: the cluster server database's initialization script path
     """
     configurator = DBConfigurator(mysqlRootsPassword)
     configurator.runSQLScript(dbName, scriptPath)
     configurator.addUser(dbUser, dbPassword, dbName, True)
     self.__dbConnector = ClusterServerDatabaseConnector(
         dbUser, dbPassword, dbName)
     self.__dbConnector.connect()
     self.__dbConnector.resetVMServersStatus()
Пример #13
0
 def connectToDatabases(self, mysqlRootsPassword, statusDBName,
                        commandsDBName, statusdbSQLFilePath,
                        commandsDBSQLFilePath, websiteUser,
                        websiteUserPassword, endpointUser,
                        endpointUserPassword):
     """
     Establishes a connection with the system status database.
     Args:
         mysqlRootsPassword: MySQL root's password
         statusDBName: the status database name
         statusdbSQLFilePath: the database schema definition SQL file path
         websiteUser: the website user's name. 
         websiteUserPassword: the website user's password
         endpointUser: the update user's name. This user will have ALL privileges on the status database.
         endpointUserPassword: the update user's password.
     """
     # Create the status database
     self.__rootsPassword = mysqlRootsPassword
     self.__statusDatabaseName = statusDBName
     self.__commandsDatabaseName = commandsDBName
     configurator = DBConfigurator(mysqlRootsPassword)
     configurator.runSQLScript(statusDBName, statusdbSQLFilePath)
     configurator.runSQLScript(commandsDBName, commandsDBSQLFilePath)
     # Register the website and the endpoint users
     configurator.addUser(websiteUser, websiteUserPassword, statusDBName,
                          False)
     configurator.addUser(endpointUser, endpointUserPassword, statusDBName,
                          True)
     configurator.addUser(websiteUser, websiteUserPassword, commandsDBName,
                          True)
     configurator.addUser(endpointUser, endpointUserPassword,
                          commandsDBName, True)
     # Create the database connectors
     self.__commandsDBConnector = CommandsDatabaseConnector(
         endpointUser, endpointUserPassword, commandsDBName, 1)
     self.__writer = SystemStatusDatabaseWriter(endpointUser,
                                                endpointUserPassword,
                                                statusDBName)
     # Connect to the database
     self.__writer.connect()
     self.__commandsDBConnector.connect()
Пример #14
0
class CommandsDBTests(unittest.TestCase):
    
    def setUp(self):
        # Create the database
        self.__dbConfigurator = DBConfigurator("")
        self.__dbConfigurator.runSQLScript("CommandsDBTest", "./CommandsDBTest.sql")
        # Add a user to it
        self.__dbConfigurator.addUser("cygnuscloud", "cygnuscloud", "CommandsDBTest")
        self.__connector = CommandsDatabaseConnector("cygnuscloud", "cygnuscloud", "CommandsDBTest", 1)     
        self.__connector.connect()   
        
    def tearDown(self):
        self.__connector.disconnect()
        self.__dbConfigurator.dropDatabase("CommandsDBTest")
        
    def test_addAndRemoveCommands(self):
        self.__connector.addCommand(1, 0, "command arguments")
        result = self.__connector.popCommand()
        expectedResult = (1, 0, 'command arguments')
        self.assertEquals(result[0][0], expectedResult[0], "either addCommand or popCommand does not work")
        self.assertEquals(result[1], expectedResult[1], "either addCommand or popCommand does not work")
        self.assertEquals(result[2], expectedResult[2], "either addCommand or popCommand does not work")
        result = self.__connector.addCommand(1, 1, "command2 arguments")
        self.assertEquals(result, None, "addCommand does not work")
        self.__connector.addCommand(2, 2, "command4 arguments")
        self.__connector.addCommand(3, 3, "command5 arguments")
        expectedResults = [(2, 2, "command4 arguments"), (3, 3, "command5 arguments")]
        for expectedResult in expectedResults :
            result = self.__connector.popCommand()
            self.assertEquals(result[0][0], expectedResult[0], "either addCommand or popCommand does not work")
            self.assertEquals(result[1], expectedResult[1], "either addCommand or popCommand does not work")
            self.assertEquals(result[2], expectedResult[2], "either addCommand or popCommand does not work")
            
    def test_addAndRemoveCommandOutputs(self):
        commandID = self.__connector.addCommand(1, 0, "command arguments")
        self.__connector.popCommand()
        self.__connector.addCommandOutput(commandID, 0, "commandOutput")
        result = self.__connector.getCommandOutput(commandID)
        expectedResult = (0, "commandOutput")
        self.assertEquals(result, expectedResult, "either addCommandOutput or getCommandOutput does not work")
Пример #15
0
 def connectToDatabases(self, mysqlRootsPassword, statusDBName,
                        commandsDBName, statusdbSQLFilePath,
                        commandsDBSQLFilePath, websiteUser,
                        websiteUserPassword, endpointUser,
                        endpointUserPassword, minCommandInterval):
     """
     Establece la conexión con la base de datos de estado y con la base de datos de comandos.
     Argumentos:
         mysqlRootsPassword: la contraseña de root de MySQL
         statusDBName: el nombre de la base de datos de estado
         statusdbSQLFilePath: la ruta del script que crea la base de datos de estado
         websiteUser: nombre de usuario que usará la web para manipular las bases de datos
         websiteUserPassword: contraseña del usuario de la web
         endpointUser: usuario que utilizará en eldpoint para manipular las bases de datos de estado. Será el único
         que puede escribir en la base de datos de estado.
         endpointUserPassword: contraseña del usuario del endpoint
     """
     # Crear las bases de datos
     self.__rootsPassword = mysqlRootsPassword
     self.__statusDatabaseName = statusDBName
     self.__commandsDatabaseName = commandsDBName
     configurator = DBConfigurator(mysqlRootsPassword)
     configurator.runSQLScript(statusDBName, statusdbSQLFilePath)
     configurator.runSQLScript(commandsDBName, commandsDBSQLFilePath)
     # Registrar en ellas los usuarios
     configurator.addUser(websiteUser, websiteUserPassword, statusDBName,
                          False)
     configurator.addUser(endpointUser, endpointUserPassword, statusDBName,
                          True)
     configurator.addUser(websiteUser, websiteUserPassword, commandsDBName,
                          True)
     configurator.addUser(endpointUser, endpointUserPassword,
                          commandsDBName, True)
     # Crear los conectores
     self.__commandsDBConnector = CommandsDatabaseConnector(
         endpointUser, endpointUserPassword, commandsDBName,
         minCommandInterval)
     self.__endpointDBConnector = ClusterEndpointDBConnector(
         endpointUser, endpointUserPassword, statusDBName)
Пример #16
0
 def connectToDatabase(self, rootsPassword, databaseName, websiteUser,
                       websiteUserPassword, updateUser, updateUserPassword):
     # Create the status database
     self.__rootsPassword = rootsPassword
     self.__databaseName = databaseName
     configurator = DBConfigurator(rootsPassword)
     configurator.runSQLScript(databaseName,
                               "../../database/SystemStatusDB.sql")
     # Register the website and the update users
     configurator.addUser(websiteUser, websiteUserPassword, databaseName,
                          False)
     configurator.addUser(updateUser, updateUserPassword, databaseName,
                          True)
     # Create the database connectors
     self.__reader = SystemStatusDatabaseReader(websiteUser,
                                                websiteUserPassword,
                                                databaseName)
     self.__writer = SystemStatusDatabaseWriter(updateUser,
                                                updateUserPassword,
                                                databaseName)
     # Connect to the database
     self.__reader.connect()
     self.__writer.connect()
Пример #17
0
        self.assertEquals(l1, l2, "Not All VM deleted")
        
    def test_createType(self):
        userM = UserManagement("CygnusCloud","cygnuscloud2012","WebServerDBTest",1)
        typeId = userM.createType("TypeTest")
        self.assertTrue(userM.isTypeExists(typeId), "type not created")
 
    def test_deleteType(self):
        userM = UserManagement("CygnusCloud","cygnuscloud2012","WebServerDBTest",1)
        userM.deleteType(4)
        self.assertFalse(userM.isTypeExists(4), "type not deleted") 
        
    def test_groupIds(self):
        userM = UserManagement("CygnusCloud","cygnuscloud2012","WebServerDBTest",1)
        l1 = userM.getGroupId("VMName1")
        l2 = [1]
        self.assertEquals(l1, l2, "Not Same groups")     
        
    def test_userIds(self):
        userM = UserManagement("CygnusCloud","cygnuscloud2012","WebServerDBTest",1)
        l1 = userM.getUsersId(1)
        l2 = [2,3,5]
        self.assertEquals(l1, l2, "Not Same users")    
        
if __name__ == "__main__":
    #Cargamos el script de prueba
    dbUtils = DBConfigurator("")
    dbUtils.runSQLScript("WebServerDBTest", "./WebServerDBTest.sql")
    dbUtils.addUser("CygnusCloud","cygnuscloud2012", "WebServerDBTest")
    unittest.main()
Пример #18
0
class DBWebServerTests(unittest.TestCase):
    '''
        Clase encargada de realizar los test unitarios asociados 
    '''
    def setUp(self):
        self.__dbConfigurator = DBConfigurator("")
        self.__dbConfigurator.runSQLScript("VMServerDBTest",
                                           "./VMServerDBTest.sql")
        self.__dbConfigurator.addUser("CygnusCloud", "cygnuscloud2012",
                                      "VMServerDBTest", True)
        self.__dbConnector = VMServerDBConnector("CygnusCloud",
                                                 "cygnuscloud2012",
                                                 "VMServerDBTest")

    def tearDown(self):
        self.__dbConnector.disconnect()
        self.__dbConfigurator.dropDatabase("VMServerDBTest")

    def test_getImages(self):
        # Instanciamos la clase
        l1 = self.__dbConnector.getImages()
        l2 = [1, 2, 3, 4]
        self.assertEquals(l1, l2, "The image ID lists do not match")

    def test_getName(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getName(1)
        n2 = "VMName1"
        self.assertEquals(n1, n2, "Not same image name")

    def test_getImagePath(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getImagePath(1)
        n2 = "./VMName1/"
        self.assertEquals(n1, n2, "Not same image path")

    def test_getFileConfigPath(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getFileConfigPath(1)
        n2 = "./VMName1/"
        self.assertEquals(n1, n2, "Not same image path")

    def test_setImageDataPath(self):
        # Instanciamos la clase
        self.__dbConnector.setImageDataPath(1, "./VMName1Test/")
        n1 = self.__dbConnector.getImagePath(1)
        n2 = "./VMName1Test/"
        self.assertEquals(n1, n2, "Not change image path")

    def test_createImage(self):
        # Instanciamos la clase
        imageId = self.__dbConnector.createImage(123, "VMNameTest",
                                                 "./VMNameTest/",
                                                 "./OSImagePath1",
                                                 "./VMNameTest/")
        self.assertTrue(self.__dbConnector.doesImageExist(imageId),
                        "Not image regist")
        self.__dbConnector.deleteImage(imageId)

    def test_getRunningPorts(self):
        # Instanciamos la clase
        l1 = self.__dbConnector.getRunningPorts()
        l2 = [1, 2, 3, 4]
        self.assertEquals(l1, l2, "Not same ports")

    def test_getUsers(self):
        # Instanciamos la clase
        l1 = self.__dbConnector.getUsers()
        l2 = [1, 2, 3]
        self.assertEquals(l1, l2, "Not same users")

    def test_getAssignedVM(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getAssignedVM(1)
        n2 = 1
        self.assertEquals(n1, n2, "Not same VM")

    def test_getAssignedVMNameInDomain(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getAssignedVMNameInDomain(2)
        n2 = "VMName1"
        self.assertEquals(n1, n2, "Not same VM Name")

    def test_getMachineDataPath(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getMachineDataPath(2)
        n2 = "./VMNameCopy1"
        self.assertEquals(n1, n2, "Not same VM path")

    def test_getMACAddressInDomain(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getMACAddress(3)
        n2 = "2C:00:00:00:00:02"
        self.assertEquals(n1, n2, "Not same VM MAC")

    def test_getPasswordInDomain(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getPassword(3)
        n2 = "1234567890Test"
        self.assertEquals(n1, n2, "Not same VM Pass")

    def test_registerVMResources(self):
        # Instanciamos la clase
        portId = self.__dbConnector.registerVMResources(
            "VMName123", 2, 23, "testPass", 3, 100, "./VMNameCopyTest",
            "./OSImagePath1", "testMac", "testUUID")
        self.assertTrue(self.__dbConnector.doesVMExist(portId),
                        "Not VM register")
        self.__dbConnector.unregisterVMResources("VMName123")
        self.assertFalse(self.__dbConnector.doesVMExist(23),
                         "Not VM unregisted")

    def test_extractFreeMACandUUID(self):
        # Instanciamos la clase
        (_uuid1, mac1) = self.__dbConnector.extractFreeMACAndUUID()
        (_uuid2, mac2) = ("9a47c734-5e5f-11e2-981b-001f16b99e1d",
                          "2C:00:00:00:00:00")
        self.assertEquals(mac1, mac2, "Not same MAC")

    def test_extractFreeVNCPort(self):
        # Instanciamos la clase
        vncPort1 = self.__dbConnector.extractFreeVNCPort()
        vncPort2 = (15000)
        self.assertEquals(vncPort1, vncPort2, "Not same VNCPort")

    def test_getVMsConnectionData(self):
        result = self.__dbConnector.getVMsConnectionData()
        expectedResult = [{
            "UserID": 1,
            "VMID": 1,
            "VMName": "VMName11",
            "VNCPort": 1,
            "VNCPass": "******"
        }, {
            "UserID": 1,
            "VMID": 1,
            "VMName": "VMName22",
            "VNCPort": 2,
            "VNCPass": "******"
        }, {
            "UserID": 2,
            "VMID": 1,
            "VMName": "VMName33",
            "VNCPort": 3,
            "VNCPass": "******"
        }, {
            "UserID": 3,
            "VMID": 1,
            "VMName": "VMName44",
            "VNCPort": 4,
            "VNCPass": "******"
        }]
        self.assertEquals(result, expectedResult,
                          "getVMsConnectionData does not work")

    def test_getVMBootCommand(self):
        result = self.__dbConnector.getVMBootCommand("VMName44")
        expectedResult = "123"
        self.assertEquals(result, expectedResult,
                          "getVMBootCommand does not work")
        result = self.__dbConnector.getVMBootCommand("VMName33")
        self.assertEquals(result, None, "getVMBootCommand does not work")

    def test_addVMBootCommand(self):
        self.__dbConnector.addVMBootCommand("VMName33", "1234")
        result = self.__dbConnector.getVMBootCommand("VMName33")
        self.assertEquals(result, "1234", "addVMBootCommand does not work")

    def test_getDomainImageDataPath(self):
        result = self.__dbConnector.getDomainImageDataPath("VMName33")
        expectedResult = "./VMNameCopy2"
        self.assertEquals(result, expectedResult,
                          "getDomainImageDataPath does not work")

    def test_getOSImagePath(self):
        result = self.__dbConnector.getOsImagePath(1)
        expectedResult = "./VMName1/"
        self.assertEquals(result, expectedResult,
                          "getOSImageDataPath does not work")

    def test_getRegisteredDomainNames(self):
        result = self.__dbConnector.getRegisteredDomainNames()
        expectedResult = ["VMName11", "VMName22", "VMName33", "VMName44"]
        self.assertEquals(result, expectedResult,
                          "getActiveDomainNames() does not work")
Пример #19
0
class DBWebServerTests(unittest.TestCase):
    '''
        Clase encargada de realizar los test unitarios asociados 
    '''
    
    def setUp(self):
        self.__dbConfigurator = DBConfigurator("")
        self.__dbConfigurator.runSQLScript("VMServerDBTest", "./VMServerDBTest.sql")
        self.__dbConfigurator.addUser("CygnusCloud", "cygnuscloud2012", "VMServerDBTest", True)
        self.__dbConnector = VMServerDBConnector("CygnusCloud", "cygnuscloud2012", "VMServerDBTest")
    
    def tearDown(self):
        self.__dbConnector.disconnect()
        self.__dbConfigurator.dropDatabase("VMServerDBTest")
    
    def test_getImages(self):
        # Instanciamos la clase
        l1 = self.__dbConnector.getImages()
        l2 = [1, 2, 3, 4]
        self.assertEquals(l1, l2, "The image ID lists do not match")
        
    def test_getName(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getName(1)
        n2 = "VMName1"
        self.assertEquals(n1, n2, "Not same image name")
        
    def test_getImagePath(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getImagePath(1)
        n2 = "./VMName1/"
        self.assertEquals(n1, n2, "Not same image path")   
        
    def test_getFileConfigPath(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getFileConfigPath(1)
        n2 = "./VMName1/"
        self.assertEquals(n1, n2, "Not same image path")

    def test_setImageDataPath(self):
        # Instanciamos la clase
        self.__dbConnector.setImageDataPath(1, "./VMName1Test/")
        n1 = self.__dbConnector.getImagePath(1)
        n2 = "./VMName1Test/"
        self.assertEquals(n1, n2, "Not change image path")  
        
    def test_createImage(self):
        # Instanciamos la clase
        imageId = self.__dbConnector.createImage(123, "VMNameTest", "./VMNameTest/", "./OSImagePath1", "./VMNameTest/")
        self.assertTrue(self.__dbConnector.doesImageExist(imageId), "Not image regist")  
        self.__dbConnector.deleteImage(imageId)    
    
    def test_getRunningPorts(self):
        # Instanciamos la clase
        l1 = self.__dbConnector.getRunningPorts()
        l2 = [1, 2, 3, 4]
        self.assertEquals(l1, l2, "Not same ports") 
        
    def test_getUsers(self):
        # Instanciamos la clase
        l1 = self.__dbConnector.getUsers()
        l2 = [1, 2, 3]
        self.assertEquals(l1, l2, "Not same users")

    def test_getAssignedVM(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getAssignedVM(1)
        n2 = 1
        self.assertEquals(n1, n2, "Not same VM") 
        
    def test_getAssignedVMNameInDomain(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getAssignedVMNameInDomain(2)
        n2 = "VMName1"
        self.assertEquals(n1, n2, "Not same VM Name")   
        
    def test_getMachineDataPath(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getMachineDataPath(2)
        n2 = "./VMNameCopy1"
        self.assertEquals(n1, n2, "Not same VM path")
 
    def test_getMACAddressInDomain(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getMACAddress(3)
        n2 = "2C:00:00:00:00:02"
        self.assertEquals(n1, n2, "Not same VM MAC") 
        
    def test_getPasswordInDomain(self):
        # Instanciamos la clase
        n1 = self.__dbConnector.getPassword(3)
        n2 = "1234567890Test"
        self.assertEquals(n1, n2, "Not same VM Pass")
        
    def test_registerVMResources(self):
        # Instanciamos la clase
        portId = self.__dbConnector.registerVMResources("VMName123", 2,
            23, "testPass", 3, 100, "./VMNameCopyTest", "./OSImagePath1", "testMac", "testUUID")
        self.assertTrue(self.__dbConnector.doesVMExist(portId), "Not VM register") 
        self.__dbConnector.unregisterVMResources("VMName123")
        self.assertFalse(self.__dbConnector.doesVMExist(23), "Not VM unregisted")
        
    def test_extractFreeMACandUUID(self):
        # Instanciamos la clase
        (_uuid1, mac1) = self.__dbConnector.extractFreeMACAndUUID()
        (_uuid2, mac2) = ("9a47c734-5e5f-11e2-981b-001f16b99e1d", "2C:00:00:00:00:00")
        self.assertEquals(mac1, mac2, "Not same MAC")
    
    def test_extractFreeVNCPort(self):
        # Instanciamos la clase
        vncPort1 = self.__dbConnector.extractFreeVNCPort()
        vncPort2 = (15000)
        self.assertEquals(vncPort1, vncPort2, "Not same VNCPort")
             
    def test_getVMsConnectionData(self):
        result = self.__dbConnector.getVMsConnectionData()
        expectedResult = [
                          {"UserID": 1, "VMID": 1, "VMName" :"VMName11", "VNCPort" : 1, "VNCPass" : "1234567890"},
                          {"UserID": 1, "VMID": 1, "VMName" :"VMName22", "VNCPort" : 2, "VNCPass" : "1234567890"},
                          {"UserID": 2, "VMID": 1, "VMName" :"VMName33", "VNCPort" : 3, "VNCPass" : "1234567890Test"},
                          {"UserID": 3, "VMID": 1, "VMName" :"VMName44", "VNCPort" : 4, "VNCPass" : "1234567890"}
                          ]
        self.assertEquals(result, expectedResult, "getVMsConnectionData does not work")
        
    def test_getVMBootCommand(self):
        result = self.__dbConnector.getVMBootCommand("VMName44")
        expectedResult = "123"
        self.assertEquals(result, expectedResult, "getVMBootCommand does not work")
        result = self.__dbConnector.getVMBootCommand("VMName33")
        self.assertEquals(result, None, "getVMBootCommand does not work")
        
    def test_addVMBootCommand(self):
        self.__dbConnector.addVMBootCommand("VMName33", "1234")
        result = self.__dbConnector.getVMBootCommand("VMName33")
        self.assertEquals(result, "1234", "addVMBootCommand does not work")
        
    def test_getDomainImageDataPath(self):
        result = self.__dbConnector.getDomainImageDataPath("VMName33")
        expectedResult = "./VMNameCopy2"
        self.assertEquals(result, expectedResult, "getDomainImageDataPath does not work")
        
    def test_getOSImagePath(self):
        result = self.__dbConnector.getOsImagePath(1)
        expectedResult = "./VMName1/"
        self.assertEquals(result, expectedResult, "getOSImageDataPath does not work")  
        
    def test_getRegisteredDomainNames(self):
        result = self.__dbConnector.getRegisteredDomainNames()
        expectedResult = ["VMName11", "VMName22", "VMName33", "VMName44"]
        self.assertEquals(result, expectedResult, "getActiveDomainNames() does not work")      
Пример #20
0
class DBWebServerTests(unittest.TestCase):
    '''
        Clase con las pruebas unitarias de la base de datos del servidor de máquinas
        virtuales
    '''    
    def setUp(self):
        self.__dbConfigurator = DBConfigurator("")
        self.__dbConfigurator.runSQLScript("VMServerDBTest", "./VMServerDBTest.sql")
        self.__dbConfigurator.addUser("CygnusCloud", "cygnuscloud2012", "VMServerDBTest", True)
        self.__dbConnector = VMServerDBConnector("CygnusCloud", "cygnuscloud2012", "VMServerDBTest")
    
    def tearDown(self):
        self.__dbConnector.disconnect()
        self.__dbConfigurator.dropDatabase("VMServerDBTest")
     
    def test_getImages(self):
        result = self.__dbConnector.getImageIDs()
        expectedResult = [1, 2, 3, 4]
        self.assertEquals(result, expectedResult, "getImageIDs() error")
          
            
    def test_getDataImagePath(self):
        result = self.__dbConnector.getDataImagePath(1)
        expectedResult = "./VMName1/Data.qcow2"
        self.assertEquals(result, expectedResult, "getDataImagePath() error")   
          
    def test_getOSImagePath(self):
        result = self.__dbConnector.getOSImagePath(1)
        expectedResult = "./VMName1/OS.qcow2"
        self.assertEquals(result, expectedResult, "getOSImagePath() error")   
          
    def test_getDefinitionFilePath(self):
        result = self.__dbConnector.getDefinitionFilePath(1)
        expectedResult = "./VMName1/Definition.xml"
        self.assertEquals(result, expectedResult, "getDefinitionFilePath() error")   
           
    def test_createImage(self):
        self.__dbConnector.createImage(123, "Image/OS.qcow2", "Image/Data.qcow2", "Image/Definition.xml", 0)
        result = self.__dbConnector.getOSImagePath(123)
        expectedResult = "Image/OS.qcow2"
        self.assertEquals(result, expectedResult, "createImage() error")   
        result = self.__dbConnector.getDataImagePath(123)
        expectedResult = "Image/Data.qcow2"
        self.assertEquals(result, expectedResult, "createImage() error")  
        result = self.__dbConnector.getDefinitionFilePath(123)
        expectedResult = "Image/Definition.xml"
        self.assertEquals(result, expectedResult, "createImage() error")   
        result = self.__dbConnector.getBootableFlag(123)
        expectedResult = False
        self.assertEquals(result, expectedResult, "createImage() error")   
           
    def test_deleteImage(self):
        self.__dbConnector.deleteImage(1)
        result = self.__dbConnector.getOSImagePath(1)
        expectedResult = None
        self.assertEquals(result, expectedResult, "deleteImage() error")  
           
    def test_getDomainImageID(self):
        result = self.__dbConnector.getDomainImageID("1_1")
        expectedResult = 1
        self.assertEquals(result, expectedResult, "getDomainImageID() error") 
           
    def test_getDomainDataImagePath(self):
        result = self.__dbConnector.getDomainDataImagePath("1_1")
        expectedResult = "./DataImagePath1"
        self.assertEquals(result, expectedResult, "getDomainDataImagePath() error") 
       
    def test_getDomainOSImagePath(self):
        result = self.__dbConnector.getDomainOSImagePath("1_1")
        expectedResult = "./OSImagePath1"
        self.assertEquals(result, expectedResult, "getDomainOSImagePath() error") 
           
    def test_getDomainMACAddress(self):
        result = self.__dbConnector.getDomainMACAddress("1_1")
        expectedResult = "2C:00:00:00:00:00"
        self.assertEquals(result, expectedResult, "getDomainMACAddress() error") 
           
    def test_getDomainUUID(self):
        result = self.__dbConnector.getDomainUUID("1_1")
        expectedResult = "fce02cff-5d6d-11e2-a3f0-001f16b99e1d"
        self.assertEquals(result, expectedResult, "getDomainUUID() error") 
          
    def test_getDomainVNCPassword(self):
        result = self.__dbConnector.getDomainVNCPassword("1_1")
        expectedResult = "12134567890"
        self.assertEquals(result, expectedResult, "getDomainVNCPassword() error") 
          
    def test_getWebsockifyDaemonPID(self):
        result = self.__dbConnector.getWebsockifyDaemonPID("1_1")
        expectedResult = 1
        self.assertEquals(result, expectedResult, "getWebsockifyDaemonPID() error") 
   
    def test_getDomainNameFromVNCPort(self):
        result = self.__dbConnector.getDomainNameFromVNCPort(1)
        expectedResult = "1_1"
        self.assertEquals(result, expectedResult, "getDomainNameFromVNCPort() error") 
          
    def test_registerVMResources(self):
        self.__dbConnector.registerVMResources("1_20", 1, 2000, "aaa", 1, 2, "OS_20.qcow2", "Data_20.qcow2", "MAC_20", "UUID_20")
        result = self.__dbConnector.getDomainNameFromVNCPort(2000)
        expectedResult = "1_20"
        self.assertEquals(result, expectedResult, "registerVMSResources() error")
        result = self.__dbConnector.getDomainVNCPassword("1_20")
        expectedResult = "aaa"
        self.assertEquals(result, expectedResult, "registerVMSResources() error")
        result = self.__dbConnector.getDomainOwnerID("1_20")
        expectedResult = 1
        self.assertEquals(result, expectedResult, "registerVMSResources() error")
        result = self.__dbConnector.getWebsockifyDaemonPID("1_20")
        expectedResult = 2
        self.assertEquals(result, expectedResult, "registerVMSResources() error")
        result = self.__dbConnector.getDomainOSImagePath("1_20")
        expectedResult = "OS_20.qcow2"
        self.assertEquals(result, expectedResult, "registerVMSResources() error")
        result = self.__dbConnector.getDomainDataImagePath("1_20")
        expectedResult = "Data_20.qcow2"
        self.assertEquals(result, expectedResult, "registerVMSResources() error")
        result = self.__dbConnector.getDomainMACAddress("1_20")
        expectedResult = "MAC_20"
        self.assertEquals(result, expectedResult, "registerVMSResources() error")
        result = self.__dbConnector.getDomainUUID("1_20")
        expectedResult = "UUID_20"
        self.assertEquals(result, expectedResult, "registerVMSResources() error")
          
    def test_unregisterDomainResources(self):
        self.__dbConnector.unregisterDomainResources("1_1")
        result = self.__dbConnector.getDomainOSImagePath("1_1")
        expectedResult = None
        self.assertEquals(result, expectedResult, "unregisterDomainResources() error")
          
    def test_getOwnerID(self):
        result = self.__dbConnector.getDomainOwnerID("1_1")
        expectedResult = 1
        self.assertEquals(result, expectedResult, "getOwnerID() error")
         
    def test_getVMBootCommand(self):
        result = self.__dbConnector.getVMBootCommand("4_4")
        expectedResult = "Command4"
        self.assertEquals(result, expectedResult, "getVMBootCommand() error")
        result = self.__dbConnector.getVMBootCommand("3_3")
        self.assertEquals(result, "Command3", "getVMBootCommand() error")
  
         
    def test_addVMBootCommand(self):
        self.__dbConnector.registerVMResources("5_5", 1, 1, "123", 1, 1, "os", "data", "mac", "uuid")
        self.__dbConnector.addVMBootCommand("5_5", "1234")
        result = self.__dbConnector.getVMBootCommand("5_5")
        self.assertEquals(result, "1234", "addVMBootCommand() error")
  
    def test_getBootableFlag(self):
        result = self.__dbConnector.getBootableFlag(2)
        expectedResult = True
        self.assertEquals(result, expectedResult, "getBootableFlag() error")
          
    def test_getRegisteredDomainNames(self):
        result = self.__dbConnector.getRegisteredDomainNames()
        expectedResult = ["1_1", "2_2", "3_3", "4_4"]
        self.assertEquals(result, expectedResult, "getRegisteredDomainNames() error")    
         
    def test_transferQueue(self):
        expectedResult = dict()
        expectedResult["Transfer_Type"] = TRANSFER_T.STORE_IMAGE
        expectedResult["FTPTimeout"] = 100
        expectedResult["TargetImageID"] = 2
        expectedResult["RepositoryIP"] = "192.168.0.1"
        expectedResult["RepositoryPort"] = 3000
        expectedResult["CommandID"] = "1"
        expectedResult["SourceFilePath"] ="/tmp/foo.zip"
        self.__dbConnector.addToTransferQueue(expectedResult)
        result = self.__dbConnector.peekFromTransferQueue()
        self.assertEquals(result, expectedResult, "addToTransferQueue() error")
        self.__dbConnector.removeFirstElementFromTransferQueue()
        expectedResult = dict()
        expectedResult["Transfer_Type"] = TRANSFER_T.EDIT_IMAGE
        expectedResult["FTPTimeout"] = 100
        expectedResult["SourceImageID"] = 2
        expectedResult["RepositoryIP"] = "192.168.0.1"
        expectedResult["RepositoryPort"] = 3000
        expectedResult["CommandID"] = "1"
        expectedResult["UserID"] = 1
        self.__dbConnector.addToTransferQueue(expectedResult)
        result = self.__dbConnector.peekFromTransferQueue()
        self.assertEquals(result, expectedResult, "addToTransferQueue() error")
         
    def test_addToCompressionQueue(self):
        expectedResult = dict()
        expectedResult["Transfer_Type"] = TRANSFER_T.STORE_IMAGE
        expectedResult["CommandID"] = "1"
        expectedResult["TargetImageID"] = 1
        expectedResult["OSImagePath"] = "os.qcow"
        expectedResult["DataImagePath"] = "data.qcow2"
        expectedResult["DefinitionFilePath"] = "definition.xml"
        expectedResult["RepositoryIP"] = "192.198.0.2"
        expectedResult["RepositoryPort"] = 3000
        self.__dbConnector.addToCompressionQueue(expectedResult)
        result = self.__dbConnector.peekFromCompressionQueue()
        self.assertEquals(result, expectedResult, "addToCompressionQueue() error")
        self.__dbConnector.removeFirstElementFromCompressionQueue()
        expectedResult = dict()
        expectedResult["Transfer_Type"] = TRANSFER_T.EDIT_IMAGE
        expectedResult["CommandID"] = "1"
        expectedResult["TargetImageID"] = 1
        expectedResult["SourceImageID"] = 2
        expectedResult["UserID"] = 3
        self.__dbConnector.addToCompressionQueue(expectedResult)
        result = self.__dbConnector.peekFromCompressionQueue()
        self.assertEquals(result, expectedResult, "addToCompressionQueue() error")   
         
    def test_connectionDataDictionary(self):
        result = self.__dbConnector.getImageRepositoryConnectionData("1")
        expectedResult = None
        self.assertEquals(result, expectedResult, "getImageRepositoryConnectionData() error")
        expectedResult = dict()
        expectedResult["RepositoryIP"] = "192.168.0.5"
        expectedResult["RepositoryPort"] = 30000
        self.__dbConnector.addValueToConnectionDataDictionary("1", expectedResult)
        result = self.__dbConnector.getImageRepositoryConnectionData("1")
        self.assertEquals(result, expectedResult, "getImageRepositoryConnectionData() error")
        self.__dbConnector.removeImageRepositoryConnectionData("1")
        result = self.__dbConnector.getImageRepositoryConnectionData("1")
        expectedResult = None
        self.assertEquals(result, expectedResult, "removeImageRepositoryConnectionData() error")
Пример #21
0
        typeId = userM.createType("TypeTest")
        self.assertTrue(userM.isTypeExists(typeId), "type not created")

    def test_deleteType(self):
        userM = UserManagement("CygnusCloud", "cygnuscloud2012",
                               "WebServerDBTest", 1)
        userM.deleteType(4)
        self.assertFalse(userM.isTypeExists(4), "type not deleted")

    def test_groupIds(self):
        userM = UserManagement("CygnusCloud", "cygnuscloud2012",
                               "WebServerDBTest", 1)
        l1 = userM.getGroupId("VMName1")
        l2 = [1]
        self.assertEquals(l1, l2, "Not Same groups")

    def test_userIds(self):
        userM = UserManagement("CygnusCloud", "cygnuscloud2012",
                               "WebServerDBTest", 1)
        l1 = userM.getUsersId(1)
        l2 = [2, 3, 5]
        self.assertEquals(l1, l2, "Not Same users")


if __name__ == "__main__":
    #Cargamos el script de prueba
    dbUtils = DBConfigurator("")
    dbUtils.runSQLScript("WebServerDBTest", "./WebServerDBTest.sql")
    dbUtils.addUser("CygnusCloud", "cygnuscloud2012", "WebServerDBTest")
    unittest.main()
Пример #22
0
class DBWebServerTests(unittest.TestCase):
    '''
        Clase con las pruebas unitarias de la base de datos del servidor de máquinas
        virtuales
    '''
    def setUp(self):
        self.__dbConfigurator = DBConfigurator("")
        self.__dbConfigurator.runSQLScript("VMServerDBTest",
                                           "./VMServerDBTest.sql")
        self.__dbConfigurator.addUser("CygnusCloud", "cygnuscloud2012",
                                      "VMServerDBTest", True)
        self.__dbConnector = VMServerDBConnector("CygnusCloud",
                                                 "cygnuscloud2012",
                                                 "VMServerDBTest")

    def tearDown(self):
        self.__dbConnector.disconnect()
        self.__dbConfigurator.dropDatabase("VMServerDBTest")

    def test_getImages(self):
        result = self.__dbConnector.getImageIDs()
        expectedResult = [1, 2, 3, 4]
        self.assertEquals(result, expectedResult, "getImageIDs() error")

    def test_getDataImagePath(self):
        result = self.__dbConnector.getDataImagePath(1)
        expectedResult = "./VMName1/Data.qcow2"
        self.assertEquals(result, expectedResult, "getDataImagePath() error")

    def test_getOSImagePath(self):
        result = self.__dbConnector.getOSImagePath(1)
        expectedResult = "./VMName1/OS.qcow2"
        self.assertEquals(result, expectedResult, "getOSImagePath() error")

    def test_getDefinitionFilePath(self):
        result = self.__dbConnector.getDefinitionFilePath(1)
        expectedResult = "./VMName1/Definition.xml"
        self.assertEquals(result, expectedResult,
                          "getDefinitionFilePath() error")

    def test_createImage(self):
        self.__dbConnector.createImage(123, "Image/OS.qcow2",
                                       "Image/Data.qcow2",
                                       "Image/Definition.xml", 0)
        result = self.__dbConnector.getOSImagePath(123)
        expectedResult = "Image/OS.qcow2"
        self.assertEquals(result, expectedResult, "createImage() error")
        result = self.__dbConnector.getDataImagePath(123)
        expectedResult = "Image/Data.qcow2"
        self.assertEquals(result, expectedResult, "createImage() error")
        result = self.__dbConnector.getDefinitionFilePath(123)
        expectedResult = "Image/Definition.xml"
        self.assertEquals(result, expectedResult, "createImage() error")
        result = self.__dbConnector.getBootableFlag(123)
        expectedResult = False
        self.assertEquals(result, expectedResult, "createImage() error")

    def test_deleteImage(self):
        self.__dbConnector.deleteImage(1)
        result = self.__dbConnector.getOSImagePath(1)
        expectedResult = None
        self.assertEquals(result, expectedResult, "deleteImage() error")

    def test_getDomainImageID(self):
        result = self.__dbConnector.getDomainImageID("1_1")
        expectedResult = 1
        self.assertEquals(result, expectedResult, "getDomainImageID() error")

    def test_getDomainDataImagePath(self):
        result = self.__dbConnector.getDomainDataImagePath("1_1")
        expectedResult = "./DataImagePath1"
        self.assertEquals(result, expectedResult,
                          "getDomainDataImagePath() error")

    def test_getDomainOSImagePath(self):
        result = self.__dbConnector.getDomainOSImagePath("1_1")
        expectedResult = "./OSImagePath1"
        self.assertEquals(result, expectedResult,
                          "getDomainOSImagePath() error")

    def test_getDomainMACAddress(self):
        result = self.__dbConnector.getDomainMACAddress("1_1")
        expectedResult = "2C:00:00:00:00:00"
        self.assertEquals(result, expectedResult,
                          "getDomainMACAddress() error")

    def test_getDomainUUID(self):
        result = self.__dbConnector.getDomainUUID("1_1")
        expectedResult = "fce02cff-5d6d-11e2-a3f0-001f16b99e1d"
        self.assertEquals(result, expectedResult, "getDomainUUID() error")

    def test_getDomainVNCPassword(self):
        result = self.__dbConnector.getDomainVNCPassword("1_1")
        expectedResult = "12134567890"
        self.assertEquals(result, expectedResult,
                          "getDomainVNCPassword() error")

    def test_getWebsockifyDaemonPID(self):
        result = self.__dbConnector.getWebsockifyDaemonPID("1_1")
        expectedResult = 1
        self.assertEquals(result, expectedResult,
                          "getWebsockifyDaemonPID() error")

    def test_getDomainNameFromVNCPort(self):
        result = self.__dbConnector.getDomainNameFromVNCPort(1)
        expectedResult = "1_1"
        self.assertEquals(result, expectedResult,
                          "getDomainNameFromVNCPort() error")

    def test_registerVMResources(self):
        self.__dbConnector.registerVMResources("1_20", 1, 2000, "aaa", 1, 2,
                                               "OS_20.qcow2", "Data_20.qcow2",
                                               "MAC_20", "UUID_20")
        result = self.__dbConnector.getDomainNameFromVNCPort(2000)
        expectedResult = "1_20"
        self.assertEquals(result, expectedResult,
                          "registerVMSResources() error")
        result = self.__dbConnector.getDomainVNCPassword("1_20")
        expectedResult = "aaa"
        self.assertEquals(result, expectedResult,
                          "registerVMSResources() error")
        result = self.__dbConnector.getDomainOwnerID("1_20")
        expectedResult = 1
        self.assertEquals(result, expectedResult,
                          "registerVMSResources() error")
        result = self.__dbConnector.getWebsockifyDaemonPID("1_20")
        expectedResult = 2
        self.assertEquals(result, expectedResult,
                          "registerVMSResources() error")
        result = self.__dbConnector.getDomainOSImagePath("1_20")
        expectedResult = "OS_20.qcow2"
        self.assertEquals(result, expectedResult,
                          "registerVMSResources() error")
        result = self.__dbConnector.getDomainDataImagePath("1_20")
        expectedResult = "Data_20.qcow2"
        self.assertEquals(result, expectedResult,
                          "registerVMSResources() error")
        result = self.__dbConnector.getDomainMACAddress("1_20")
        expectedResult = "MAC_20"
        self.assertEquals(result, expectedResult,
                          "registerVMSResources() error")
        result = self.__dbConnector.getDomainUUID("1_20")
        expectedResult = "UUID_20"
        self.assertEquals(result, expectedResult,
                          "registerVMSResources() error")

    def test_unregisterDomainResources(self):
        self.__dbConnector.unregisterDomainResources("1_1")
        result = self.__dbConnector.getDomainOSImagePath("1_1")
        expectedResult = None
        self.assertEquals(result, expectedResult,
                          "unregisterDomainResources() error")

    def test_getOwnerID(self):
        result = self.__dbConnector.getDomainOwnerID("1_1")
        expectedResult = 1
        self.assertEquals(result, expectedResult, "getOwnerID() error")

    def test_getVMBootCommand(self):
        result = self.__dbConnector.getVMBootCommand("4_4")
        expectedResult = "Command4"
        self.assertEquals(result, expectedResult, "getVMBootCommand() error")
        result = self.__dbConnector.getVMBootCommand("3_3")
        self.assertEquals(result, "Command3", "getVMBootCommand() error")

    def test_addVMBootCommand(self):
        self.__dbConnector.registerVMResources("5_5", 1, 1, "123", 1, 1, "os",
                                               "data", "mac", "uuid")
        self.__dbConnector.addVMBootCommand("5_5", "1234")
        result = self.__dbConnector.getVMBootCommand("5_5")
        self.assertEquals(result, "1234", "addVMBootCommand() error")

    def test_getBootableFlag(self):
        result = self.__dbConnector.getBootableFlag(2)
        expectedResult = True
        self.assertEquals(result, expectedResult, "getBootableFlag() error")

    def test_getRegisteredDomainNames(self):
        result = self.__dbConnector.getRegisteredDomainNames()
        expectedResult = ["1_1", "2_2", "3_3", "4_4"]
        self.assertEquals(result, expectedResult,
                          "getRegisteredDomainNames() error")

    def test_transferQueue(self):
        expectedResult = dict()
        expectedResult["Transfer_Type"] = TRANSFER_T.STORE_IMAGE
        expectedResult["FTPTimeout"] = 100
        expectedResult["TargetImageID"] = 2
        expectedResult["RepositoryIP"] = "192.168.0.1"
        expectedResult["RepositoryPort"] = 3000
        expectedResult["CommandID"] = "1"
        expectedResult["SourceFilePath"] = "/tmp/foo.zip"
        self.__dbConnector.addToTransferQueue(expectedResult)
        result = self.__dbConnector.peekFromTransferQueue()
        self.assertEquals(result, expectedResult, "addToTransferQueue() error")
        self.__dbConnector.removeFirstElementFromTransferQueue()
        expectedResult = dict()
        expectedResult["Transfer_Type"] = TRANSFER_T.EDIT_IMAGE
        expectedResult["FTPTimeout"] = 100
        expectedResult["SourceImageID"] = 2
        expectedResult["RepositoryIP"] = "192.168.0.1"
        expectedResult["RepositoryPort"] = 3000
        expectedResult["CommandID"] = "1"
        expectedResult["UserID"] = 1
        self.__dbConnector.addToTransferQueue(expectedResult)
        result = self.__dbConnector.peekFromTransferQueue()
        self.assertEquals(result, expectedResult, "addToTransferQueue() error")

    def test_addToCompressionQueue(self):
        expectedResult = dict()
        expectedResult["Transfer_Type"] = TRANSFER_T.STORE_IMAGE
        expectedResult["CommandID"] = "1"
        expectedResult["TargetImageID"] = 1
        expectedResult["OSImagePath"] = "os.qcow"
        expectedResult["DataImagePath"] = "data.qcow2"
        expectedResult["DefinitionFilePath"] = "definition.xml"
        expectedResult["RepositoryIP"] = "192.198.0.2"
        expectedResult["RepositoryPort"] = 3000
        self.__dbConnector.addToCompressionQueue(expectedResult)
        result = self.__dbConnector.peekFromCompressionQueue()
        self.assertEquals(result, expectedResult,
                          "addToCompressionQueue() error")
        self.__dbConnector.removeFirstElementFromCompressionQueue()
        expectedResult = dict()
        expectedResult["Transfer_Type"] = TRANSFER_T.EDIT_IMAGE
        expectedResult["CommandID"] = "1"
        expectedResult["TargetImageID"] = 1
        expectedResult["SourceImageID"] = 2
        expectedResult["UserID"] = 3
        self.__dbConnector.addToCompressionQueue(expectedResult)
        result = self.__dbConnector.peekFromCompressionQueue()
        self.assertEquals(result, expectedResult,
                          "addToCompressionQueue() error")

    def test_connectionDataDictionary(self):
        result = self.__dbConnector.getImageRepositoryConnectionData("1")
        expectedResult = None
        self.assertEquals(result, expectedResult,
                          "getImageRepositoryConnectionData() error")
        expectedResult = dict()
        expectedResult["RepositoryIP"] = "192.168.0.5"
        expectedResult["RepositoryPort"] = 30000
        self.__dbConnector.addValueToConnectionDataDictionary(
            "1", expectedResult)
        result = self.__dbConnector.getImageRepositoryConnectionData("1")
        self.assertEquals(result, expectedResult,
                          "getImageRepositoryConnectionData() error")
        self.__dbConnector.removeImageRepositoryConnectionData("1")
        result = self.__dbConnector.getImageRepositoryConnectionData("1")
        expectedResult = None
        self.assertEquals(result, expectedResult,
                          "removeImageRepositoryConnectionData() error")