Esempio n. 1
0
    def test_being_mysql_install(self):

        self.mySqlAppStatus = MySqlAppStatus()

        self.mySqlAppStatus.begin_mysql_install()

        self.assertEquals(self.mySqlAppStatus.status, ServiceStatuses.BUILDING)
Esempio n. 2
0
    def test_get_actual_db_status(self):

        dbaas.utils.execute_with_timeout = Mock(return_value=(None, None))

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.RUNNING, status)
Esempio n. 3
0
    def test_begin_mysql_restart(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.restart_mode = False

        self.mySqlAppStatus.begin_mysql_restart()

        self.assertTrue(self.mySqlAppStatus.restart_mode)
Esempio n. 4
0
    def test_end_install_or_restart(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.SHUTDOWN)

        self.mySqlAppStatus.end_install_or_restart()

        self.assertEqual(ServiceStatuses.SHUTDOWN, self.mySqlAppStatus.status)
        self.assertFalse(self.mySqlAppStatus.restart_mode)
Esempio n. 5
0
    def test_wait_for_real_status_to_change_to_timeout(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.RUNNING)
        dbaas.time.sleep = Mock()

        self.assertFalse(
            self.mySqlAppStatus.wait_for_real_status_to_change_to(
                ServiceStatuses.SHUTDOWN, 10))
Esempio n. 6
0
    def test_get_actual_db_status_error_shutdown(self):

        from reddwarf.common.exception import ProcessExecutionError
        mocked = Mock(side_effect=ProcessExecutionError())
        dbaas.utils.execute_with_timeout = mocked
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=False)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.SHUTDOWN, status)
Esempio n. 7
0
    def test_get_actual_db_status_error_crashed(self):

        from reddwarf.common.exception import ProcessExecutionError
        dbaas.utils.execute_with_timeout = \
            MagicMock(side_effect=[ProcessExecutionError(),
                                   ("some output", None)])
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=True)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.BLOCKED, status)
Esempio n. 8
0
    def test_being_mysql_install(self):

        self.mySqlAppStatus = MySqlAppStatus()

        self.mySqlAppStatus.begin_mysql_install()

        self.assertEquals(self.mySqlAppStatus.status, ServiceStatuses.BUILDING)
Esempio n. 9
0
    def test_begin_mysql_restart(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.restart_mode = False

        self.mySqlAppStatus.begin_mysql_restart()

        self.assertTrue(self.mySqlAppStatus.restart_mode)
Esempio n. 10
0
    def test_get_actual_db_status(self):

        dbaas.utils.execute_with_timeout = Mock(return_value=(None, None))

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.RUNNING, status)
Esempio n. 11
0
    def test_wait_for_real_status_to_change_to_timeout(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.RUNNING)
        dbaas.time.sleep = Mock()

        self.assertFalse(self.mySqlAppStatus.
                         wait_for_real_status_to_change_to
                         (ServiceStatuses.SHUTDOWN, 10))
Esempio n. 12
0
    def test_end_install_or_restart(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.SHUTDOWN)

        self.mySqlAppStatus.end_install_or_restart()

        self.assertEqual(ServiceStatuses.SHUTDOWN, self.mySqlAppStatus.status)
        self.assertFalse(self.mySqlAppStatus.restart_mode)
