|
120 | 120 | res[index_written] += 1
|
121 | 121 | end
|
122 | 122 | expect(indexes_written.count).to eq(3)
|
123 |
| - expect(indexes_written["#{expected_index}-000001"]).to eq(3) |
124 |
| - expect(indexes_written["#{expected_index}-000002"]).to eq(3) |
125 |
| - expect(indexes_written["#{expected_index}-000003"]).to eq(3) |
| 123 | + expect(indexes_written["#{expected_index}-#{todays_date}-000001"]).to eq(3) |
| 124 | + expect(indexes_written["#{expected_index}-#{todays_date}-000002"]).to eq(3) |
| 125 | + expect(indexes_written["#{expected_index}-#{todays_date}-000003"]).to eq(3) |
126 | 126 | end
|
127 | 127 | end
|
128 | 128 |
|
|
161 | 161 | res[index_written] += 1
|
162 | 162 | end
|
163 | 163 | expect(indexes_written.count).to eq(1)
|
164 |
| - expect(indexes_written["#{expected_index}-000001"]).to eq(6) |
| 164 | + expect(indexes_written["#{expected_index}-#{todays_date}-000001"]).to eq(6) |
165 | 165 | end
|
166 | 166 | end
|
167 | 167 | end
|
|
255 | 255 |
|
256 | 256 |
|
257 | 257 | context 'when using the default policy' do
|
| 258 | + context 'with a custom pattern' do |
| 259 | + let (:settings) { super.merge("ilm_pattern" => "000001")} |
| 260 | + it 'should create a write alias' do |
| 261 | + expect(@es.indices.exists_alias(index: "logstash")).to be_falsey |
| 262 | + subject.register |
| 263 | + sleep(1) |
| 264 | + expect(@es.indices.exists_alias(index: "logstash")).to be_truthy |
| 265 | + expect(@es.get_alias(name: "logstash")).to include("logstash-000001") |
| 266 | + end |
| 267 | + end |
| 268 | + |
| 269 | + |
258 | 270 | it 'should install it if it is not present' do
|
259 | 271 | expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
260 | 272 | subject.register
|
|
263 | 275 | end
|
264 | 276 |
|
265 | 277 | it 'should create the default write alias' do
|
266 |
| - |
267 | 278 | expect(@es.indices.exists_alias(index: "logstash")).to be_falsey
|
268 | 279 | subject.register
|
269 | 280 | sleep(1)
|
270 | 281 | expect(@es.indices.exists_alias(index: "logstash")).to be_truthy
|
271 |
| - expect(@es.get_alias(name: "logstash")).to include("logstash-000001") |
| 282 | + expect(@es.get_alias(name: "logstash")).to include("logstash-#{todays_date}-000001") |
272 | 283 | end
|
273 | 284 |
|
| 285 | + |
274 | 286 | it 'should ingest into a single index' do
|
275 | 287 | subject.register
|
276 | 288 |
|
|
301 | 313 | end
|
302 | 314 |
|
303 | 315 | expect(indexes_written.count).to eq(1)
|
304 |
| - expect(indexes_written["logstash-000001"]).to eq(6) |
| 316 | + expect(indexes_written["logstash-#{todays_date}-000001"]).to eq(6) |
305 | 317 | end
|
306 | 318 | end
|
307 | 319 |
|
|
333 | 345 | end
|
334 | 346 | end
|
335 | 347 |
|
| 348 | + context 'when using a time based policy' do |
| 349 | + let (:ilm_policy_name) {"new_one"} |
| 350 | + let (:settings) { super.merge("ilm_policy" => ilm_policy_name)} |
| 351 | + let (:policy) {{ |
| 352 | + "policy" => { |
| 353 | + "phases"=> { |
| 354 | + "hot" => { |
| 355 | + "actions" => { |
| 356 | + "rollover" => { |
| 357 | + "max_age" => "1d" |
| 358 | + } |
| 359 | + } |
| 360 | + } |
| 361 | + } |
| 362 | + }}} |
| 363 | + |
| 364 | + before do |
| 365 | + expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound) |
| 366 | + put_policy(@es,ilm_policy_name, policy) |
| 367 | + end |
| 368 | + |
| 369 | + it 'should not install the default policy if it is not used' do |
| 370 | + subject.register |
| 371 | + sleep(1) |
| 372 | + expect{get_policy(@es, LogStash::Outputs::ElasticSearch::DEFAULT_POLICY)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound) |
| 373 | + end |
| 374 | + end |
336 | 375 | context 'with the default template' do
|
337 | 376 | let(:expected_index) { "logstash" }
|
338 | 377 |
|
|
341 | 380 | subject.register
|
342 | 381 | sleep(1)
|
343 | 382 | expect(@es.indices.exists_alias(index: expected_index)).to be_truthy
|
344 |
| - expect(@es.get_alias(name: expected_index)).to include("#{expected_index}-000001") |
| 383 | + expect(@es.get_alias(name: expected_index)).to include("#{expected_index}-#{todays_date}-000001") |
345 | 384 | end
|
346 | 385 |
|
347 | 386 | it 'should write the ILM settings into the template' do
|
|
382 | 421 | subject.register
|
383 | 422 | sleep(1)
|
384 | 423 | expect(@es.indices.exists_alias(index: ilm_write_alias)).to be_truthy
|
385 |
| - expect(@es.get_alias(name: ilm_write_alias)).to include("#{ilm_write_alias}-000001") |
| 424 | + expect(@es.get_alias(name: ilm_write_alias)).to include("#{ilm_write_alias}-#{todays_date}-000001") |
386 | 425 | end
|
387 | 426 |
|
388 | 427 | it 'should write the ILM settings into the template' do
|
|
0 commit comments