コード例 #1
0
ファイル: test_driver.py プロジェクト: wangcong202/manila
    def test_manage_server(self):

        fake_id = cont_fakes.fake_identifier()
        fake_share_server = cont_fakes.fake_share_server()
        fake_container_name = "manila_fake_container"
        fake_container_old_name = "fake_old_name"

        mock_get_container_name = self.mock_object(
            self._driver, '_get_container_name',
            mock.Mock(return_value=fake_container_name))
        mock_get_correct_container_old_name = self.mock_object(
            self._driver, '_get_correct_container_old_name',
            mock.Mock(return_value=fake_container_old_name))
        mock_rename_container = self.mock_object(self._driver.container,
                                                 'rename_container')
        expected_result = {'id': fake_share_server['id']}

        new_identifier, new_backend_details = self._driver.manage_server(
            self._context, fake_share_server, fake_id, {})

        self.assertEqual(expected_result, new_backend_details)
        self.assertEqual(fake_container_name, new_identifier)
        mock_rename_container.assert_called_once_with(fake_container_old_name,
                                                      fake_container_name)
        mock_get_container_name.assert_called_with(fake_share_server['id'])
        mock_get_correct_container_old_name.assert_called_once_with(fake_id)
コード例 #2
0
ファイル: test_driver.py プロジェクト: openstack/manila
    def test_manage_server(self):

        fake_id = cont_fakes.fake_identifier()
        fake_share_server = cont_fakes.fake_share_server()
        fake_container_name = "manila_fake_container"
        fake_container_old_name = "fake_old_name"

        mock_get_container_name = self.mock_object(
            self._driver, '_get_container_name',
            mock.Mock(return_value=fake_container_name))
        mock_get_correct_container_old_name = self.mock_object(
            self._driver, '_get_correct_container_old_name',
            mock.Mock(return_value=fake_container_old_name)
        )
        mock_rename_container = self.mock_object(self._driver.container,
                                                 'rename_container')
        expected_result = {'id': fake_share_server['id']}

        new_identifier, new_backend_details = self._driver.manage_server(
            self._context, fake_share_server, fake_id, {})

        self.assertEqual(expected_result, new_backend_details)
        self.assertEqual(fake_container_name, new_identifier)
        mock_rename_container.assert_called_once_with(
            fake_container_old_name, fake_container_name)
        mock_get_container_name.assert_called_with(
            fake_share_server['id']
        )
        mock_get_correct_container_old_name.assert_called_once_with(
            fake_id
        )
コード例 #3
0
ファイル: test_driver.py プロジェクト: openstack/manila
    def test_get_share_server_network_info(self):

        fake_share_server = cont_fakes.fake_share_server()
        fake_id = cont_fakes.fake_identifier()
        expected_result = ['veth11b2c34']

        interfaces = [cont_fakes.FAKE_VSCTL_LIST_INTERFACE_1,
                      cont_fakes.FAKE_VSCTL_LIST_INTERFACE_2,
                      cont_fakes.FAKE_VSCTL_LIST_INTERFACE_4,
                      cont_fakes.FAKE_VSCTL_LIST_INTERFACE_3]

        self.mock_object(self._driver.container, 'execute',
                         mock.Mock(return_value=interfaces))

        result = self._driver.get_share_server_network_info(self._context,
                                                            fake_share_server,
                                                            fake_id, {})
        self.assertEqual(expected_result, result)
コード例 #4
0
    def test_get_share_server_network_info(self):

        fake_share_server = cont_fakes.fake_share_server()
        fake_id = cont_fakes.fake_identifier()
        expected_result = ['veth11b2c34']

        interfaces = [cont_fakes.FAKE_VSCTL_LIST_INTERFACE_1,
                      cont_fakes.FAKE_VSCTL_LIST_INTERFACE_2,
                      cont_fakes.FAKE_VSCTL_LIST_INTERFACE_4,
                      cont_fakes.FAKE_VSCTL_LIST_INTERFACE_3]

        self.mock_object(self._driver.container, 'execute',
                         mock.Mock(return_value=interfaces))

        result = self._driver.get_share_server_network_info(self._context,
                                                            fake_share_server,
                                                            fake_id, {})
        self.assertEqual(expected_result, result)