Skip to content

Commit

Permalink
Merge pull request #972 from ph448/master
Browse files Browse the repository at this point in the history
Emit CommitInterval when writer is configured for database
  • Loading branch information
bastelfreak authored Jun 29, 2021
2 parents e134062 + a059cd5 commit 23274fd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
33 changes: 27 additions & 6 deletions spec/classes/collectd_plugin_postgresql_spec.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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>

0 comments on commit 23274fd

Please sign in to comment.