-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix empty queue condition for queue shutdown drain, PR #7575
page test queue test move is_empty? at queue level new wrapped acked queue spec
- Loading branch information
1 parent
f3f24dc
commit aedf397
Showing
8 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
logstash-core/spec/logstash/util/wrapped_acked_queue_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# encoding: utf-8 | ||
require "spec_helper" | ||
require "logstash/util/wrapped_acked_queue" | ||
|
||
describe LogStash::Util::WrappedAckedQueue do | ||
shared_examples "queue tests" do | ||
it "is_empty? on creation" do | ||
expect(queue.is_empty?).to be_truthy | ||
end | ||
|
||
it "not is_empty? after pushing an element" do | ||
queue.push(LogStash::Event.new) | ||
expect(queue.is_empty?).to be_falsey | ||
end | ||
|
||
it "not is_empty? when all elements are not acked" do | ||
queue.push(LogStash::Event.new) | ||
batch = queue.read_batch(1, 250) | ||
expect(batch.get_elements.size).to eq(1) | ||
expect(queue.is_empty?).to be_falsey | ||
end | ||
|
||
it "is_empty? when all elements are acked" do | ||
queue.push(LogStash::Event.new) | ||
batch = queue.read_batch(1, 250) | ||
expect(batch.get_elements.size).to eq(1) | ||
expect(queue.is_empty?).to be_falsey | ||
batch.close | ||
expect(queue.is_empty?).to be_truthy | ||
end | ||
end | ||
|
||
context "memory" do | ||
let(:page_capacity) { 1024 } | ||
let(:max_events) { 0 } | ||
let(:max_bytes) { 0 } | ||
let(:path) { Stud::Temporary.directory } | ||
let(:queue) { LogStash::Util::WrappedAckedQueue.create_memory_based(path, page_capacity, max_events, max_bytes) } | ||
|
||
after do | ||
queue.close | ||
end | ||
|
||
include_examples "queue tests" | ||
end | ||
|
||
context "persisted" do | ||
let(:page_capacity) { 1024 } | ||
let(:max_events) { 0 } | ||
let(:max_bytes) { 0 } | ||
let(:checkpoint_acks) { 1024 } | ||
let(:checkpoint_writes) { 1024 } | ||
let(:checkpoint_interval) { 0 } | ||
let(:path) { Stud::Temporary.directory } | ||
let(:queue) { LogStash::Util::WrappedAckedQueue.create_file_based(path, page_capacity, max_events, checkpoint_acks, checkpoint_writes, checkpoint_interval, max_bytes) } | ||
|
||
after do | ||
queue.close | ||
end | ||
|
||
include_examples "queue tests" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters