Make 'has_minutes' part of the EE metrics

parent d8707956
......@@ -2,37 +2,69 @@ module GitLab
module Monitor
module Database
# A helper class to collect CI builds metrics.
class CiBuildsCollector < Base # rubocop:disable ClassLength
BUILDS_QUERY =
class CiBuildsCollector < Base # rubocop:disable Metrics/ClassLength
SET_RANDOM_PAGE_COST = "SET LOCAL random_page_cost TO 1".freeze
BUILDS_QUERY_EE =
<<~SQL.freeze
SELECT
projects.namespace_id,
ci_builds.status,
projects.shared_runners_enabled,
(COALESCE(namespaces.shared_runners_minutes_limit, application_settings.shared_runners_minutes, 0) = 0 OR
COALESCE(namespace_statistics.shared_runners_seconds, 0) < COALESCE(namespaces.shared_runners_minutes_limit, application_settings.shared_runners_minutes, 0) * 60) as has_minutes,
COUNT(*) AS count
FROM ci_builds
JOIN projects
ON projects.id = ci_builds.project_id
JOIN namespaces
ON namespaces.id = projects.namespace_id
LEFT JOIN namespace_statistics
ON namespace_statistics.namespace_id = namespaces.id
JOIN application_settings
ON application_settings.id = 1
WHERE ci_builds.type = 'Ci::Build'
AND ci_builds.status IN ('created', 'pending')
AND projects.pending_delete = 'f'
GROUP BY
projects.namespace_id,
ci_builds.status,
projects.shared_runners_enabled,
namespaces.shared_runners_minutes_limit,
namespace_statistics.shared_runners_seconds,
application_settings.shared_runners_minutes
SQL
BUILDS_QUERY_CE =
<<~SQL.freeze
SELECT
projects.namespace_id,
ci_builds.status,
projects.shared_runners_enabled,
COUNT(*) AS count
FROM ci_builds
JOIN projects
ON projects.id = ci_builds.project_id
WHERE ci_builds.type = 'Ci::Build'
AND ci_builds.status IN ('created', 'pending')
AND projects.pending_delete = 'f'
GROUP BY
projects.namespace_id,
ci_builds.status,
projects.shared_runners_enabled
FROM ci_builds
JOIN projects
ON projects.id = ci_builds.project_id
WHERE ci_builds.type = 'Ci::Build'
AND ci_builds.status IN ('created', 'pending')
AND projects.pending_delete = 'f'
GROUP BY
projects.namespace_id,
ci_builds.status,
projects.shared_runners_enabled
SQL
STALE_BUILDS_QUERY =
<<~SQL.freeze
SELECT
COUNT(*) AS count
FROM ci_builds
JOIN projects
ON projects.id = ci_builds.project_id
WHERE ci_builds.type = 'Ci::Build'
AND ci_builds.status = 'running'
AND ci_builds.updated_at < NOW() - INTERVAL '1 hour'
AND projects.pending_delete = 'f'
FROM ci_builds
JOIN projects
ON projects.id = ci_builds.project_id
WHERE ci_builds.type = 'Ci::Build'
AND ci_builds.status = 'running'
AND ci_builds.updated_at < NOW() - INTERVAL '1 hour'
AND projects.pending_delete = 'f'
SQL
PER_RUNNER_QUERY_EE =
......@@ -45,6 +77,8 @@ module GitLab
projects.mirror_trigger_builds,
ci_pipelines.pipeline_schedule_id,
ci_builds.trigger_request_id,
(COALESCE(namespaces.shared_runners_minutes_limit, application_settings.shared_runners_minutes, 0) = 0 OR
COALESCE(namespace_statistics.shared_runners_seconds, 0) < COALESCE(namespaces.shared_runners_minutes_limit, application_settings.shared_runners_minutes, 0) * 60) as has_minutes,
COUNT(*) AS count
FROM ci_builds
JOIN ci_runners
......@@ -53,17 +87,26 @@ module GitLab
ON projects.id = ci_builds.project_id
JOIN ci_pipelines
ON ci_pipelines.id = ci_builds.commit_id
JOIN namespaces
ON namespaces.id = projects.namespace_id
LEFT JOIN namespace_statistics
ON namespace_statistics.namespace_id = namespaces.id
JOIN application_settings
ON application_settings.id = 1
WHERE ci_builds.type = 'Ci::Build'
AND ci_builds.status = 'running'
AND projects.pending_delete = 'f'
GROUP BY
ci_builds.runner_id,
ci_runners.is_shared,
projects.namespace_id,
projects.mirror,
projects.mirror_trigger_builds,
ci_pipelines.pipeline_schedule_id,
ci_builds.trigger_request_id,
projects.mirror,
projects.namespace_id,
projects.mirror_trigger_builds
namespaces.shared_runners_minutes_limit,
namespace_statistics.shared_runners_seconds,
application_settings.shared_runners_minutes
SQL
PER_RUNNER_QUERY_CE =
......@@ -100,22 +143,20 @@ module GitLab
def run
results = {}
results.merge!(get_builds(BUILDS_QUERY))
results[:stale_builds] = get_stale_builds(STALE_BUILDS_QUERY)
query = mirror_column? ? PER_RUNNER_QUERY_EE : PER_RUNNER_QUERY_CE
results[:per_runner] = get_per_runner(query)
results.merge!(builds)
results[:stale_builds] = stale_builds
results[:per_runner] = per_runner_builds
results
end
private
def get_builds(query)
def builds
results = { pending_builds: [], created_builds: [] }
connection.exec(query).each do |row|
row_data = { namespace: row["namespace_id"].to_s,
shared_runners: row["shared_runners_enabled"] == "t" ? "yes" : "no",
value: row["count"].to_i }
query = mirror_column? ? BUILDS_QUERY_EE : BUILDS_QUERY_CE
exec_query_with_custom_random_page_cost(query).each do |row|
row_data = transform_builds_row_to_values(row)
if row["status"] == "pending"
results[:pending_builds].push(row_data)
......@@ -129,17 +170,25 @@ module GitLab
results
end
def get_stale_builds(query)
connection.exec(query)[0]["count"].to_i
def transform_builds_row_to_values(row)
values = { namespace: row["namespace_id"].to_s,
shared_runners: row["shared_runners_enabled"] == "t" ? "yes" : "no",
value: row["count"].to_i }
include_ee_fields(values, row)
end
def stale_builds
connection.exec(STALE_BUILDS_QUERY)[0]["count"].to_i
rescue PG::UndefinedTable, PG::UndefinedColumn
0
end
def get_per_runner(query)
def per_runner_builds
results = []
connection.exec(query).each do |row|
results << transform_row_to_values(row)
query = mirror_column? ? PER_RUNNER_QUERY_EE : PER_RUNNER_QUERY_CE
exec_query_with_custom_random_page_cost(query).each do |row|
results << transform_per_runners_builds_row_to_values(row)
end
results
......@@ -147,23 +196,35 @@ module GitLab
[]
end
def transform_row_to_values(row)
def transform_per_runners_builds_row_to_values(row)
values = { runner: row["runner_id"].to_s,
shared_runner: row["is_shared"] == "t" ? "yes" : "no",
namespace: row["namespace_id"].to_s,
scheduled: row["pipeline_schedule_id"] ? "yes" : "no",
triggered: row["trigger_request_id"] ? "yes" : "no",
value: row["count"].to_i }
include_mirror_fields(values, row)
include_ee_fields(values, row)
end
def include_mirror_fields(values, row)
values[:mirror] = row["mirror"] == "t" ? "yes" : "no" if row["mirror"]
values[:mirror_trigger_builds] =
row["mirror_trigger_builds"] == "t" ? "yes" : "no" if row["mirror_trigger_builds"]
def include_ee_fields(values, row)
values.merge!(include_bool_if_row_defined(row, :mirror))
values.merge!(include_bool_if_row_defined(row, :mirror_trigger_builds))
values.merge!(include_bool_if_row_defined(row, :has_minutes))
values
end
def include_bool_if_row_defined(row, field)
return {} unless row[field.to_s]
{ field => row[field.to_s] == "t" ? "yes" : "no" }
end
def exec_query_with_custom_random_page_cost(query)
connection.transaction do |conn|
conn.exec(SET_RANDOM_PAGE_COST)
conn.exec(query)
end
end
def mirror_column?
@mirror_column ||=
begin
......@@ -207,6 +268,8 @@ module GitLab
# If we have a low value, put the value into an "other" bucket.
if metric[:value] < 10
key = { shared_runners: metric[:shared_runners] }
key[:has_minutes] = metric[:has_minutes] if metric[:has_minutes]
other_values[key] ||= 0
other_values[key] += metric[:value]
else
......@@ -220,7 +283,7 @@ module GitLab
def add_ci_created_pending_builds(metric_name, value, labels)
add_metric_with_namespace_label(metric_name,
[:namespace, :shared_runners],
[:namespace, :shared_runners, :has_minutes],
value,
labels)
end
......@@ -239,6 +302,7 @@ module GitLab
scheduled: metric[:scheduled], triggered: metric[:triggered] }
key[:mirror] = metric[:mirror] if metric[:mirror]
key[:mirror_trigger_builds] = metric[:mirror_trigger_builds] if metric[:mirror_trigger_builds]
key[:has_minutes] = metric[:has_minutes] if metric[:has_minutes]
other_values[key] ||= 0
other_values[key] += metric[:value]
......@@ -254,7 +318,8 @@ module GitLab
def add_ci_running_builds(value, labels)
add_metric_with_namespace_label(
"ci_running_builds",
[:runner, :namespace, :shared_runner, :scheduled, :triggered, :mirror, :mirror_trigger_builds],
[:runner, :namespace, :shared_runner, :scheduled,
:triggered, :mirror, :mirror_trigger_builds, :has_minutes],
value,
labels
)
......
......@@ -3,7 +3,9 @@ require "gitlab_monitor/database/ci_builds"
# rubocop:disable Metrics/LineLength
describe GitLab::Monitor::Database do
let(:builds_query) { "SELECT BUILDS" }
let(:set_random_page_cost_query) { "SET random_page_cost" }
let(:builds_query_ee) { "SELECT BUILDS EE" }
let(:builds_query_ce) { "SELECT BUILDS CE" }
let(:stale_builds_query) { "SELECT NOT UPDATED RUNNING" }
let(:per_runner_query_ee) { "SELECT ALL RUNNING PER RUNNER EE" }
let(:per_runner_query_ce) { "SELECT ALL RUNNING PER RUNNER CE" }
......@@ -18,11 +20,25 @@ describe GitLab::Monitor::Database do
allow(connection).to receive(:exec).with(mirror_column_query).and_return([{ "exists" => "f" }])
end
def builds_query_row_ee(shared_runners_enabled, status, namespace_id, has_minutes, count)
row = builds_query_row_ce(shared_runners_enabled, status, namespace_id, count)
row["has_minutes"] = has_minutes
row
end
def builds_query_row_ce(shared_runners_enabled, status, namespace_id, count)
{ "shared_runners_enabled" => shared_runners_enabled,
"status" => status,
"namespace_id" => namespace_id,
"count" => count }
end
# rubocop:disable Metrics/ParameterLists
def per_runner_query_row_ee(runner_id, is_shared, namespace_id, mirror, mirror_trigger_builds, pipeline_schedule_id, trigger_request_id, count)
def per_runner_query_row_ee(runner_id, is_shared, namespace_id, mirror, mirror_trigger_builds, pipeline_schedule_id, trigger_request_id, has_minutes, count)
row = per_runner_query_row_ce(runner_id, is_shared, namespace_id, pipeline_schedule_id, trigger_request_id, count)
row["mirror"] = mirror
row["mirror_trigger_builds"] = mirror_trigger_builds
row["has_minutes"] = has_minutes
row
end
# rubocop:enable Metrics/ParameterLists
......@@ -39,7 +55,9 @@ describe GitLab::Monitor::Database do
# rubocop:enable Metrics/ParameterLists
before do
stub_const("GitLab::Monitor::Database::CiBuildsCollector::BUILDS_QUERY", builds_query)
stub_const("GitLab::Monitor::Database::CiBuildsCollector::SET_RANDOM_PAGE_COST", set_random_page_cost_query)
stub_const("GitLab::Monitor::Database::CiBuildsCollector::BUILDS_QUERY_EE", builds_query_ee)
stub_const("GitLab::Monitor::Database::CiBuildsCollector::BUILDS_QUERY_CE", builds_query_ce)
stub_const("GitLab::Monitor::Database::CiBuildsCollector::STALE_BUILDS_QUERY", stale_builds_query)
stub_const("GitLab::Monitor::Database::CiBuildsCollector::PER_RUNNER_QUERY_EE", per_runner_query_ee)
stub_const("GitLab::Monitor::Database::CiBuildsCollector::PER_RUNNER_QUERY_CE", per_runner_query_ce)
......@@ -47,20 +65,33 @@ describe GitLab::Monitor::Database do
allow_any_instance_of(GitLab::Monitor::Database::CiBuildsCollector).to receive(:connection).and_return(connection)
allow(connection).to receive(:exec).with(builds_query)
.and_return([{ "shared_runners_enabled" => "f", "status" => "created", "namespace_id" => "1", "count" => 10 },
{ "shared_runners_enabled" => "t", "status" => "pending", "namespace_id" => "1", "count" => 30 },
{ "shared_runners_enabled" => "f", "status" => "created", "namespace_id" => "2", "count" => 20 },
{ "shared_runners_enabled" => "t", "status" => "pending", "namespace_id" => "2", "count" => 50 },
{ "shared_runners_enabled" => "t", "status" => "pending", "namespace_id" => "3", "count" => 1 },
{ "shared_runners_enabled" => "t", "status" => "pending", "namespace_id" => "4", "count" => 2 },
{ "shared_runners_enabled" => "f", "status" => "pending", "namespace_id" => "5", "count" => 2 }])
allow(connection).to receive(:transaction).and_yield(connection)
allow(connection).to receive(:exec).with(set_random_page_cost_query)
allow(connection).to receive(:exec).with(builds_query_ee)
.and_return([builds_query_row_ee("f", "created", "1", "f", 10),
builds_query_row_ee("t", "pending", "1", "t", 30),
builds_query_row_ee("f", "created", "2", "f", 20),
builds_query_row_ee("t", "pending", "2", "t", 50),
builds_query_row_ee("t", "pending", "3", "f", 1),
builds_query_row_ee("t", "pending", "4", "t", 2),
builds_query_row_ee("f", "pending", "5", "f", 2)])
allow(connection).to receive(:exec).with(builds_query_ce)
.and_return([builds_query_row_ce("f", "created", "1", 10),
builds_query_row_ce("t", "pending", "1", 30),
builds_query_row_ce("f", "created", "2", 20),
builds_query_row_ce("t", "pending", "2", 50),
builds_query_row_ce("t", "pending", "3", 1),
builds_query_row_ce("t", "pending", "4", 2),
builds_query_row_ce("f", "pending", "5", 2)])
allow(connection).to receive(:exec).with(stale_builds_query).and_return([{ "count" => 2 }])
allow(connection).to receive(:exec).with(per_runner_query_ee)
.and_return([per_runner_query_row_ee(1, "t", 1, "f", "f", 1, nil, 15),
per_runner_query_row_ee(2, "f", 2, "t", "t", nil, 3, 5),
per_runner_query_row_ee(2, "f", 3, "t", "t", nil, 3, 5),
per_runner_query_row_ee(3, "f", 4, "t", "t", nil, 3, 5)])
.and_return([per_runner_query_row_ee(1, "t", 1, "f", "f", 1, nil, "t", 15),
per_runner_query_row_ee(2, "f", 2, "t", "t", nil, 3, "f", 5),
per_runner_query_row_ee(2, "f", 3, "t", "t", nil, 3, "t", 5),
per_runner_query_row_ee(3, "f", 4, "t", "t", nil, 3, "f", 5)])
allow(connection).to receive(:exec).with(per_runner_query_ce)
.and_return([per_runner_query_row_ce(1, "t", 1, 1, nil, 15),
......@@ -71,35 +102,45 @@ describe GitLab::Monitor::Database do
describe GitLab::Monitor::Database::CiBuildsCollector do
let(:collector) { described_class.new(connection_string: "host=localhost") }
let(:expected_pending_builds) do
[{ namespace: "1", shared_runners: "yes", value: 30 },
{ namespace: "2", shared_runners: "yes", value: 50 },
{ namespace: "3", shared_runners: "yes", value: 1 },
{ namespace: "4", shared_runners: "yes", value: 2 },
{ namespace: "5", shared_runners: "no", value: 2 }]
end
let(:expected_created_builds) do
[{ namespace: "1", shared_runners: "no", value: 10 },
{ namespace: "2", shared_runners: "no", value: 20 }]
end
let(:expected_stale_builds) { 2 }
shared_examples "data collector" do
it "returns raw data" do
data = collector.run
expect(data[:per_runner]).to include(*expected_per_runner)
expect(data[:pending_builds]).to include(*expected_pending_builds)
expect(data[:created_builds]).to include(*expected_created_builds)
expect(data[:stale_builds]).to eq(expected_stale_builds)
subject { collector.run }
it "returns raw per_runner data" do
expect(subject[:per_runner]).to include(*expected_per_runner)
end
it "returns raw pending_builds data" do
expect(subject[:pending_builds]).to include(*expected_pending_builds)
end
it "returns raw created_builds data" do
expect(subject[:created_builds]).to include(*expected_created_builds)
end
it "returns raw stale_builds data" do
expect(subject[:stale_builds]).to eq(expected_stale_builds)
end
end
context "when executed on EE" do
let(:expected_pending_builds) do
[{ namespace: "1", shared_runners: "yes", has_minutes: "yes", value: 30 },
{ namespace: "2", shared_runners: "yes", has_minutes: "yes", value: 50 },
{ namespace: "3", shared_runners: "yes", has_minutes: "no", value: 1 },
{ namespace: "4", shared_runners: "yes", has_minutes: "yes", value: 2 },
{ namespace: "5", shared_runners: "no", has_minutes: "no", value: 2 }]
end
let(:expected_created_builds) do
[{ namespace: "1", shared_runners: "no", has_minutes: "no", value: 10 },
{ namespace: "2", shared_runners: "no", has_minutes: "no", value: 20 }]
end
let(:expected_per_runner) do
[{ runner: "1", shared_runner: "yes", namespace: "1", mirror: "no", mirror_trigger_builds: "no", scheduled: "yes", triggered: "no", value: 15 },
{ runner: "2", shared_runner: "no", namespace: "2", mirror: "yes", mirror_trigger_builds: "yes", scheduled: "no", triggered: "yes", value: 5 },
{ runner: "2", shared_runner: "no", namespace: "3", mirror: "yes", mirror_trigger_builds: "yes", scheduled: "no", triggered: "yes", value: 5 },
{ runner: "3", shared_runner: "no", namespace: "4", mirror: "yes", mirror_trigger_builds: "yes", scheduled: "no", triggered: "yes", value: 5 }]
[{ runner: "1", shared_runner: "yes", namespace: "1", mirror: "no", mirror_trigger_builds: "no", scheduled: "yes", triggered: "no", has_minutes: "yes", value: 15 },
{ runner: "2", shared_runner: "no", namespace: "2", mirror: "yes", mirror_trigger_builds: "yes", scheduled: "no", triggered: "yes", has_minutes: "no", value: 5 },
{ runner: "2", shared_runner: "no", namespace: "3", mirror: "yes", mirror_trigger_builds: "yes", scheduled: "no", triggered: "yes", has_minutes: "yes", value: 5 },
{ runner: "3", shared_runner: "no", namespace: "4", mirror: "yes", mirror_trigger_builds: "yes", scheduled: "no", triggered: "yes", has_minutes: "no", value: 5 }]
end
before do
......@@ -110,6 +151,17 @@ describe GitLab::Monitor::Database do
end
context "when executed on CE" do
let(:expected_pending_builds) do
[{ namespace: "1", shared_runners: "yes", value: 30 },
{ namespace: "2", shared_runners: "yes", value: 50 },
{ namespace: "3", shared_runners: "yes", value: 1 },
{ namespace: "4", shared_runners: "yes", value: 2 },
{ namespace: "5", shared_runners: "no", value: 2 }]
end
let(:expected_created_builds) do
[{ namespace: "1", shared_runners: "no", value: 10 },
{ namespace: "2", shared_runners: "no", value: 20 }]
end
let(:expected_per_runner) do
[{ runner: "1", shared_runner: "yes", namespace: "1", scheduled: "yes", triggered: "no", value: 15 },
{ runner: "2", shared_runner: "no", namespace: "2", scheduled: "no", triggered: "yes", value: 5 },
......@@ -137,24 +189,34 @@ describe GitLab::Monitor::Database do
end
shared_examples "metrics server" do
subject do
prober.probe_db
prober.write_to(writer)
writer.string
end
context "when PG exceptions aren't raised" do
it "responds with Prometheus metrics" do
prober.probe_db
prober.write_to(writer)
output = writer.string
it "responds with created builds Prometheus metrics" do
ci_created_builds_expected_lines.each do |expected_line|
expect(subject).to match(Regexp.new("^#{expected_line}$", Regexp::MULTILINE))
end
end
expect(output).to match(/^ci_pending_builds\{namespace="1",shared_runners="yes"\} 30$/m)
expect(output).to match(/^ci_pending_builds\{namespace="2",shared_runners="yes"\} 50$/m)
expect(output).to match(/^ci_pending_builds\{namespace="",shared_runners="yes"\} 3$/m)
expect(output).to match(/^ci_pending_builds\{namespace="",shared_runners="no"\} 2$/m)
expect(output).to match(/^ci_created_builds\{namespace="1",shared_runners="no"\} 10$/m)
expect(output).to match(/^ci_created_builds\{namespace="2",shared_runners="no"\} 20$/m)
expect(output).to match(/^ci_stale_builds 2$/)
it "responds with pending builds Prometheus metrics" do
ci_pending_builds_expected_lines.each do |expected_line|
expect(subject).to match(Regexp.new("^#{expected_line}$", Regexp::MULTILINE))
end
end
it "responds with running builds Prometheus metrics" do
ci_running_builds_expected_lines.each do |expected_line|
expect(output).to match(Regexp.new("^#{expected_line}$", Regexp::MULTILINE))
expect(subject).to match(Regexp.new("^#{expected_line}$", Regexp::MULTILINE))
end
end
it "responds with stale builds Prometheus metrics" do
expect(subject).to match(/^ci_stale_builds 2$/m)
end
end
context "when PG exceptions are raised" do
......@@ -165,22 +227,32 @@ describe GitLab::Monitor::Database do
it "responds with Prometheus metrics" do
prober.probe_db
prober.write_to(writer)
output = writer.string
output = <<~OUTPUT
ci_stale_builds 0
OUTPUT
expect(writer.string).to eq(output)
expect(output).to match(/^ci_stale_builds 0$/m)
end
end
end
context "when executed on EE" do
let(:ci_created_builds_expected_lines) do
['ci_created_builds\{has_minutes="no",namespace="1",shared_runners="no"\} 10',
'ci_created_builds\{has_minutes="no",namespace="2",shared_runners="no"\} 20']
end
let(:ci_pending_builds_expected_lines) do
['ci_pending_builds\{has_minutes="yes",namespace="1",shared_runners="yes"\} 30',
'ci_pending_builds\{has_minutes="yes",namespace="2",shared_runners="yes"\} 50',
'ci_pending_builds\{has_minutes="no",namespace="",shared_runners="yes"\} 1',
'ci_pending_builds\{has_minutes="yes",namespace="",shared_runners="yes"\} 2',
'ci_pending_builds\{has_minutes="no",namespace="",shared_runners="no"\} 2']
end
let(:ci_running_builds_expected_lines) do
['ci_running_builds\{mirror="no",mirror_trigger_builds="no",namespace="1",runner="1",scheduled="yes",shared_runner="yes",triggered="no"\} 15',
'ci_running_builds\{mirror="yes",mirror_trigger_builds="yes",namespace="",runner="2",scheduled="no",shared_runner="no",triggered="yes"\} 10',
'ci_running_builds\{mirror="yes",mirror_trigger_builds="yes",namespace="",runner="3",scheduled="no",shared_runner="no",triggered="yes"\} 5']
['ci_running_builds\{has_minutes="yes",mirror="no",mirror_trigger_builds="no",namespace="1",runner="1",scheduled="yes",shared_runner="yes",triggered="no"\} 15',
'ci_running_builds\{has_minutes="no",mirror="yes",mirror_trigger_builds="yes",namespace="",runner="2",scheduled="no",shared_runner="no",triggered="yes"\} 5',
'ci_running_builds\{has_minutes="yes",mirror="yes",mirror_trigger_builds="yes",namespace="",runner="2",scheduled="no",shared_runner="no",triggered="yes"\} 5',
'ci_running_builds\{has_minutes="no",mirror="yes",mirror_trigger_builds="yes",namespace="",runner="3",scheduled="no",shared_runner="no",triggered="yes"\} 5']
end
let(:namespace_out_of_limit) { 2 }
before do
stub_ee
......@@ -190,11 +262,22 @@ describe GitLab::Monitor::Database do
end
context "when executed on CE" do
let(:ci_created_builds_expected_lines) do
['ci_created_builds\{namespace="1",shared_runners="no"\} 10',
'ci_created_builds\{namespace="2",shared_runners="no"\} 20']
end
let(:ci_pending_builds_expected_lines) do
['ci_pending_builds\{namespace="1",shared_runners="yes"\} 30',
'ci_pending_builds\{namespace="2",shared_runners="yes"\} 50',
'ci_pending_builds\{namespace="",shared_runners="yes"\} 3',
'ci_pending_builds\{namespace="",shared_runners="no"\} 2']
end
let(:ci_running_builds_expected_lines) do
['ci_running_builds\{namespace="1",runner="1",scheduled="yes",shared_runner="yes",triggered="no"\} 15',
'ci_running_builds\{namespace="",runner="2",scheduled="no",shared_runner="no",triggered="yes"\} 10',
'ci_running_builds\{namespace="",runner="3",scheduled="no",shared_runner="no",triggered="yes"\} 5']
end
let(:namespace_out_of_limit) { 0 }
before do
stub_ce
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment