Esempio n. 1
0
    def test_trigger_refresh(self):
        """Test drone manager trigger refresh."""
        self.god.stub_with(self._DRONE_CLASS, '_drone_utility_path',
                           self.drone_utility_path)
        mock_drone = self.create_drone('fakedrone1', 'fakehost1')
        self.manager._drones[mock_drone.hostname] = mock_drone

        # Create some fake pidfiles and confirm that a refresh call is
        # executed on each drone host, with the same pidfile paths. Then
        # check that each drone gets a key in the returned results dictionary.
        for i in range(0, 1):
            pidfile_info = self.create_fake_pidfile_info(
                'tag%s' % i, 'name%s' % i)
        pidfile_paths = [pidfile.path for pidfile in pidfile_info.keys()]
        refresh_call = drone_utility.call('refresh', pidfile_paths)
        expected_results = {}
        mock_result = utils.CmdResult(stdout=cPickle.dumps(self.mock_return))
        for drone in self.manager.get_drones():
            drone._host.run.expect_call(
                'python %s' % self.drone_utility_path,
                stdin=cPickle.dumps([refresh_call]),
                stdout_tee=None,
                connect_timeout=mock.is_instance_comparator(int)).and_return(
                    mock_result)
            expected_results[drone] = self.mock_return['results']
        self.manager.trigger_refresh()
        self.assertTrue(
            self.manager._refresh_task_queue.get_results() == expected_results)
        self.god.check_playback()
Esempio n. 2
0
 def queue_call(self, method, *args, **kwargs):
     self._calls.append(drone_utility.call(method, *args, **kwargs))
Esempio n. 3
0
 def call(self, method, *args, **kwargs):
     return self._execute_calls(
         [drone_utility.call(method, *args, **kwargs)])
Esempio n. 4
0
 def queue_call(self, method, *args, **kwargs):
     self._calls.append(drone_utility.call(method, *args, **kwargs))
Esempio n. 5
0
 def call(self, method, *args, **kwargs):
     return self._execute_calls(
         [drone_utility.call(method, *args, **kwargs)])