Skip to content

Commit

Permalink
Add failing acceptance test for service restart
Browse files Browse the repository at this point in the history
In systemd, the service is currently not being restarted after
configuration changes.  See GH-382

The acceptance test in this commit reconfigures prometheus with
the admin API enabled and then attempts to access it.

See https://prometheus.io/docs/prometheus/latest/querying/api/#tsdb-admin-apis
  • Loading branch information
alexjfisher committed Nov 18, 2019
1 parent 0c5e1a1 commit 20dc6a7
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion spec/acceptance/prometheus_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'prometheus server basics' do
it 'prometheus server via main class works idempotently with no errors' do
pp = "class{'prometheus': manage_prometheus_server => true, version => '1.5.2' }"
pp = "class{'prometheus': manage_prometheus_server => true }"

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
Expand Down Expand Up @@ -32,6 +32,29 @@
it { is_expected.to be_listening.with('tcp6') }
end

it 'does not allow admin API' do # rubocop:disable RSpec/MultipleExpectations
shell('curl -s -XPOST http://127.0.0.1:9090/api/v1/admin/tsdb/snapshot') do |r|
expect(r.stdout).to match(%r{admin APIs disabled})
expect(r.exit_code).to eq(0)
end
end

describe 'updating configuration to enable Admin API' do
it 'prometheus server via main class works idempotently with no errors' do
pp = "class{'prometheus': manage_prometheus_server => true, web_enable_admin_api => true }"

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
it 'allows admin API' do # rubocop:disable RSpec/MultipleExpectations
shell('curl -s -XPOST http://127.0.0.1:9090/api/v1/admin/tsdb/snapshot') do |r|
expect(r.stdout).not_to match(%r{admin APIs disabled})
expect(r.stdout).to match(%r{success})
expect(r.exit_code).to eq(0)
end
end
end

describe 'prometheus server with options' do
it 'is idempotent' do
pp = "class{'prometheus::server': version => '2.4.3', external_url => '/test'}"
Expand Down

0 comments on commit 20dc6a7

Please sign in to comment.