Ejemplo n.º 1
0
    def test_init_helper(self):
        ganeshelper = mock.Mock()
        exptemp = mock.Mock()

        def set_attributes(*a, **kw):
            self._helper.ganesha = ganeshelper
            self._helper.export_template = exptemp

        self.mock_object(ganesha.GaneshaNASHelper, 'init_helper',
                         mock.Mock(side_effect=set_attributes))
        self.assertEqual({}, glusterfs.GaneshaNFSHelper.shared_data)

        self._helper.init_helper()

        ganesha.GaneshaNASHelper.init_helper.assert_called_once_with()
        self.assertEqual(ganeshelper, self._helper.ganesha)
        self.assertEqual(exptemp, self._helper.export_template)
        self.assertEqual(
            {
                'GLUSTER-Ganesha-localhost': {
                    'ganesha': ganeshelper,
                    'export_template': exptemp
                }
            }, glusterfs.GaneshaNFSHelper.shared_data)

        other_helper = glusterfs.GaneshaNFSHelper(
            self._execute,
            self.fake_conf,
            gluster_manager=self.gluster_manager)
        other_helper.tag = 'GLUSTER-Ganesha-localhost'

        other_helper.init_helper()

        self.assertEqual(ganeshelper, other_helper.ganesha)
        self.assertEqual(exptemp, other_helper.export_template)
Ejemplo n.º 2
0
 def test_init_remote_ganesha_server(self):
     ssh_execute = mock.Mock(return_value=('', ''))
     CONF.set_default('glusterfs_ganesha_server_ip', 'fakeip')
     self.mock_object(glusterfs.ganesha_utils, 'SSHExecutor',
                      mock.Mock(return_value=ssh_execute))
     glusterfs.GaneshaNFSHelper(self._execute,
                                self.fake_conf,
                                gluster_manager=self.gluster_manager)
     glusterfs.ganesha_utils.SSHExecutor.assert_called_once_with(
         'fakeip', 22, None, 'root', password=None, privatekey=None)
     glusterfs.ganesha.GaneshaNASHelper.__init__.assert_has_calls(
         [mock.call(ssh_execute, self.fake_conf)])
Ejemplo n.º 3
0
 def setUp(self):
     super(GaneshaNFSHelperTestCase, self).setUp()
     self.gluster_manager = mock.Mock(**fake_gluster_manager_attrs)
     self._execute = mock.Mock(return_value=('', ''))
     self._root_execute = mock.Mock(return_value=('', ''))
     self.access = fake_share.fake_access()
     self.fake_conf = config.Configuration(None)
     self.fake_template = {'key': 'value'}
     self.share = fake_share.fake_share()
     self.mock_object(glusterfs.ganesha_utils, 'RootExecutor',
                      mock.Mock(return_value=self._root_execute))
     self.mock_object(glusterfs.ganesha.GaneshaNASHelper, '__init__',
                      mock.Mock())
     self._helper = glusterfs.GaneshaNFSHelper(
         self._execute,
         self.fake_conf,
         gluster_manager=self.gluster_manager)