-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for a minimum TTL for events
When running with riemann-wrappers, one may want to run different tools with distinct ttl, but the `--ttl` flag cannot be specified twice, so the following configuration will not work: ``` --- options: --ttl 300 tools: - name: "health" - name: "rdap" options: "--interval 21600 --ttl 86400 --domains example.com example.net" ``` A workaround is to add an explicit ttl for each tool, but it is not convenient. Introduce a `--minimum-ttl` flag that can be used as a global option to circumvent this issue.
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'riemann/tools/health' | ||
|
||
class ExampleTool | ||
include Riemann::Tools | ||
end | ||
|
||
RSpec.describe Riemann::Tools do | ||
describe '#options' do | ||
describe ':ttl' do | ||
subject(:tool) { ExampleTool.new } | ||
|
||
{ | ||
'' => 10, | ||
'--ttl=60' => 60, | ||
'--interval 10' => 20, | ||
'--minimum-ttl 300' => 300, | ||
'--minimum-ttl 300 --ttl=60' => 300, | ||
'--minimum-ttl 30 --ttl 60' => 60, | ||
}.each do |argv, expected_ttl| | ||
context "with ARGV=\"#{argv}\"" do | ||
before do | ||
ARGV.replace argv.split | ||
end | ||
|
||
it { expect(tool.options[:ttl]).to eq expected_ttl } | ||
end | ||
end | ||
end | ||
end | ||
end |