Skip to content
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

Emit CommitInterval when writer is configured for database #972

Merged
merged 2 commits into from Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 27 additions & 6 deletions spec/classes/collectd_plugin_postgresql_spec.rb
Expand Up @@ -49,12 +49,6 @@
'valuesfrom' => 'log_delay'
}]
}
},
writers: {
'sqlstore' => {
'statement' => 'SELECT collectd_insert($1, $2, $3, $4, $5, $6, $7, $8, $9);',
'storerates' => true
}
}
}
end
Expand All @@ -66,6 +60,33 @@
is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_query_log_delay').with(content: %r{Statement \"SELECT \* FROM log_delay_repli;\"\n})
is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_query_log_delay').with(content: %r{<Result>\n})
is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_query_log_delay').with(content: %r{Param \"database\"})
end
end

context ':ensure => present and create a db with a custom writer' do
let(:params) do
{
databases: {
'postgres' => {
'host' => 'localhost',
'user' => 'postgres',
'password' => 'postgres',
'interval' => 10,
'writer' => 'sqlstore'
},
},
writers: {
'sqlstore' => {
'statement' => 'SELECT collectd_insert($1, $2, $3, $4, $5, $6, $7, $8, $9);',
'storerates' => true
}
}
}
end

it "Will create #{options[:plugin_conf_dir]}/postgresql-config.conf" do
is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_db_postgres').with(content: %r{Writer \"sqlstore\"})
is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_db_postgres').with(content: %r{CommitInterval 10})
is_expected.to contain_concat__fragment('collectd_plugin_postgresql_conf_writer_sqlstore').with(content: %r{<Writer sqlstore>\n})
end
end
Expand Down
4 changes: 2 additions & 2 deletions templates/plugin/postgresql/database.conf.erb
Expand Up @@ -12,7 +12,7 @@
Password "<%= @password %>"
<% end -%>
<% if @interval -%>
Interval <%= @interval %>
<% if @writer -%>Commit<% end -%>Interval <%= @interval %>
<% end -%>
<% if @instance -%>
Instance "<%= @instance %>"
Expand All @@ -32,4 +32,4 @@
<% @query.each do |query| -%>
Query "<%= query %>"
<% end -%>
</Database>
</Database>