Skip to content

Commit

Permalink
Updated kusto_spec.rb and ingestor_spec.rb
Browse files Browse the repository at this point in the history
Testing spec files
  • Loading branch information
MonishkaDas committed Sep 26, 2024
1 parent 47a3db2 commit 4b66790
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions spec/outputs/kusto/ingestor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,76 @@


it 'does not throw an error when initializing' do
puts "Running test: does not throw an error when initializing"
# note that this will cause an internal error since connection is being tried.
# however we still want to test that all the java stuff is working as expected
expect {
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity, cliauth, database, table, json_mapping, proxy_host, proxy_port,proxy_protocol, logger)
ingestor.stop
}.not_to raise_error
puts "Completed test: does not throw an error when initializing"
end

dynamic_name_array = ['/a%{name}/', '/a %{name}/', '/a- %{name}/', '/a- %{name}']

context 'doesnt allow database to have some dynamic part' do
dynamic_name_array.each do |test_database|
it "with database: #{test_database}" do
puts "Running test: doesnt allow database to have some dynamic part with database: #{test_database}"
expect {
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity, cliauth, test_database, table, json_mapping, proxy_host, proxy_port,proxy_protocol,logger)
ingestor.stop
}.to raise_error(LogStash::ConfigurationError)
}.to raise_error(LogStash::ConfigurationError)
puts "Completed test: doesnt allow database to have some dynamic part with database: #{test_database}"
end
end
end

context 'doesnt allow table to have some dynamic part' do
dynamic_name_array.each do |test_table|
it "with database: #{test_table}" do
it "with table: #{test_table}" do
puts "Running test: doesnt allow table to have some dynamic part with table: #{test_table}"
expect {
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity, cliauth, database, test_table, json_mapping, proxy_host, proxy_port,proxy_protocol,logger)
ingestor.stop
}.to raise_error(LogStash::ConfigurationError)
}.to raise_error(LogStash::ConfigurationError)
puts "Completed test: doesnt allow table to have some dynamic part with table: #{test_table}"
end
end
end

context 'doesnt allow mapping to have some dynamic part' do
dynamic_name_array.each do |json_mapping|
it "with database: #{json_mapping}" do
it "with mapping: #{json_mapping}" do
puts "Running test: doesnt allow mapping to have some dynamic part with mapping: #{json_mapping}"
expect {
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity, cliauth, database, table, json_mapping, proxy_host, proxy_port,proxy_protocol,logger)
ingestor.stop
}.to raise_error(LogStash::ConfigurationError)
}.to raise_error(LogStash::ConfigurationError)
puts "Completed test: doesnt allow mapping to have some dynamic part with mapping: #{json_mapping}"
end
end
end

context 'proxy protocol has to be http or https' do
it "with proxy protocol: socks" do
puts "Running test: proxy protocol has to be http or https with proxy protocol: socks"
expect {
ingestor = described_class.new(ingest_url, app_id, app_key, app_tenant, managed_identity, cliauth, database, table, json_mapping, proxy_host, proxy_port,'socks',logger)
ingestor.stop
}.to raise_error(LogStash::ConfigurationError)
}.to raise_error(LogStash::ConfigurationError)
puts "Completed test: proxy protocol has to be http or https with proxy protocol: socks"
end
end

context 'one of appid or managedid has to be provided' do
it "with empty managed identity and appid" do
puts "Running test: one of appid or managedid has to be provided with empty managed identity and appid"
expect {
ingestor = described_class.new(ingest_url, "", app_key, app_tenant, "", cliauth, database, table, json_mapping, proxy_host, proxy_port,'socks',logger)
ingestor.stop
}.to raise_error(LogStash::ConfigurationError)
}.to raise_error(LogStash::ConfigurationError)
puts "Completed test: one of appid or managedid has to be provided with empty managed identity and appid"
end
end

Expand Down

0 comments on commit 4b66790

Please sign in to comment.