def setup_method(self, _, mocked_transports): """Setup the test environment.""" # pylint: disable=attribute-defined-outside-init self.config = Config(get_fixture_path("remote", "config.yaml")) self.mocked_transports = mocked_transports self.hosts = NodeSet("host[1-9]") self.remote_hosts = remote.RemoteHosts(self.config, self.hosts, dry_run=False) self.remote_hosts_dry_run = remote.RemoteHosts(self.config, self.hosts) self.expected = [(NodeSet("host1"), "output1")]
def test_reboot_single(self, mocked_target): """It should call the reboot script on the target host with default batch size and no sleep.""" hosts = NodeSet("host1") remote_hosts = remote.RemoteHosts(self.config, hosts, dry_run=False) mock_cumin(self.mocked_transports, 0) remote_hosts.reboot() self.mocked_transports.clustershell.ClusterShellWorker.execute.assert_called_once_with() mocked_target.assert_has_calls([mock.call(hosts, batch_size_ratio=None, batch_sleep=None, batch_size=1)])
def setup_method(self): """Setup the test environment.""" # pylint: disable=attribute-defined-outside-init config = get_fixture_path("remote", "config.yaml") self.hosts = NodeSet("host[1-10]") # We want to mock out ConftoolEntity completely here. As far as we're concerned it's just an interface self.conftool = mock.MagicMock(spec=confctl.ConftoolEntity) self.remote_hosts = remote.RemoteHosts(config, self.hosts, dry_run=False) self.remote_hosts.run_async = mock.MagicMock() self.lbcluster = remote.LBRemoteCluster(config, self.remote_hosts, self.conftool)
def test_using_sudo_prepends_when_command_is_string(self, mocked_transport_new): """Test that using sudo prepends when command is string.""" nodes_a = "host1" mock_cumin(self.mocked_transports, 0, retvals=[[(nodes_a, b"")]]) mocked_worker = mock.MagicMock() mocked_worker.execute.return_value = 0 mocked_transport_new.return_value = mocked_worker remote.RemoteHosts(self.config, NodeSet(nodes_a), dry_run=False, use_sudo=True).run_sync("command") assert mocked_worker.commands == ["sudo -i command"]
def setup_method(self): """Setup the test environment.""" # pylint: disable=attribute-defined-outside-init config = get_fixture_path("remote", "config.yaml") self.hosts = NodeSet("host[1-9]") self.remote_hosts = remote.RemoteHostsAdapter(remote.RemoteHosts(config, self.hosts, dry_run=False))
def test_init_no_hosts(self): """Should raise RemoteError if initialized without hosts.""" with pytest.raises(remote.RemoteError, match="No hosts provided"): remote.RemoteHosts(self.config, NodeSet(), dry_run=False)