spec/out_groupcounter_spec.rb in fluent-plugin-groupcounter-0.2.2 vs spec/out_groupcounter_spec.rb in fluent-plugin-groupcounter-0.2.3
- old
+ new
@@ -12,15 +12,15 @@
before { Fluent::Test.setup }
CONFIG = %[
count_interval 5s
aggragate tag
output_per_tag true
- tag_prefix count
+ add_tag_prefix count
group_by_keys code,method,path
]
- let(:tag) { 'test' }
+ let(:tag) { 'test.hoge' }
let(:driver) { Fluent::Test::OutputTestDriver.new(Fluent::GroupCounterOutput, tag).configure(config) }
describe 'test configure' do
describe 'good configuration' do
subject { driver.instance }
@@ -30,24 +30,24 @@
its(:count_interval) { should == 60 }
its(:unit) { should == 'minute' }
its(:output_per_tag) { should == false }
its(:aggregate) { should == :tag }
its(:tag) { should == 'groupcount' }
- its(:tag_prefix) { should be_nil }
- its(:input_tag_remove_prefix) { should be_nil }
+ its(:add_tag_prefix) { should be_nil }
+ its(:remove_tag_prefix) { should be_nil }
its(:group_by_keys) { should == %w[foo] }
end
context "test template configuration" do
let(:config) { CONFIG }
its(:count_interval) { should == 5 }
its(:unit) { should == 'minute' }
its(:output_per_tag) { should == true }
its(:aggregate) { should == :tag }
its(:tag) { should == 'groupcount' }
- its(:tag_prefix) { should == 'count' }
- its(:input_tag_remove_prefix) { should be_nil }
+ its(:add_tag_prefix) { should == 'count' }
+ its(:remove_tag_prefix) { should be_nil }
its(:group_by_keys) { should == %w[code method path] }
end
end
end
@@ -72,11 +72,11 @@
"200_POST_/auth_count"=>1,
"400_GET_/ping_count"=>1,
}
end
let(:expected_with_tag) do
- Hash[*(expected.map {|key, val| next ["test_#{key}", val] }.flatten)]
+ Hash[*(expected.map {|key, val| next ["test.hoge_#{key}", val] }.flatten)]
end
context 'typical' do
let(:config) { CONFIG }
before do
@@ -215,11 +215,11 @@
end
context 'no group_by' do
let(:config) do
%[
- tag_prefix count
+ add_tag_prefix count
output_per_tag true
count_suffix count
max_key reqtime
min_key reqtime
@@ -269,33 +269,78 @@
end
it { emit }
end
end
- context 'tag_prefix' do
+ context 'tag_prefix (obsolete)' do
let(:config) do
- CONFIG + %[
+ %[
+ count_interval 5s
+ aggragate tag
+ output_per_tag true
tag_prefix foo
+ group_by_keys code,method,path
]
end
before do
Fluent::Engine.stub(:now).and_return(time)
Fluent::Engine.should_receive(:emit).with("foo.#{tag}", time, expected)
end
it { emit }
end
+ context 'add_tag_prefix' do
+ let(:config) do
+ CONFIG + %[
+ add_tag_prefix foo
+ ]
+ end
+ before do
+ Fluent::Engine.stub(:now).and_return(time)
+ Fluent::Engine.should_receive(:emit).with("foo.#{tag}", time, expected)
+ end
+ it { emit }
+ end
+
+ context 'input_tag_remove_prefix (obsolete)' do
+ let(:config) do
+ CONFIG + %[
+ add_tag_prefix foo
+ input_tag_remove_prefix test
+ ]
+ end
+ before do
+ Fluent::Engine.stub(:now).and_return(time)
+ Fluent::Engine.should_receive(:emit).with("foo.hoge", time, expected)
+ end
+ it { emit }
+ end
+
+ context 'remove_tag_prefix' do
+ let(:config) do
+ CONFIG + %[
+ add_tag_prefix foo
+ remove_tag_prefix test
+ ]
+ end
+ before do
+ Fluent::Engine.stub(:now).and_return(time)
+ Fluent::Engine.should_receive(:emit).with("foo.hoge", time, expected)
+ end
+ it { emit }
+ end
+
context 'aggregate all' do
let(:emit) do
driver.run { messages.each {|message| driver.emit_with_tag(message, time, 'foo.bar') } }
driver.run { messages.each {|message| driver.emit_with_tag(message, time, 'foo.bar2') } }
driver.instance.flush_emit
end
let(:config) do
CONFIG + %[
aggregate all
- tag_prefix count
+ add_tag_prefix count
]
end
before do
Fluent::Engine.stub(:now).and_return(time)