-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/implement different actions #74
Open
nilskuhn
wants to merge
6
commits into
logstash-plugins:main
Choose a base branch
from
iteratec:feature/implementDifferentActions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
91d44f9
:pencil: Added new config settings to ascii doc
nilskuhn 5df1ad3
:bug: Fix for issues #60, #64, #65 and #66
nilskuhn 3ee049d
:sparkles: Support updating and replacing given documents
nilskuhn f1182b6
:bookmark: Set version to 3.2.0
nilskuhn 768c909
:white_check_mark: Added tests
nilskuhn ff4ac81
:bug: Removed partial update support for arrays
nilskuhn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,64 @@ | ||
# encoding: utf-8 | ||
require_relative "../spec_helper" | ||
require "logstash/plugin" | ||
|
||
describe LogStash::Outputs::Mongodb do | ||
|
||
let(:uri) { 'mongodb://localhost:27017' } | ||
let(:database) { 'logstash' } | ||
let(:collection) { 'logs' } | ||
|
||
describe "validate_config method" do | ||
|
||
subject! { LogStash::Outputs::Mongodb.new(config) } | ||
|
||
[ | ||
{:action => "not-supported", :query_key => "qk", :query_value => "qv", :upsert => false, | ||
:expected_reason => "Only insert, update and replace are valid for 'action' setting."}, | ||
{:action => "update", :query_key => "qk", :query_value => nil, :upsert => false, | ||
:expected_reason => "If action is update or replace, query_value must be set."}, | ||
{:action => "update", :query_key => "qk", :query_value => "", :upsert => false, | ||
:expected_reason => "If action is update or replace, query_value must be set."}, | ||
{:action => "replace", :query_key => "qk", :query_value => nil, :upsert => false, | ||
:expected_reason => "If action is update or replace, query_value must be set."}, | ||
{:action => "replace", :query_key => "qk", :query_value => "", :upsert => false, | ||
:expected_reason => "If action is update or replace, query_value must be set."}, | ||
{:action => "insert", :bulk_size => 1001, | ||
:expected_reason => "Bulk size must be lower than '1000', currently '1001'"}, | ||
].each do |test| | ||
|
||
describe "when validating config with action '#{test[:action]}' query_key '#{test[:query_key]}', query_value '#{test[:query_value]}' and upsert '#{test[:upsert]}'" do | ||
|
||
let(:config) { | ||
configuration = { | ||
"uri" => uri, | ||
"database" => database, | ||
"collection" => collection | ||
} | ||
unless test[:action].nil? | ||
configuration["action"] = test[:action] | ||
end | ||
unless test[:query_key].nil? | ||
configuration["query_key"] = test[:query_key] | ||
end | ||
unless test[:query_value].nil? | ||
configuration["query_value"] = test[:query_value] | ||
end | ||
unless test[:upsert].nil? | ||
configuration["upsert"] = test[:upsert] | ||
end | ||
unless test[:bulk_size].nil? | ||
configuration["bulk_size"] = test[:bulk_size] | ||
end | ||
return configuration | ||
} | ||
|
||
it "should raise error: #{test[:expected_reason]}" do | ||
expect { subject.validate_config }.to raise_error(LogStash::ConfigurationError, test[:expected_reason]) | ||
end | ||
end | ||
|
||
end | ||
|
||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage of this is not really clear from this example, would you mind improving it a bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was a week on vacation. Will look into this asap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem take your time as you saw I went a bit beyond the original intent 😃
Hope you like the result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gets clear if you follow the link to mongodb documentation I added to ascii-documentation and take a look at update and replace examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in general you don't want to update a document in mongodb with whole logstash event but instead just increment some fields in mongodb? And do you want to read size to increment fields with from logstash event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I am building projections from the events and I am doing now something like: