|
8 | 8 | let (:settings) { super.merge("ilm_policy" => ilm_policy_name)} |
9 | 9 |
|
10 | 10 | it 'should rollover when the policy max docs is reached' do |
11 | | - put_policy(@es,ilm_policy_name, policy) |
| 11 | + put_policy(@es, ilm_policy_name, policy) |
12 | 12 | subject.register |
13 | 13 |
|
14 | 14 | subject.multi_receive([ |
|
108 | 108 | it 'should not write the ILM settings into the template' do |
109 | 109 | subject.register |
110 | 110 | sleep(1) |
111 | | - expect(@es.indices.get_template(name: "logstash")["logstash"]).to have_index_pattern("logstash-*") |
| 111 | + |
| 112 | + template = get_template(@es, "logstash") |
| 113 | + expect(template).to have_index_pattern("logstash-*") |
112 | 114 | if ESHelper.es_version_satisfies?(">= 2") |
113 | | - expect(@es.indices.get_template(name: "logstash")["logstash"]["settings"]['index']['lifecycle']).to be_nil |
| 115 | + expect(get_template_settings(template)['index']['lifecycle']).to be_nil |
114 | 116 | end |
115 | 117 | end |
116 | 118 |
|
|
152 | 154 | end |
153 | 155 |
|
154 | 156 | context 'with a custom template name' do |
155 | | - let (:template_name) { "custom_template_name" } |
| 157 | + let (:template_name) { "logstash_custom_template_name" } |
156 | 158 | let (:settings) { super.merge('template_name' => template_name)} |
157 | 159 |
|
158 | 160 | it 'should not write the ILM settings into the template' do |
159 | 161 | subject.register |
160 | 162 | sleep(1) |
161 | 163 |
|
162 | | - expect(@es.indices.get_template(name: template_name)[template_name]).to have_index_pattern("logstash-*") |
| 164 | + template = get_template(@es, template_name) |
| 165 | + expect(template).to have_index_pattern("logstash-*") |
163 | 166 | if ESHelper.es_version_satisfies?(">= 2") |
164 | | - expect(@es.indices.get_template(name: template_name)[template_name]["settings"]['index']['lifecycle']).to be_nil |
| 167 | + expect(get_template_settings(template)['index']['lifecycle']).to be_nil |
165 | 168 | end |
166 | 169 | end |
167 | 170 | end |
|
387 | 390 | it 'should write the ILM settings into the template' do |
388 | 391 | subject.register |
389 | 392 | sleep(1) |
390 | | - expect(@es.indices.get_template(name: "logstash")["logstash"]).to have_index_pattern("logstash-*") |
391 | | - expect(@es.indices.get_template(name: "logstash")["logstash"]["settings"]['index']['lifecycle']['name']).to eq("logstash-policy") |
392 | | - expect(@es.indices.get_template(name: "logstash")["logstash"]["settings"]['index']['lifecycle']['rollover_alias']).to eq("logstash") |
| 393 | + |
| 394 | + template = get_template(@es, "logstash") |
| 395 | + expect(template).to have_index_pattern("logstash-*") |
| 396 | + expect(get_template_settings(template)['index']['lifecycle']['name']).to eq("logstash-policy") |
| 397 | + expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq("logstash") |
393 | 398 | end |
394 | 399 |
|
395 | 400 | it_behaves_like 'an ILM enabled Logstash' |
396 | 401 | end |
397 | 402 |
|
398 | 403 | context 'with a set index and a custom index pattern' do |
399 | | - if ESHelper.es_version_satisfies?(">= 7.0") |
| 404 | + if ESHelper.es_version_satisfies?(">= 8.0") |
| 405 | + let (:template) { "spec/fixtures/template-with-policy-es8x.json" } |
| 406 | + elsif ESHelper.es_version_satisfies?(">= 7.0") |
400 | 407 | let (:template) { "spec/fixtures/template-with-policy-es7x.json" } |
401 | 408 | else |
402 | 409 | let (:template) { "spec/fixtures/template-with-policy-es6x.json" } |
|
408 | 415 | it 'should not overwrite the index patterns' do |
409 | 416 | subject.register |
410 | 417 | sleep(1) |
411 | | - expect(@es.indices.get_template(name: "logstash")["logstash"]).to have_index_pattern("overwrite-*") |
| 418 | + |
| 419 | + template = get_template(@es, "logstash") |
| 420 | + expect(template).to have_index_pattern("overwrite-*") |
412 | 421 | end |
413 | 422 | end |
414 | 423 |
|
415 | 424 |
|
416 | 425 | context 'with a custom template' do |
417 | | - let (:ilm_rollover_alias) { "the_cat_in_the_hat" } |
| 426 | + let (:ilm_rollover_alias) { "logstash_the_cat_in_the_hat" } |
418 | 427 | let (:index) { ilm_rollover_alias } |
419 | 428 | let(:expected_index) { index } |
420 | 429 | let (:settings) { super.merge("ilm_policy" => ilm_policy_name, |
421 | 430 | "template" => template, |
422 | 431 | "ilm_rollover_alias" => ilm_rollover_alias)} |
423 | 432 |
|
424 | 433 |
|
425 | | - if ESHelper.es_version_satisfies?(">= 7.0") |
| 434 | + if ESHelper.es_version_satisfies?(">= 8.0") |
| 435 | + let (:template) { "spec/fixtures/template-with-policy-es8x.json" } |
| 436 | + elsif ESHelper.es_version_satisfies?(">= 7.0") |
426 | 437 | let (:template) { "spec/fixtures/template-with-policy-es7x.json" } |
427 | 438 | else |
428 | 439 | let (:template) { "spec/fixtures/template-with-policy-es6x.json" } |
|
460 | 471 | it 'should write the ILM settings into the template' do |
461 | 472 | subject.register |
462 | 473 | sleep(1) |
463 | | - expect(@es.indices.get_template(name: ilm_rollover_alias)[ilm_rollover_alias]).to have_index_pattern("#{ilm_rollover_alias}-*") |
464 | | - expect(@es.indices.get_template(name: ilm_rollover_alias)[ilm_rollover_alias]["settings"]['index']['lifecycle']['name']).to eq(ilm_policy_name) |
465 | | - expect(@es.indices.get_template(name: ilm_rollover_alias)[ilm_rollover_alias]["settings"]['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias) |
| 474 | + |
| 475 | + template = get_template(@es, ilm_rollover_alias) |
| 476 | + expect(template).to have_index_pattern("#{ilm_rollover_alias}-*") |
| 477 | + expect(get_template_settings(template)['index']['lifecycle']['name']).to eq(ilm_policy_name) |
| 478 | + expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias) |
466 | 479 | end |
467 | 480 |
|
468 | 481 | context 'with a different template_name' do |
469 | | - let (:template_name) { "custom_template_name" } |
| 482 | + let (:template_name) { "logstash_custom_template_name" } |
470 | 483 | let (:settings) { super.merge('template_name' => template_name)} |
471 | 484 |
|
472 | 485 | it_behaves_like 'an ILM enabled Logstash' |
473 | 486 |
|
474 | 487 | it 'should write the ILM settings into the template' do |
475 | 488 | subject.register |
476 | 489 | sleep(1) |
477 | | - expect(@es.indices.get_template(name: template_name)[template_name]).to have_index_pattern("#{ilm_rollover_alias}-*") |
478 | | - expect(@es.indices.get_template(name: template_name)[template_name]["settings"]['index']['lifecycle']['name']).to eq(ilm_policy_name) |
479 | | - expect(@es.indices.get_template(name: template_name)[template_name]["settings"]['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias) |
| 490 | + template = get_template(@es, template_name) |
| 491 | + expect(template).to have_index_pattern("#{ilm_rollover_alias}-*") |
| 492 | + expect(get_template_settings(template)['index']['lifecycle']['name']).to eq(ilm_policy_name) |
| 493 | + expect(get_template_settings(template)['index']['lifecycle']['rollover_alias']).to eq(ilm_rollover_alias) |
480 | 494 | end |
481 | 495 | end |
482 | 496 |
|
|
0 commit comments