From 15a90a1df46688a54bf08dacf72d5ab7cc9c6755 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 20 Nov 2023 16:23:41 +0900 Subject: [PATCH] test: Fix failed test cases --- .../test_elasticsearch_fallback_selector.rb | 2 +- ...lasticsearch_index_lifecycle_management.rb | 12 +- test/plugin/test_in_elasticsearch.rb | 20 +- test/plugin/test_out_elasticsearch.rb | 672 +++++++++--------- .../test_out_elasticsearch_data_stream.rb | 42 +- test/plugin/test_out_elasticsearch_dynamic.rb | 24 +- 6 files changed, 393 insertions(+), 379 deletions(-) diff --git a/test/plugin/test_elasticsearch_fallback_selector.rb b/test/plugin/test_elasticsearch_fallback_selector.rb index 10d2150b..d332b39e 100644 --- a/test/plugin/test_elasticsearch_fallback_selector.rb +++ b/test/plugin/test_elasticsearch_fallback_selector.rb @@ -15,7 +15,7 @@ def setup def stub_elastic(url="http://localhost:9200/_bulk") stub_request(:post, url).with do |req| @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) } - end + end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) end def elasticsearch_version diff --git a/test/plugin/test_elasticsearch_index_lifecycle_management.rb b/test/plugin/test_elasticsearch_index_lifecycle_management.rb index fcdfae80..e398d6c3 100644 --- a/test/plugin/test_elasticsearch_index_lifecycle_management.rb +++ b/test/plugin/test_elasticsearch_index_lifecycle_management.rb @@ -60,7 +60,7 @@ def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_versio def test_xpack_info stub_request(:get, "http://localhost:9200/_xpack"). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json" }) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch' }) stub_elastic_info expected = {"features"=>{"ilm"=>{"available"=>true, "enabled"=>true}}} if xpack_info.is_a?(Elasticsearch::API::Response) @@ -72,32 +72,32 @@ def test_xpack_info def test_verify_ilm_working stub_request(:get, "http://localhost:9200/_xpack"). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json" }) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch' }) stub_elastic_info assert_nothing_raised { verify_ilm_working } end def test_ilm_policy_doesnt_exists stub_request(:get, "http://localhost:9200/#{ilm_existence_endpoint("fluentd-policy")}"). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info assert_false(ilm_policy_exists?("fluentd-policy")) end def test_ilm_policy_exists stub_request(:get, "http://localhost:9200/#{ilm_existence_endpoint("fluent-policy")}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info assert_true(ilm_policy_exists?("fluent-policy")) end def test_create_ilm_policy stub_request(:get, "http://localhost:9200/#{ilm_creation_endpoint("fluent-policy")}"). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "http://localhost:9200/#{ilm_creation_endpoint("fluent-policy")}"). with(:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}", :headers => {'Content-Type'=>'application/json'}). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info create_ilm_policy("fluent-policy") diff --git a/test/plugin/test_in_elasticsearch.rb b/test/plugin/test_in_elasticsearch.rb index a6053a91..d867bc0d 100644 --- a/test/plugin/test_in_elasticsearch.rb +++ b/test/plugin/test_in_elasticsearch.rb @@ -334,7 +334,7 @@ def test_emit stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000"). with(body: "{\"sort\":[\"_doc\"]}"). to_return(status: 200, body: sample_response.to_s, - headers: {'Content-Type' => 'application/json'}) + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver(CONFIG) @@ -350,7 +350,7 @@ def test_emit_with_custom_index_name stub_request(@http_method, "http://localhost:9200/#{index_name}/_search?scroll=1m&size=1000"). with(body: "{\"sort\":[\"_doc\"]}"). to_return(status: 200, body: sample_response(index_name).to_s, - headers: {'Content-Type' => 'application/json'}) + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver(CONFIG + %[index_name #{index_name}]) @@ -366,7 +366,7 @@ def test_emit_with_parse_timestamp stub_request(@http_method, "http://localhost:9200/#{index_name}/_search?scroll=1m&size=1000"). with(body: "{\"sort\":[\"_doc\"]}"). to_return(status: 200, body: sample_response(index_name).to_s, - headers: {'Content-Type' => 'application/json'}) + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver(CONFIG + %[parse_timestamp]) @@ -385,7 +385,7 @@ def test_emit_with_parse_timestamp_and_timstamp_format stub_request(@http_method, "http://localhost:9200/#{index_name}/_search?scroll=1m&size=1000"). with(body: "{\"sort\":[\"_doc\"]}"). to_return(status: 200, body: sample_response(index_name).to_s, - headers: {'Content-Type' => 'application/json'}) + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver(CONFIG + %[parse_timestamp true @@ -405,7 +405,7 @@ def test_emit_with_docinfo stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000"). with(body: "{\"sort\":[\"_doc\"]}"). to_return(status: 200, body: sample_response.to_s, - headers: {'Content-Type' => 'application/json'}) + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver(CONFIG + %[docinfo true]) @@ -425,11 +425,11 @@ def test_emit_with_slices stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000"). with(body: "{\"sort\":[\"_doc\"],\"slice\":{\"id\":0,\"max\":2}}"). to_return(status: 200, body: sample_response.to_s, - headers: {'Content-Type' => 'application/json'}) + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}) stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000"). with(body: "{\"sort\":[\"_doc\"],\"slice\":{\"id\":1,\"max\":2}}"). to_return(status: 200, body: sample_response.to_s, - headers: {'Content-Type' => 'application/json'}) + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver(CONFIG + %[num_slices 2]) @@ -446,7 +446,7 @@ def test_emit_with_size stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1"). with(body: "{\"sort\":[\"_doc\"]}"). to_return(status: 200, body: sample_scroll_response.to_s, - headers: {'Content-Type' => 'application/json'}) + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}) connection = 0 scroll_request = stub_request(@http_method, "http://localhost:9200/_search/scroll?scroll=1m"). with( @@ -457,10 +457,10 @@ def test_emit_with_size scroll_request.to_return(lambda do |req| if connection <= 1 {status: 200, body: sample_scroll_response_2.to_s, - headers: {'Content-Type' => 'application/json'}} + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}} else {status: 200, body: sample_scroll_response_terminate.to_s, - headers: {'Content-Type' => 'application/json'}} + headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}} end end) stub_request(:delete, "http://localhost:9200/_search/scroll/WomkoUKG0QPB679Ulo6TqQgh3pIGRUmrl9qXXGK3EeiQh9rbYNasTkspZQcJ01uz"). diff --git a/test/plugin/test_out_elasticsearch.rb b/test/plugin/test_out_elasticsearch.rb index 014b17a8..6ab53be8 100644 --- a/test/plugin/test_out_elasticsearch.rb +++ b/test/plugin/test_out_elasticsearch.rb @@ -57,6 +57,10 @@ def elasticsearch_transport_layer_decoupling? Gem::Version.create(::TRANSPORT_CLASS::VERSION) >= Gem::Version.new("7.14.0") end + def elastic_perform_request_refactored? + Gem::Version.create(Elasticsearch::VERSION) >= Gem::Version.new("8.8.0") + end + def elastic_transport_layer? Gem::Version.create(::TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0") end @@ -84,7 +88,7 @@ def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_versio def stub_elastic(url="http://localhost:9200/_bulk") stub_request(:post, url).with do |req| @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) } - end + end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) end def stub_elastic_all_requests(url="http://localhost:9200/_bulk") @@ -92,7 +96,7 @@ def stub_elastic_all_requests(url="http://localhost:9200/_bulk") stub_request(:post, url).with do |req| @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) } @index_cmds_all_requests << @index_cmds - end + end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) end def stub_elastic_unavailable(url="http://localhost:9200/_bulk") @@ -112,7 +116,7 @@ def stub_elastic_with_store_index_command_counts(url="http://localhost:9200/_bul stub_request(:post, url).with do |req| index_cmds = req.body.split("\n").map {|r| JSON.parse(r) } @index_command_counts[url] += index_cmds.size - end + end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) end def make_response_body(req, error_el = nil, error_status = nil, error = nil) @@ -179,7 +183,7 @@ def stub_elastic_bad_argument(url="http://localhost:9200/_bulk") "reason" => "Invalid format: \"...\"" } } - stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 400, error), :headers => { 'Content-Type' => 'json' } } }) + stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 400, error), :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } }) end def stub_elastic_bulk_error(url="http://localhost:9200/_bulk") @@ -187,7 +191,7 @@ def stub_elastic_bulk_error(url="http://localhost:9200/_bulk") "type" => "some-unrecognized-error", "reason" => "some message printed here ...", } - stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 500, error), :headers => { 'Content-Type' => 'json' } } }) + stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 500, error), :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } }) end def stub_elastic_bulk_rejected(url="http://localhost:9200/_bulk") @@ -196,7 +200,7 @@ def stub_elastic_bulk_rejected(url="http://localhost:9200/_bulk") "type" => "es_rejected_execution_exception", "reason" => "rejected execution of org.elasticsearch.transport.TransportService$4@1a34d37a on EsThreadPoolExecutor[bulk, queue capacity = 50, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@312a2162[Running, pool size = 32, active threads = 32, queued tasks = 50, completed tasks = 327053]]" } - stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 429, error), :headers => { 'Content-Type' => 'json' } } }) + stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 429, error), :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } }) end def stub_elastic_out_of_memory(url="http://localhost:9200/_bulk") @@ -205,7 +209,7 @@ def stub_elastic_out_of_memory(url="http://localhost:9200/_bulk") "type" => "out_of_memory_error", "reason" => "Java heap space" } - stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 500, error), :headers => { 'Content-Type' => 'json' } } }) + stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 500, error), :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } }) end def stub_elastic_unexpected_response_op(url="http://localhost:9200/_bulk") @@ -213,7 +217,7 @@ def stub_elastic_unexpected_response_op(url="http://localhost:9200/_bulk") "category" => "some-other-type", "reason" => "some-other-reason" } - stub_request(:post, url).to_return(lambda { |req| bodystr = make_response_body(req, 0, 500, error); body = JSON.parse(bodystr); body['items'][0]['unknown'] = body['items'][0].delete('create'); { :status => 200, :body => body.to_json, :headers => { 'Content-Type' => 'json' } } }) + stub_request(:post, url).to_return(lambda { |req| bodystr = make_response_body(req, 0, 500, error); body = JSON.parse(bodystr); body['items'][0]['unknown'] = body['items'][0].delete('create'); { :status => 200, :body => body.to_json, :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } }) end def assert_logs_include(logs, msg, exp_matches=1) @@ -324,7 +328,7 @@ def test_configure end stub_request(:post, "http://localhost:9200/_bulk"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver.run(default_tag: 'test') do driver.feed(sample_record) @@ -357,7 +361,7 @@ def test_configure end stub_request(:post, "http://localhost:9200/_bulk"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch' }) stub_elastic_info driver.run(default_tag: 'test') do driver.feed(sample_record) @@ -458,7 +462,7 @@ def format(tag, time, record) def stub_elastic_info_bad(url="http://localhost:9200/", version="6.4.2") body ="{\"version\":{\"number\":\"#{version}\",\"build_flavor\":\"default\"},\"tagline\":\"You Know, for Search\"}" - stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'text/plain' } }) + stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'text/plain', 'x-elastic-product' => 'Elasticsearch'} }) end test 'handle invalid client.info' do @@ -474,7 +478,11 @@ def stub_elastic_info_bad(url="http://localhost:9200/", version="6.4.2") scheme https @log_level info } - if elastic_transport_layer? + if elastic_perform_request_refactored? + d = create_driver(config, 8, "\"8.8.0\"") + logs = d.logs + assert_logs_include(logs, /Detected ES 7.x: `_doc` will be used as the document `_type`./) + elsif elastic_transport_layer? assert_raise(NoMethodError) do d = create_driver(config, 8, "\"8.0.0\"") end @@ -543,22 +551,22 @@ def ilm_endpoint use_legacy_template #{use_legacy_template_flag} } stub_request(:get, "http://localhost:9200/#{endpoint}/fluentd"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:head, "http://localhost:9200/_alias/fluentd"). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "http://localhost:9200/%3Cfluentd-default-%7Bnow%2Fd%7D-000001%3E/#{alias_endpoint}/fluentd"). with(body: "{\"aliases\":{\"fluentd\":{\"is_write_index\":true}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "http://localhost:9200/%3Cfluentd-default-%7Bnow%2Fd%7D-000001%3E"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "http://localhost:9200/_xpack"). to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', - :headers => {"Content-Type"=> "application/json"}) + :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy"). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy"). with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info assert_nothing_raised { @@ -588,22 +596,22 @@ def ilm_endpoint use_legacy_template #{use_legacy_template_flag} } stub_request(:get, "http://localhost:9200/#{endpoint}/fluentd"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:head, "http://localhost:9200/_alias/fluentd"). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "http://localhost:9200/%3Cfluentd-default-%7Bnow%2Fd%7D-000001%3E/#{alias_endpoint}/fluentd"). with(body: "{\"aliases\":{\"fluentd\":{\"is_write_index\":true}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "http://localhost:9200/%3Cfluentd-default-%7Bnow%2Fd%7D-000001%3E"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "http://localhost:9200/_xpack"). to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', - :headers => {"Content-Type"=> "application/json"}) + :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy"). with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"75gb\",\"max_age\":\"50d\"}}}}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info assert_nothing_raised { @@ -954,11 +962,11 @@ def test_template_already_present(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -995,15 +1003,15 @@ def test_template_create(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1043,27 +1051,27 @@ def test_template_create_with_rollover_index_and_template_related_placeholders(d # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-test.template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # create template stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-test.template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector-test.template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E/#{alias_endpoint}/myapp_deflector-test.template"). with(basic_auth: ['john', 'doe'], body: "{\"aliases\":{\"myapp_deflector-test.template\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) driver(config) @@ -1113,27 +1121,27 @@ def test_template_create_with_rollover_index_and_template_related_placeholders_w # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-test.template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # create template stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-test.template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector-test.template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E/#{alias_endpoint}/myapp_deflector-test.template"). with(basic_auth: ['john', 'doe'], body: "{\"aliases\":{\"myapp_deflector-test.template\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1210,51 +1218,51 @@ def test_template_create_with_rollover_index_and_default_ilm(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-*\",\"order\":51}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1296,52 +1304,52 @@ def test_template_create_with_rollover_index_and_default_ilm_on_logstash_format( # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash-#{date_str}"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-log-#{date_str}\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-log-#{date_str}-*\",\"order\":53}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-log-2020.09.21-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-2020.09.21\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":103}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-log-#{date_str}-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-log-#{date_str}-000001%3E/#{alias_endpoint}/logstash-#{date_str}"). with(basic_auth: ['john', 'doe'], body: "{\"aliases\":{\"logstash-#{date_str}\":{\"is_write_index\":true}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1389,51 +1397,51 @@ def test_template_create_with_rollover_index_and_default_ilm_and_ilm_policy_over # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-*\",\"order\":51}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1498,51 +1506,51 @@ def test_template_create_with_rollover_index_and_default_ilm_with_empty_index_da # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_deflector"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-*\",\"order\":51}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_deflector"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-000001%3E/#{alias_endpoint}/logstash"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1584,50 +1592,50 @@ def test_template_create_with_rollover_index_and_custom_ilm(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"myalogs\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"mylogs-*\",\"order\":51}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash"). with(body: "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1669,50 +1677,50 @@ def test_template_create_with_rollover_index_and_ilm_policies_and_placeholderste # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"myalogs\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"mylogs-*\",\"order\":51}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash"). with(body: "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1761,50 +1769,50 @@ def test_tag_placeholder(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"myalogs\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"mylogs-*\",\"order\":51}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash"). with(body: "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe'], body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1852,50 +1860,50 @@ def test_tag_placeholder_with_multiple_policies(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy2\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-*\",\"order\":51}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy2\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash"). with(body: "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy2"). with(basic_auth: ['john', 'doe'], body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"80gb\",\"max_age\":\"20d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -1942,86 +1950,86 @@ def test_template_create_with_rollover_index_and_default_ilm_and_placeholders(da # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash-tag1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-tag1"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-tag1"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-tag1\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-tag1-*\",\"order\":52}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-tag1"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-tag1-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-tag1\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":102}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-tag1-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-tag1-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash-tag1"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"logstash-tag1\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash-tag2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-tag2"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-tag2"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-tag2\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-tag2-*\",\"order\":52}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-tag2"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash-tag2-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-tag2\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":102}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-tag2-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-tag2-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash-tag2"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"logstash-tag2\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -2074,51 +2082,51 @@ def test_template_create_with_rollover_index_and_default_ilm_and_placeholders_an # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/logstash.tag1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash.tag1"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash.tag1"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash.tag1\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash.tag1.*\",\"order\":52}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash.tag1"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"logstash.tag1.*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash.tag1\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":102}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Clogstash.tag1.default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Clogstash.tag1.default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash.tag1"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"logstash.tag1\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -2177,45 +2185,45 @@ def test_template_create_with_rollover_index_and_default_ilm_and_custom_and_time # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/#{task_def_value}-#{date_str}"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/#{task_def_value}-#{date_str}"). with(basic_auth: ['john', 'doe'], body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"#{task_def_value}-#{date_str}\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"#{task_def_value}-#{date_str}-*\",\"order\":52}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/#{task_def_value}-#{date_str}"). with(basic_auth: ['john', 'doe'], body: "{\"index_patterns\":\"task_definition-#{date_str}-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"task_definition-#{date_str}\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":102}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) end # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/#{task_def_value}-#{date_str}"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3C#{task_def_value}-#{date_str}-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3C#{task_def_value}-#{date_str}-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/#{task_def_value}-#{date_str}"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"#{task_def_value}-#{date_str}\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -2263,15 +2271,15 @@ def test_custom_template_create(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -2309,18 +2317,18 @@ def test_custom_template_create_with_customize_template_related_placeholders(dat # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template-test.template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template-test.template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test-default-000001%3E"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) driver(config) @@ -2365,14 +2373,14 @@ def test_custom_template_installation_for_host_placeholder(data) # connection start stub_request(:head, "https://logs-test.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs-test.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs-test.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) driver(config) @@ -2417,27 +2425,27 @@ def test_custom_template_with_rollover_index_create(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation of index which can rollover stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -2480,27 +2488,27 @@ def test_custom_template_with_rollover_index_create_and_deflector_alias(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation of index which can rollover stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/myapp_deflector"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -2544,28 +2552,28 @@ def test_custom_template_with_rollover_index_create_with_logstash_format(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation of index which can rollover stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-#{timestr}-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs-#{timestr}"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-#{timestr}-000001%3E/#{alias_endpoint}/mylogs-#{timestr}"). with(basic_auth: ['john', 'doe'], body: "{\"aliases\":{\"mylogs-#{timestr}\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) driver(config) @@ -2635,52 +2643,52 @@ def test_custom_template_with_rollover_index_create_and_default_ilm(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation of index which can rollover stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs"). with(basic_auth: ['john', 'doe'], body: "{\"order\":6,\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}},\"index_patterns\":\"mylogs-*\"}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs"). with(basic_auth: ['john', 'doe'], body: "{\"priority\":106,\"index_patterns\":\"mylogs-*\",\"template\":{\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"mylogs\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -2724,52 +2732,52 @@ def test_custom_template_with_rollover_index_create_and_default_ilm_and_ilm_poli # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation of index which can rollover stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs"). with(basic_auth: ['john', 'doe'], body: "{\"order\":6,\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}},\"index_patterns\":\"mylogs-*\"}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs"). with(basic_auth: ['john', 'doe'], body: "{\"priority\":106,\"index_patterns\":\"mylogs-*\",\"template\":{\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"mylogs\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -2841,101 +2849,101 @@ def test_custom_template_with_rollover_index_create_and_default_ilm_and_placehol # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # test-tag1 # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation of index which can rollover stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-test-tag1-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs-test-tag1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag1"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag1"). with(basic_auth: ['john', 'doe'], body: "{\"order\":8,\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs-test-tag1\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}},\"index_patterns\":\"mylogs-test-tag1-*\"}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag1"). with(basic_auth: ['john', 'doe'], body: "{\"priority\":108,\"index_patterns\":\"mylogs-test-tag1-*\",\"template\":{\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs-test-tag1\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-test-tag1-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs-test-tag1"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"mylogs-test-tag1\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # test-tag2 # check if template exists stub_request(:get, "https://logs.google.com:777/es//_template/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//_template/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation of index which can rollover stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-test-tag2-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs-test-tag2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag2"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) if use_legacy_template_flag stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag2"). with(basic_auth: ['john', 'doe'], body: "{\"order\":8,\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs-test-tag2\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}},\"index_patterns\":\"mylogs-test-tag2-*\"}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) else stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag2"). with(basic_auth: ['john', 'doe'], body: "{\"priority\":108,\"index_patterns\":\"mylogs-test-tag2-*\",\"template\":{\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs-test-tag2\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}}}}"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-test-tag2-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs-test-tag2"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"mylogs-test-tag2\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -2989,44 +2997,44 @@ def test_custom_template_with_rollover_index_create_and_custom_ilm(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation of index which can rollover stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs"). with(basic_auth: ['john', 'doe']). - to_return(status: 404, body: "", headers: {}) + to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs"). with(basic_auth: ['john', 'doe']). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs"). with(basic_auth: ['john', 'doe'], :body => "{\"aliases\":{\"mylogs\":{\"is_write_index\":true}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//_xpack"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"}) + to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy"). with(basic_auth: ['john', 'doe'], :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -3064,15 +3072,15 @@ def test_template_overwrite(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -3111,15 +3119,15 @@ def test_custom_template_overwrite(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -3162,27 +3170,27 @@ def test_custom_template_with_rollover_index_overwrite(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # creation of index which can rollover stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if alias exists stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # put the alias for the index stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E/#{alias_endpoint}/myapp_deflector"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -3205,11 +3213,11 @@ def test_template_create_invalid_filename # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//_template/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") assert_raise(RuntimeError) { @@ -3248,17 +3256,17 @@ def test_template_create_for_host_placeholder(data) # connection start stub_request(:head, "https://logs-test.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs-test.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs-test.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_request(:post, "https://logs-test.google.com:777/es//_bulk"). with(basic_auth: ['john', 'doe']). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) driver(config) @@ -3339,28 +3347,28 @@ def test_templates_create(data) stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash3"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) #exists + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) #exists stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash3"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -3398,27 +3406,27 @@ def test_templates_overwrite(data) stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash3"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) #exists + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) #exists stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash3"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -3457,27 +3465,27 @@ def test_templates_are_also_used(data) # connection start stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) #creation stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") driver(config) @@ -3514,21 +3522,21 @@ def test_templates_can_be_partially_created_if_error_occurs(data) } stub_request(:head, "https://logs.google.com:777/es//"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) # check if template exists stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 404, :body => "", :headers => {}) + to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash1"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2"). with(basic_auth: ['john', 'doe']). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info("https://logs.google.com:777/es//") assert_raise(RuntimeError) { @@ -3794,13 +3802,15 @@ def test_password_is_required_if_specify_user def test_content_type_header stub_request(:head, "http://localhost:9200/"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) if Elasticsearch::VERSION >= "6.0.2" elastic_request = stub_request(:post, "http://localhost:9200/_bulk"). - with(headers: { "Content-Type" => "application/x-ndjson" }) + with(headers: { "Content-Type" => "application/x-ndjson" }). + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) else elastic_request = stub_request(:post, "http://localhost:9200/_bulk"). - with(headers: { "Content-Type" => "application/json" }) + with(headers: { "Content-Type" => "application/json" }). + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) end stub_elastic_info driver.run(default_tag: 'test') do @@ -3811,9 +3821,10 @@ def test_content_type_header def test_custom_headers stub_request(:head, "http://localhost:9200/"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) elastic_request = stub_request(:post, "http://localhost:9200/_bulk"). - with(headers: {'custom' => 'header1','and_others' => 'header2' }) + with(headers: {'custom' => 'header1','and_others' => 'header2' }). + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver.configure(%[custom_headers {"custom":"header1", "and_others":"header2"}]) driver.run(default_tag: 'test') do @@ -3824,9 +3835,10 @@ def test_custom_headers def test_api_key_header stub_request(:head, "http://localhost:9200/"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) elastic_request = stub_request(:post, "http://localhost:9200/_bulk"). - with(headers: {'Authorization'=>'ApiKey dGVzdGF1dGhoZWFkZXI='}) + with(headers: {'Authorization'=>'ApiKey dGVzdGF1dGhoZWFkZXI='}). + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver.configure(%[api_key testauthheader]) driver.run(default_tag: 'test') do @@ -3895,7 +3907,7 @@ def test_writes_to_default_index_with_compression compressed_body = gzip(bodystr, Zlib::DEFAULT_COMPRESSION) elastic_request = stub_request(:post, "http://localhost:9200/_bulk"). - to_return(:status => 200, :headers => {'Content-Type' => 'Application/json'}, :body => compressed_body) + to_return(:status => 200, :headers => {'Content-Type' => 'Application/json', 'x-elastic-product' => 'Elasticsearch'}, :body => compressed_body) stub_elastic_info("http://localhost:9200/") driver(config) @@ -3975,7 +3987,7 @@ def test_writes_with_record_metadata with( body: /#{index_part}\n{"age":26,"request_id":"42","parent_id":"parent","routing_id":"routing","#{chunk_id_key}":".*"}\n/) do |req| @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) } - end + end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) stub_elastic_info driver.run(default_tag: 'test', shutdown: false) do driver.feed(sample_record) @@ -4137,7 +4149,7 @@ def stub_elastic_affinity_target_index_search_with_body(url="http://localhost:92 ) .to_return(lambda do |req| { :status => 200, - :headers => { 'Content-Type' => 'json' }, + :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch'}, :body => return_body_str } end) @@ -5493,7 +5505,7 @@ def test_connection_failed stub_request(:post, "http://localhost:9200/_bulk").with do |req| connection_resets += 1 raise Faraday::ConnectionFailed, "Test message" - end + end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) { @@ -5510,7 +5522,7 @@ def test_reconnect_on_error_enabled stub_request(:post, "http://localhost:9200/_bulk").with do |req| connection_resets += 1 raise ZeroDivisionError, "any not host_unreachable_exceptions exception" - end + end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver.configure("reconnect_on_error true\n") @@ -5537,7 +5549,7 @@ def test_reconnect_on_error_disabled stub_request(:post, "http://localhost:9200/_bulk").with do |req| connection_resets += 1 raise ZeroDivisionError, "any not host_unreachable_exceptions exception" - end + end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver.configure("reconnect_on_error false\n") @@ -5561,7 +5573,7 @@ def test_bulk_error_retags_when_configured stub_request(:post, 'http://localhost:9200/_bulk') .to_return(lambda do |req| { :status => 200, - :headers => { 'Content-Type' => 'json' }, + :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch'}, :body => %({ "took" : 1, "errors" : true, @@ -5621,7 +5633,7 @@ def client_library_version stub_request(:post, 'http://localhost:9200/_bulk') .to_return(lambda do |req| { :status => 200, - :headers => { 'Content-Type' => 'json' }, + :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch'}, :body => %({ "took" : 1, "errors" : true, @@ -5673,7 +5685,7 @@ def test_create_should_write_records_with_ids_and_skip_those_without stub_request(:post, 'http://localhost:9200/_bulk') .to_return(lambda do |req| { :status => 200, - :headers => { 'Content-Type' => 'json' }, + :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' }, :body => %({ "took" : 1, "errors" : true, @@ -5724,7 +5736,7 @@ def test_create_should_write_records_with_ids_and_emit_those_without stub_request(:post, 'http://localhost:9200/_bulk') .to_return(lambda do |req| { :status => 200, - :headers => { 'Content-Type' => 'json' }, + :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' }, :body => %({ "took" : 1, "errors" : true, @@ -5774,7 +5786,7 @@ def test_bulk_error stub_request(:post, 'http://localhost:9200/_bulk') .to_return(lambda do |req| { :status => 200, - :headers => { 'Content-Type' => 'json' }, + :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch'}, :body => %({ "took" : 1, "errors" : true, diff --git a/test/plugin/test_out_elasticsearch_data_stream.rb b/test/plugin/test_out_elasticsearch_data_stream.rb index 1a534481..5fd3fc6d 100644 --- a/test/plugin/test_out_elasticsearch_data_stream.rb +++ b/test/plugin/test_out_elasticsearch_data_stream.rb @@ -92,40 +92,40 @@ def sample_record_no_timestamp NONEXISTENT_DATA_STREAM_EXCEPTION = {"error": {}, "status": 404} def stub_ilm_policy(name="foo_ilm_policy", url="http://localhost:9200") - stub_request(:put, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED]) + stub_request(:put, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'}) end def stub_index_template(name="foo_tpl", url="http://localhost:9200") - stub_request(:put, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED]) + stub_request(:put, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'}) end def stub_data_stream(name="foo", url="http://localhost:9200") - stub_request(:put, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED]) + stub_request(:put, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'}) end def stub_existent_data_stream?(name="foo", url="http://localhost:9200") - stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED]) + stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'}) end def stub_existent_ilm?(name="foo_ilm_policy", url="http://localhost:9200") - stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED]) + stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'}) end def stub_existent_template?(name="foo_tpl", url="http://localhost:9200") - stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED]) + stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [200, RESPONSE_ACKNOWLEDGED], :headers => {'x-elastic-product' => 'Elasticsearch'}) end def stub_nonexistent_data_stream?(name="foo", url="http://localhost:9200") - stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound]) + stub_request(:get, "#{url}/_data_stream/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'}) end def stub_nonexistent_ilm?(name="foo_ilm_policy", url="http://localhost:9200") - stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound]) + stub_request(:get, "#{url}/#{ilm_endpoint}/policy/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'}) end def stub_nonexistent_template?(name="foo_tpl", url="http://localhost:9200") - stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound]) + stub_request(:get, "#{url}/_index_template/#{name}").to_return(:status => [404, TRANSPORT_CLASS::Transport::Errors::NotFound], :headers => {'x-elastic-product' => 'Elasticsearch'}) end @@ -141,7 +141,7 @@ def push_bulk_request(req_body) def stub_nonexistent_template_retry?(name="foo_tpl", url="http://localhost:9200") stub_request(:get, "#{url}/_index_template/#{name}"). - to_return({ status: 500, body: 'Internal Server Error' }, { status: 404, body: '{}' }) + to_return({ status: 500, body: 'Internal Server Error' }, { status: 404, body: '{}', :headers => {'x-elastic-product' => 'Elasticsearch'} }) end def stub_bulk_feed(datastream_name="foo", ilm_name="foo_ilm_policy", template_name="foo_tpl", url="http://localhost:9200") @@ -150,19 +150,19 @@ def stub_bulk_feed(datastream_name="foo", ilm_name="foo_ilm_policy", template_na # {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar # {"@timestamp": ...} push_bulk_request(req.body) - end + end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) stub_request(:post, "#{url}/#{ilm_name}/_bulk").with do |req| # bulk data must be pair of OP and records # {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar # {"@timestamp": ...} push_bulk_request(req.body) - end + end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) stub_request(:post, "#{url}/#{template_name}/_bulk").with do |req| # bulk data must be pair of OP and records # {"create": {}}\nhttp://localhost:9200/_ilm/policy/foo_ilm_bar # {"@timestamp": ...} push_bulk_request(req.body) - end + end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) end def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_version, headers={}) @@ -189,7 +189,7 @@ def stub_elastic_with_store_index_command_counts(url="http://localhost:9200/_bul stub_request(:post, url).with do |req| index_cmds = req.body.split("\n").map {|r| JSON.parse(r) } @index_command_counts[url] += index_cmds.size - end + end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) end def data_stream_supported? @@ -588,7 +588,7 @@ def test_check_content_encoding_header_with_compression stub_default stub_request(:post, "http://localhost:9200/foo/_bulk"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) instance = driver(config).instance @@ -626,7 +626,7 @@ def test_check_compression_option_is_passed_to_transport stub_default stub_request(:post, "http://localhost:9200/foo/_bulk"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) instance = driver(config).instance @@ -849,7 +849,7 @@ def test_placeholder_writes_to_multi_hosts stub_elastic_with_store_index_command_counts("http://#{host}:#{port}/foo_bar/_bulk") stub_elastic_info("http://#{host}:#{port}/") stub_request(:get, "http://#{host}:#{port}/_data_stream/foo_bar"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) end conf = config_element( @@ -919,7 +919,7 @@ def test_writes_to_data_stream_with_compression stub_default elastic_request = stub_request(:post, "http://localhost:9200/foo/_bulk"). - to_return(:status => 200, :headers => {'Content-Type' => 'application/json'}, :body => compressed_body) + to_return(:status => 200, :headers => {'Content-Type' => 'application/json', 'x-elastic-product' => 'Elasticsearch'}, :body => compressed_body) driver(config) driver.run(default_tag: 'test') do @@ -945,7 +945,7 @@ def test_doesnt_update_ilm_policy_if_overwrite_unset stub_data_stream stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/foo_ilm_policy"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) assert_nothing_raised { driver(config) @@ -970,7 +970,7 @@ def test_updates_ilm_policy_if_overwrite_set stub_data_stream stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/foo_ilm_policy"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) assert_nothing_raised { driver(config) @@ -999,7 +999,7 @@ def test_creates_custom_ilm_policy_if_none_exists stub_nonexistent_template?("foo_template") stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/foo_ilm_policy"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) assert_nothing_raised { driver(config) diff --git a/test/plugin/test_out_elasticsearch_dynamic.rb b/test/plugin/test_out_elasticsearch_dynamic.rb index c62c2c05..c1d438e3 100644 --- a/test/plugin/test_out_elasticsearch_dynamic.rb +++ b/test/plugin/test_out_elasticsearch_dynamic.rb @@ -67,7 +67,7 @@ def nested_sample_record def stub_elastic(url="http://localhost:9200/_bulk") stub_request(:post, url).with do |req| @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) } - end + end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) end def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_version) @@ -92,7 +92,7 @@ def stub_elastic_with_store_index_command_counts(url="http://localhost:9200/_bul stub_request(:post, url).with do |req| index_cmds = req.body.split("\n").map {|r| JSON.parse(r) } @index_command_counts[url] += index_cmds.size - end + end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } }) end def assert_logs_include(logs, msg, exp_matches=1) @@ -182,7 +182,7 @@ def test_configure end stub_request(:post, "http://localhost:9200/_bulk"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver.run(default_tag: 'test') do driver.feed(sample_record) @@ -215,7 +215,7 @@ def test_configure end stub_request(:post, "http://localhost:9200/_bulk"). - to_return(status: 200, body: "", headers: {}) + to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver.run(default_tag: 'test') do driver.feed(sample_record) @@ -387,13 +387,15 @@ def test_single_host_params_and_defaults_with_escape_placeholders def test_content_type_header stub_request(:head, "http://localhost:9200/"). - to_return(:status => 200, :body => "", :headers => {}) + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) if Elasticsearch::VERSION >= "6.0.2" elastic_request = stub_request(:post, "http://localhost:9200/_bulk"). - with(headers: { "Content-Type" => "application/x-ndjson" }) + with(headers: { "Content-Type" => "application/x-ndjson"}). + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) else elastic_request = stub_request(:post, "http://localhost:9200/_bulk"). - with(headers: { "Content-Type" => "application/json" }) + with(headers: { "Content-Type" => "application/json"}). + to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) end stub_elastic_info('http://localhost:9200') @@ -444,7 +446,7 @@ def test_writes_to_default_index_with_compression compressed_body = gzip(bodystr, Zlib::DEFAULT_COMPRESSION) elastic_request = stub_request(:post, "http://localhost:9200/_bulk"). - to_return(:status => 200, :headers => {'Content-Type' => 'Application/json'}, :body => compressed_body) + to_return(:status => 200, :headers => {'Content-Type' => 'Application/json', 'x-elastic-product' => 'Elasticsearch'}, :body => compressed_body) stub_elastic_info driver(config) @@ -1122,7 +1124,7 @@ def test_connection_failed stub_request(:post, "http://localhost:9200/_bulk").with do |req| connection_resets += 1 raise Faraday::ConnectionFailed, "Test message" - end + end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) { @@ -1139,7 +1141,7 @@ def test_reconnect_on_error_enabled stub_request(:post, "http://localhost:9200/_bulk").with do |req| connection_resets += 1 raise ZeroDivisionError, "any not host_unreachable_exceptions exception" - end + end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver.configure("reconnect_on_error true\n") @@ -1166,7 +1168,7 @@ def test_reconnect_on_error_disabled stub_request(:post, "http://localhost:9200/_bulk").with do |req| connection_resets += 1 raise ZeroDivisionError, "any not host_unreachable_exceptions exception" - end + end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) stub_elastic_info driver.configure("reconnect_on_error false\n")