def test_is_port_open(self):
        self.patch('zaza.openstack.utilities.generic.telnetlib.Telnet',
                   new_callable=mock.MagicMock(),
                   name='telnet')

        _port = "80"
        _addr = "10.5.254.20"

        self.assertTrue(generic_utils.is_port_open(_port, _addr))
        self.telnet.assert_called_with(_addr, _port)

        self.telnet.side_effect = generic_utils.socket.error
        self.assertFalse(generic_utils.is_port_open(_port, _addr))
Beispiel #2
0
    def test_100_kill_crm_master(self):
        """Ensure VIP failover.

        When killing the mysqld on the crm_master unit verify the VIP fails
        over.
        """
        logging.info("Testing failover of crm_master unit on mysqld failure")
        # we are going to kill the crm_master
        old_crm_master = self.get_crm_master()
        logging.info("kill -9 mysqld on {}".format(old_crm_master))
        cmd = "sudo killall -9 mysqld"
        zaza.model.run_on_unit(old_crm_master, cmd)

        logging.info("looking for the new crm_master")
        i = 0
        while i < 10:
            i += 1
            # XXX time.sleep roundup
            # https://github.com/openstack-charmers/zaza-openstack-tests/issues/46
            time.sleep(5)  # give some time to pacemaker to react
            new_crm_master = self.get_crm_master()

            if (new_crm_master and new_crm_master != old_crm_master):
                logging.info("New crm_master unit detected"
                             " on {}".format(new_crm_master))
                break
        else:
            assert False, "The crm_master didn't change"

        # Check connectivity on the VIP
        # \ is required due to pep8 and parenthesis would make the assertion
        # always true.
        assert generic_utils.is_port_open("3306", self.vip), \
            "Cannot connect to vip"
Beispiel #3
0
    def test_100_kill_crm_master(self):
        """Ensure VIP failover.

        When killing the mysqld on the crm_master unit verify the VIP fails
        over.
        """
        logging.info("Testing failover of crm_master unit on mysqld failure")
        # we are going to kill the crm_master
        old_crm_master = self.get_crm_master()
        logging.info(
            "kill -9 mysqld on {}".format(old_crm_master)
        )
        cmd = "sudo killall -9 mysqld"
        zaza.model.run_on_unit(old_crm_master, cmd)

        logging.info("looking for the new crm_master")
        self.assertTrue(
            retry_is_new_crm_master(self, old_crm_master),
            msg="The crm_master didn't change")

        # Check connectivity on the VIP
        # \ is required due to pep8 and parenthesis would make the assertion
        # always true.
        assert generic_utils.is_port_open("3306", self.vip), \
            "Cannot connect to vip"