(POOLER-178) Target Stats for api & manager

Ensure that the correct stats are registered for the Manager and the api
respectively. E.g. all checkout counters are for the api only, whereas
clone times belong to the manager.

Also new ondemand functionality stats weren't registered, so add these
along with missing delete stats.
This commit is contained in:
John O'Connor 2020-06-25 19:44:26 +01:00
parent 8ed8c43970
commit a21d8c5642
14 changed files with 128 additions and 28 deletions

View file

@ -40,7 +40,7 @@ describe Vmpooler::API::V1 do
before(:each) do
expect(app).to receive(:run!).once
app.execute(['api'], config, redis, metrics)
app.execute([:api], config, redis, metrics)
app.settings.set :config, auth: false
create_token('abcdefghijklmnopqrstuvwxyz012345', 'jdoe', current_time)
end

View file

@ -43,7 +43,7 @@ describe Vmpooler::API::V1 do
before(:each) do
expect(app).to receive(:run!).once
app.execute(['api'], config, redis, metrics)
app.execute([:api], config, redis, metrics)
app.settings.set :config, auth: false
app.settings.set :checkoutlock, checkoutlock
create_token('abcdefghijklmnopqrstuvwxyz012345', 'jdoe', current_time)

View file

@ -37,7 +37,7 @@ describe Vmpooler::API::V1 do
before(:each) do
expect(app).to receive(:run!).once
app.execute(['api'], config, redis, metrics)
app.execute([:api], config, redis, metrics)
app.settings.set :config, auth: false
create_token('abcdefghijklmnopqrstuvwxyz012345', 'jdoe', current_time)
end

View file

@ -40,7 +40,7 @@ describe Vmpooler::API::V1 do
before(:each) do
expect(app).to receive(:run!).once
app.execute(['api'], config, redis, nil)
app.execute([:api], config, redis, nil)
app.settings.set :config, auth: false
create_token('abcdefghijklmnopqrstuvwxyz012345', 'jdoe', current_time)
end

View file

@ -22,7 +22,7 @@ describe Vmpooler::API::V1 do
before(:each) do
expect(app).to receive(:run!).once
app.execute(['api'], config, redis, nil)
app.execute([:api], config, redis, nil)
end
describe 'GET /token' do
@ -106,7 +106,7 @@ describe Vmpooler::API::V1 do
before(:each) do
expect(app).to receive(:run!).once
app.execute(['api'], config, redis, nil)
app.execute([:api], config, redis, nil)
app.settings.set :config, config
app.settings.set :redis, redis
end

View file

@ -43,7 +43,7 @@ describe Vmpooler::API::V1 do
before(:each) do
expect(app).to receive(:run!).once
app.execute(['api'], config, redis, metrics)
app.execute([:api], config, redis, metrics)
create_token('abcdefghijklmnopqrstuvwxyz012345', 'jdoe', current_time)
end

View file

@ -40,7 +40,7 @@ describe Vmpooler::API::V1 do
before(:each) do
expect(app).to receive(:run!).once
app.execute(['api'], config, redis, metrics)
app.execute([:api], config, redis, metrics)
app.settings.set :config, auth: false
app.settings.set :checkoutlock, checkoutlock
create_token('abcdefghijklmnopqrstuvwxyz012345', 'jdoe', current_time)

View file

@ -41,7 +41,7 @@ describe Vmpooler::API::V1 do
before(:each) do
expect(app).to receive(:run!).once
app.execute(['api'], config, redis, metrics)
app.execute([:api], config, redis, metrics)
app.settings.set :config, auth: false
app.settings.set :checkoutlock, checkoutlock
create_token('abcdefghijklmnopqrstuvwxyz012345', 'jdoe', current_time)

View file

@ -26,7 +26,7 @@ describe Vmpooler::API do
before(:each) do
expect(app).to receive(:run!)
app.execute(['api'], config, redis, nil)
app.execute([:api], config, redis, nil)
app.settings.set :config, auth: false
end

View file

@ -55,7 +55,7 @@ describe 'prometheus' do
context 'setup_prometheus_metrics' do
before(:all) do
Prometheus::Client.config.data_store = Prometheus::Client::DataStores::Synchronized.new
subject.setup_prometheus_metrics
subject.setup_prometheus_metrics(%i[api manager])
end
let(:MCOUNTER) { 1 }
@ -63,7 +63,7 @@ describe 'prometheus' do
it 'calls add_prometheus_metric for each item in list' do
Prometheus::Client.config.data_store = Prometheus::Client::DataStores::Synchronized.new
expect(subject).to receive(:add_prometheus_metric).at_least(subject.vmpooler_metrics_table.size).times
subject.setup_prometheus_metrics
subject.setup_prometheus_metrics(%i[api manager])
end
end
@ -102,6 +102,48 @@ describe 'prometheus' do
po.get(labels: metric[:labels])
}.by(1)
end
it 'Increments delete.failed' do
bad_template = 'test-template'
expect { subject.increment('delete.failed') }.to change {
metric, po = subject.get('delete.failed')
po.get(labels: metric[:labels])
}.by(1)
end
it 'Increments delete.success' do
bad_template = 'test-template'
expect { subject.increment('delete.success') }.to change {
metric, po = subject.get('delete.success')
po.get(labels: metric[:labels])
}.by(1)
end
it 'Increments ondemandrequest_generate.duplicaterequests' do
bad_template = 'test-template'
expect { subject.increment('ondemandrequest_generate.duplicaterequests') }.to change {
metric, po = subject.get('ondemandrequest_generate.duplicaterequests')
po.get(labels: metric[:labels])
}.by(1)
end
it 'Increments ondemandrequest_generate.success' do
bad_template = 'test-template'
expect { subject.increment('ondemandrequest_generate.success') }.to change {
metric, po = subject.get('ondemandrequest_generate.success')
po.get(labels: metric[:labels])
}.by(1)
end
it 'Increments ondemandrequest_fail.toomanyrequests.#{bad_template}' do
bad_template = 'test-template'
expect { subject.increment("ondemandrequest_fail.toomanyrequests.#{bad_template}") }.to change {
metric, po = subject.get("ondemandrequest_fail.toomanyrequests.#{bad_template}")
po.get(labels: metric[:labels])
}.by(1)
end
it 'Increments ondemandrequest_fail.invalid.#{bad_template}' do
bad_template = 'test-template'
expect { subject.increment("ondemandrequest_fail.invalid.#{bad_template}") }.to change {
metric, po = subject.get("ondemandrequest_fail.invalid.#{bad_template}")
po.get(labels: metric[:labels])
}.by(1)
end
it 'Increments config.invalid.#{bad_template}' do
bad_template = 'test-template'
expect { subject.increment("config.invalid.#{bad_template}") }.to change {