spec/outputs/kusto_spec.rb (44 lines of code) (raw):
# encoding: utf-8
require 'logstash/outputs/kusto'
require 'logstash/codecs/plain'
require 'logstash/event'
describe LogStash::Outputs::Kusto do
let(:options) { { "path" => "./kusto_tst/%{+YYYY-MM-dd-HH-mm}",
"ingest_url" => "https://ingest-sdkse2etest.eastus.kusto.windows.net/",
"app_id" => "myid",
"app_key" => "mykey",
"app_tenant" => "mytenant",
"database" => "mydatabase",
"table" => "mytable",
"json_mapping" => "mymapping",
"proxy_host" => "localhost",
"proxy_port" => 3128,
"proxy_protocol" => "https"
} }
describe '#register' do
it 'doesnt allow the path to start with a dynamic string' do
kusto = described_class.new(options.merge( {'path' => '/%{name}'} ))
expect { kusto.register }.to raise_error(LogStash::ConfigurationError)
kusto.close
end
it 'path must include a dynamic string to allow file rotation' do
kusto = described_class.new(options.merge( {'path' => '/{name}'} ))
expect { kusto.register }.to raise_error(LogStash::ConfigurationError)
kusto.close
end
dynamic_name_array = ['/a%{name}/', '/a %{name}/', '/a- %{name}/', '/a- %{name}']
context 'doesnt allow the root directory to have some dynamic part' do
dynamic_name_array.each do |test_path|
it "with path: #{test_path}" do
kusto = described_class.new(options.merge( {'path' => test_path} ))
expect { kusto.register }.to raise_error(LogStash::ConfigurationError)
kusto.close
end
end
end
it 'allow to have dynamic part after the file root' do
kusto = described_class.new(options.merge({'path' => '/tmp/%{name}'}))
expect { kusto.register }.not_to raise_error
kusto.close
end
end
end