Esempio n. 1
0
    def test_create_slv_array(self):
        """Function:  test_create_slv_array

        Description:  Test create_slv_array function.

        Arguments:

        """

        slaves = cmds_gen.create_cfg_array(self.config_name,
                                           cfg_path=self.config_dir)
        srv = mysql_libs.create_slv_array(slaves)

        self.assertTrue(isinstance(srv, list))
Esempio n. 2
0
    def test_add_down_true(self, mock_rep):

        """Function:  test_add_down_true

        Description:  Test with add_down option set to true.

        Arguments:

        """

        mock_rep.return_value = self.slave
        slaves = mysql_libs.create_slv_array([self.cfg_array])

        self.assertEqual(len(slaves), 1)
Esempio n. 3
0
    def test_create_slv_array(self, mock_rep):

        """Function:  test_create_slv_array

        Description:  Test create_slv_array function.

        Arguments:

        """

        mock_rep.return_value = self.slave
        slaves = mysql_libs.create_slv_array([self.cfg_array])

        self.assertEqual(len(slaves), 1)
Esempio n. 4
0
    def test_multiple_array(self, mock_rep):

        """Function:  test_multiple_array

        Description:  Test with multiple slaves.

        Arguments:

        """

        mock_rep.return_value = self.slave
        slaves = mysql_libs.create_slv_array(self.cfg_array2)

        self.assertEqual(len(slaves), 2)
Esempio n. 5
0
    def test_multiple_array_down(self, mock_rep):

        """Function:  test_multiple_array_down

        Description:  Test with multiple slaves and down slave.

        Arguments:

        """

        mock_rep.side_effect = [self.slave, self.slave2]
        slaves = mysql_libs.create_slv_array(self.cfg_array2)

        self.assertEqual(len(slaves), 2)
Esempio n. 6
0
    def test_dont_add_array(self, mock_rep):

        """Function:  test_dont_add_array

        Description:  Test with do not add slaves that are down.

        Arguments:

        """

        mock_rep.side_effect = [self.slave, self.slave2]
        slaves = mysql_libs.create_slv_array(self.cfg_array2, add_down=False)

        self.assertEqual(len(slaves), 1)
Esempio n. 7
0
    def test_no_rep_user(self, mock_rep):

        """Function:  test_no_rep_user

        Description:  Test with no rep_user information passed.

        Arguments:

        """

        mock_rep.return_value = self.slave
        slaves = mysql_libs.create_slv_array([self.cfg_array])

        self.assertEqual(len(slaves), 1)
Esempio n. 8
0
    def test_not_found(self):
        """Function:  test_not_found

        Description:  Test with slave not found.

        Arguments:

        """

        slaves = cmds_gen.create_cfg_array(self.config_name,
                                           cfg_path=self.config_dir)
        servers = mysql_libs.create_slv_array(slaves)
        slv, _, _ = mysql_libs.fetch_slv(servers, self.name)

        self.assertFalse(slv)
Esempio n. 9
0
    def test_not_found2(self):
        """Function:  test_not_found2

        Description:  Test with slave not found.

        Arguments:

        """

        slaves = cmds_gen.create_cfg_array(self.config_name,
                                           cfg_path=self.config_dir)
        servers = mysql_libs.create_slv_array(slaves)
        _, err_flag, err_msg = mysql_libs.fetch_slv(servers, self.name)

        self.assertEqual((err_flag, err_msg), (True, self.err_msg))
Esempio n. 10
0
    def test_add_down_conn_false(self, mock_rep):

        """Function:  test_add_down_conn_false

        Description:  Test with add_down and conn set to false.

        Arguments:

        """

        self.slave.conn = False
        mock_rep.return_value = self.slave
        slaves = mysql_libs.create_slv_array([self.cfg_array], add_down=False)

        self.assertEqual(len(slaves), 0)
Esempio n. 11
0
    def test_found2(self):
        """Function:  test_found2

        Description:  Test with slave found.

        Arguments:

        """

        slaves = cmds_gen.create_cfg_array(self.config_name,
                                           cfg_path=self.config_dir)
        name = slaves[0]["name"]
        servers = mysql_libs.create_slv_array(slaves)
        _, err_flag, err_msg = mysql_libs.fetch_slv(servers, name)

        self.assertEqual((err_flag, err_msg), (False, None))
Esempio n. 12
0
    def test_found(self):
        """Function:  test_found

        Description:  Test with slave found.

        Arguments:

        """

        slaves = cmds_gen.create_cfg_array(self.config_name,
                                           cfg_path=self.config_dir)
        name = slaves[0]["name"]
        servers = mysql_libs.create_slv_array(slaves)
        slv, _, _ = mysql_libs.fetch_slv(servers, name)

        self.assertTrue(isinstance(slv, mysql_class.SlaveRep))