|
102 | 102 | it 'should not install the default policy' do |
103 | 103 | subject.register |
104 | 104 | sleep(1) |
105 | | - expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound) |
| 105 | + expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class) |
106 | 106 | end |
107 | 107 |
|
108 | 108 | it 'should not write the ILM settings into the template' do |
|
282 | 282 | subject.register |
283 | 283 | sleep(1) |
284 | 284 | expect(@es.indices.exists_alias(name: "logstash")).to be_truthy |
285 | | - expect(@es.get_alias(name: "logstash")).to include("logstash-000001") |
| 285 | + expect(@es.indices.get_alias(name: "logstash")).to include("logstash-000001") |
286 | 286 | end |
287 | 287 | end |
288 | 288 |
|
289 | 289 | it 'should install it if it is not present' do |
290 | | - expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound) |
| 290 | + expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class) |
291 | 291 | subject.register |
292 | 292 | sleep(1) |
293 | 293 | expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.not_to raise_error |
|
298 | 298 | subject.register |
299 | 299 | sleep(1) |
300 | 300 | expect(@es.indices.exists_alias(name: "logstash")).to be_truthy |
301 | | - expect(@es.get_alias(name: "logstash")).to include("logstash-#{todays_date}-000001") |
| 301 | + expect(@es.indices.get_alias(name: "logstash")).to include("logstash-#{todays_date}-000001") |
302 | 302 | end |
303 | 303 |
|
304 | 304 | it 'should ingest into a single index' do |
|
340 | 340 | let (:policy) { small_max_doc_policy } |
341 | 341 |
|
342 | 342 | before do |
343 | | - expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound) |
| 343 | + expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class) |
344 | 344 | put_policy(@es,ilm_policy_name, policy) |
345 | 345 | end |
346 | 346 |
|
347 | 347 | it 'should not install the default policy if it is not used' do |
348 | 348 | subject.register |
349 | 349 | sleep(1) |
350 | | - expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound) |
| 350 | + expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class) |
351 | 351 | end |
352 | 352 | end |
353 | 353 |
|
|
357 | 357 | let (:policy) { max_age_policy("1d") } |
358 | 358 |
|
359 | 359 | before do |
360 | | - expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound) |
| 360 | + expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class) |
361 | 361 | put_policy(@es,ilm_policy_name, policy) |
362 | 362 | end |
363 | 363 |
|
364 | 364 | it 'should not install the default policy if it is not used' do |
365 | 365 | subject.register |
366 | 366 | sleep(1) |
367 | | - expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound) |
| 367 | + expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(get_expected_error_class) |
368 | 368 | end |
369 | 369 | end |
370 | 370 |
|
|
374 | 374 | subject.register |
375 | 375 | sleep(1) |
376 | 376 | expect(@es.indices.exists_alias(name: expected_index)).to be_truthy |
377 | | - expect(@es.get_alias(name: expected_index)).to include("#{expected_index}-#{todays_date}-000001") |
| 377 | + expect(@es.indices.get_alias(name: expected_index)).to include("#{expected_index}-#{todays_date}-000001") |
378 | 378 | end |
379 | 379 |
|
380 | 380 | it 'should write the ILM settings into the template' do |
|
443 | 443 | subject.register |
444 | 444 | sleep(1) |
445 | 445 | expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy |
446 | | - expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001") |
| 446 | + expect(@es.indices.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001") |
447 | 447 | end |
448 | 448 |
|
449 | 449 | context 'when the custom rollover alias already exists' do |
450 | 450 | it 'should ignore the already exists error' do |
451 | 451 | expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_falsey |
452 | | - put_alias(@es, "#{ilm_rollover_alias}-#{todays_date}-000001", ilm_rollover_alias) |
| 452 | + @es.indices.create(index: "#{ilm_rollover_alias}-#{todays_date}-000001") |
| 453 | + @es.indices.put_alias(name: ilm_rollover_alias, index: "#{ilm_rollover_alias}-#{todays_date}-000001") |
453 | 454 | expect(@es.indices.exists_alias(name: ilm_rollover_alias)).to be_truthy |
454 | 455 | subject.register |
455 | 456 | sleep(1) |
456 | | - expect(@es.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001") |
| 457 | + expect(@es.indices.get_alias(name: ilm_rollover_alias)).to include("#{ilm_rollover_alias}-#{todays_date}-000001") |
457 | 458 | end |
458 | 459 |
|
459 | 460 | end |
|
532 | 533 | end |
533 | 534 |
|
534 | 535 | end |
| 536 | + |
| 537 | +def get_expected_error_class |
| 538 | + return Elastic::Transport::Transport::Errors::NotFound if elastic_ruby_v8_client_available? |
| 539 | + Elasticsearch::Transport::Transport::Errors::NotFound |
| 540 | +end |
0 commit comments