Esempio n. 13
0
    def test_get_actual_db_status_error_shutdown(self):

        from reddwarf.common.exception import ProcessExecutionError
        mocked = Mock(side_effect=ProcessExecutionError())
        dbaas.utils.execute_with_timeout = mocked
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=False)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.SHUTDOWN, status)
Esempio n. 14
0
    def test_get_actual_db_status_error_crashed(self):

        from reddwarf.common.exception import ProcessExecutionError
        dbaas.utils.execute_with_timeout = \
            MagicMock(side_effect=[ProcessExecutionError(),
                                   ("some output", None)])
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=True)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.BLOCKED, status)
Esempio n. 15
0
    def test_is_mysql_running(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.RUNNING

        self.assertTrue(self.mySqlAppStatus.is_mysql_running)
Esempio n. 16
0
    def test_is_mysql_restarting(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.restart_mode = True

        self.assertTrue(self.mySqlAppStatus._is_mysql_restarting)
Esempio n. 17
0
    def test_is_mysql_installed_failed(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.FAILED

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)
Esempio n. 18
0
    def test_is_mysql_installed_building(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.BUILDING

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)
Esempio n. 19
0
    def test_is_mysql_installed_none(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = None

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)
Esempio n. 20
0
    def test_is_mysql_installed_none(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = None

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)
Esempio n. 21
0
    def test_is_mysql_installed_building(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.BUILDING

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)
Esempio n. 22
0
    def test_is_mysql_installed_failed(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.FAILED

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)
Esempio n. 23
0
    def test_is_mysql_restarting(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.restart_mode = True

        self.assertTrue(self.mySqlAppStatus._is_mysql_restarting)
Esempio n. 24
0
    def test_is_mysql_running_not(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.SHUTDOWN

        self.assertFalse(self.mySqlAppStatus.is_mysql_running)
Esempio n. 25
0
    def test_is_mysql_running_not(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.SHUTDOWN

        self.assertFalse(self.mySqlAppStatus.is_mysql_running)
Esempio n. 26
0
    def test_is_mysql_running(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.RUNNING

        self.assertTrue(self.mySqlAppStatus.is_mysql_running)
Esempio n. 27
0
class MySqlAppStatusTest(testtools.TestCase):

    def setUp(self):
        super(MySqlAppStatusTest, self).setUp()
        util.init_db()
        self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
        self.orig_load_mysqld_options = dbaas.load_mysqld_options
        self.orig_dbaas_os_path_exists = dbaas.os.path.exists
        self.orig_dbaas_time_sleep = dbaas.time.sleep
        self.FAKE_ID = randint(1, 10000)
        InstanceServiceStatus.create(instance_id=self.FAKE_ID,
                                     status=ServiceStatuses.NEW)
        dbaas.CONF.guest_id = self.FAKE_ID

    def tearDown(self):
        super(MySqlAppStatusTest, self).tearDown()
        dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
        dbaas.load_mysqld_options = self.orig_load_mysqld_options
        dbaas.os.path.exists = self.orig_dbaas_os_path_exists
        dbaas.time.sleep = self.orig_dbaas_time_sleep
        InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
        dbaas.CONF.guest_id = None

    def test_being_mysql_install(self):

        self.mySqlAppStatus = MySqlAppStatus()

        self.mySqlAppStatus.begin_mysql_install()

        self.assertEquals(self.mySqlAppStatus.status, ServiceStatuses.BUILDING)

    def test_begin_mysql_restart(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.restart_mode = False

        self.mySqlAppStatus.begin_mysql_restart()

        self.assertTrue(self.mySqlAppStatus.restart_mode)

    def test_end_install_or_restart(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.SHUTDOWN)

        self.mySqlAppStatus.end_install_or_restart()

        self.assertEqual(ServiceStatuses.SHUTDOWN, self.mySqlAppStatus.status)
        self.assertFalse(self.mySqlAppStatus.restart_mode)

    def test_get_actual_db_status(self):

        dbaas.utils.execute_with_timeout = Mock(return_value=(None, None))

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.RUNNING, status)

    def test_get_actual_db_status_error_shutdown(self):

        from reddwarf.common.exception import ProcessExecutionError
        mocked = Mock(side_effect=ProcessExecutionError())
        dbaas.utils.execute_with_timeout = mocked
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=False)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.SHUTDOWN, status)

    def test_get_actual_db_status_error_crashed(self):

        from reddwarf.common.exception import ProcessExecutionError
        dbaas.utils.execute_with_timeout = \
            MagicMock(side_effect=[ProcessExecutionError(),
                                   ("some output", None)])
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=True)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.BLOCKED, status)

    def test_is_mysql_installed(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.RUNNING

        self.assertTrue(self.mySqlAppStatus.is_mysql_installed)

    def test_is_mysql_installed_none(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = None

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)

    def test_is_mysql_installed_building(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.BUILDING

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)

    def test_is_mysql_installed_failed(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.FAILED

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)

    def test_is_mysql_restarting(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.restart_mode = True

        self.assertTrue(self.mySqlAppStatus._is_mysql_restarting)

    def test_is_mysql_running(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.RUNNING

        self.assertTrue(self.mySqlAppStatus.is_mysql_running)

    def test_is_mysql_running_not(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.SHUTDOWN

        self.assertFalse(self.mySqlAppStatus.is_mysql_running)

    def test_wait_for_real_status_to_change_to(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.RUNNING)
        dbaas.time.sleep = Mock()

        self.assertTrue(self.mySqlAppStatus.
                        wait_for_real_status_to_change_to
                        (ServiceStatuses.RUNNING, 10))

    def test_wait_for_real_status_to_change_to_timeout(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.RUNNING)
        dbaas.time.sleep = Mock()

        self.assertFalse(self.mySqlAppStatus.
                         wait_for_real_status_to_change_to
                         (ServiceStatuses.SHUTDOWN, 10))
Esempio n. 28
0
class MySqlAppStatusTest(testtools.TestCase):
    def setUp(self):
        super(MySqlAppStatusTest, self).setUp()
        util.init_db()
        self.orig_utils_execute_with_timeout = dbaas.utils.execute_with_timeout
        self.orig_load_mysqld_options = dbaas.load_mysqld_options
        self.orig_dbaas_os_path_exists = dbaas.os.path.exists
        self.orig_dbaas_time_sleep = dbaas.time.sleep
        self.FAKE_ID = randint(1, 10000)
        InstanceServiceStatus.create(instance_id=self.FAKE_ID,
                                     status=ServiceStatuses.NEW)
        dbaas.CONF.guest_id = self.FAKE_ID

    def tearDown(self):
        super(MySqlAppStatusTest, self).tearDown()
        dbaas.utils.execute_with_timeout = self.orig_utils_execute_with_timeout
        dbaas.load_mysqld_options = self.orig_load_mysqld_options
        dbaas.os.path.exists = self.orig_dbaas_os_path_exists
        dbaas.time.sleep = self.orig_dbaas_time_sleep
        InstanceServiceStatus.find_by(instance_id=self.FAKE_ID).delete()
        dbaas.CONF.guest_id = None

    def test_being_mysql_install(self):

        self.mySqlAppStatus = MySqlAppStatus()

        self.mySqlAppStatus.begin_mysql_install()

        self.assertEquals(self.mySqlAppStatus.status, ServiceStatuses.BUILDING)

    def test_begin_mysql_restart(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.restart_mode = False

        self.mySqlAppStatus.begin_mysql_restart()

        self.assertTrue(self.mySqlAppStatus.restart_mode)

    def test_end_install_or_restart(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.SHUTDOWN)

        self.mySqlAppStatus.end_install_or_restart()

        self.assertEqual(ServiceStatuses.SHUTDOWN, self.mySqlAppStatus.status)
        self.assertFalse(self.mySqlAppStatus.restart_mode)

    def test_get_actual_db_status(self):

        dbaas.utils.execute_with_timeout = Mock(return_value=(None, None))

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.RUNNING, status)

    def test_get_actual_db_status_error_shutdown(self):

        from reddwarf.common.exception import ProcessExecutionError
        mocked = Mock(side_effect=ProcessExecutionError())
        dbaas.utils.execute_with_timeout = mocked
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=False)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.SHUTDOWN, status)

    def test_get_actual_db_status_error_crashed(self):

        from reddwarf.common.exception import ProcessExecutionError
        dbaas.utils.execute_with_timeout = \
            MagicMock(side_effect=[ProcessExecutionError(),
                                   ("some output", None)])
        dbaas.load_mysqld_options = Mock()
        dbaas.os.path.exists = Mock(return_value=True)

        self.mySqlAppStatus = MySqlAppStatus()
        status = self.mySqlAppStatus._get_actual_db_status()

        self.assertEqual(ServiceStatuses.BLOCKED, status)

    def test_is_mysql_installed(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.RUNNING

        self.assertTrue(self.mySqlAppStatus.is_mysql_installed)

    def test_is_mysql_installed_none(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = None

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)

    def test_is_mysql_installed_building(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.BUILDING

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)

    def test_is_mysql_installed_failed(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.FAILED

        self.assertFalse(self.mySqlAppStatus.is_mysql_installed)

    def test_is_mysql_restarting(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.restart_mode = True

        self.assertTrue(self.mySqlAppStatus._is_mysql_restarting)

    def test_is_mysql_running(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.RUNNING

        self.assertTrue(self.mySqlAppStatus.is_mysql_running)

    def test_is_mysql_running_not(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus.status = ServiceStatuses.SHUTDOWN

        self.assertFalse(self.mySqlAppStatus.is_mysql_running)

    def test_wait_for_real_status_to_change_to(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.RUNNING)
        dbaas.time.sleep = Mock()

        self.assertTrue(
            self.mySqlAppStatus.wait_for_real_status_to_change_to(
                ServiceStatuses.RUNNING, 10))

    def test_wait_for_real_status_to_change_to_timeout(self):

        self.mySqlAppStatus = MySqlAppStatus()
        self.mySqlAppStatus._get_actual_db_status = \
            Mock(return_value=ServiceStatuses.RUNNING)
        dbaas.time.sleep = Mock()

        self.assertFalse(
            self.mySqlAppStatus.wait_for_real_status_to_change_to(
                ServiceStatuses.SHUTDOWN, 10))