Sha256: 92d0317effef5eba2a202f643281b7c31468c838108f0f66784f883d054a16ea

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

# encoding: utf-8
require 'logstash/devutils/rspec/spec_helper'
require 'logstash/inputs/remote_proc'
require 'net/ssh/multi'

describe LogStash::Inputs::RemoteProc do
  let(:config) do
    { 'servers' => [{ 'host' => 'localhost',
                      'port' => 22,
                      'username' => ENV['USER'] }],
      'interval' => 100 }
  end

  let(:queue) { [] }

  before do
    ssh_session = spy('Net::SSH::Multi')
    expect(Net::SSH::Multi).to receive(:start).with(any_args)
      .and_return(ssh_session)
  end

  it_behaves_like 'an interruptible input plugin' do
  end

  subject { described_class.new(config) }

  context 'when host is reacheable' do
    it '.register' do
      expect { subject.register }.to_not raise_error
    end
  end

  context 'when host is unreacheable' do
    it '.register' do
      rp = described_class.new(
        'servers' => { 'host' => 'not_konown_host' }
      )
      expect { rp.register }.to_not raise_error
    end
  end

  context 'when gateway is provided' do
    it '.register' do
      ssh_gateway = spy('Net::SSH::Gateway')
      expect(Net::SSH::Gateway).to receive(:new).with(any_args)
        .and_return(ssh_gateway)
      rp_gateway = described_class.new(
        'servers' => [{ 'host' => 'localhost',
                        'port' => 22,
                        'username' => ENV['USER'],
                        'gateway_host' => '10.0.0.1',
                        'gateway_port' => 22 }],
        'interval' => 100
      )
      expect { rp_gateway.register }.to_not raise_error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-input-remote_proc-0.0.22 spec/inputs/remote_proc_spec.rb