Commit e89ff8c5 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '331393-follow-up-from-introduce-matcher-classes-for-builds-and-runners' into 'master'

Add runner ids to the runner matcher class

See merge request gitlab-org/gitlab!64077
parents fbcaaccb 83fe818f
......@@ -214,15 +214,15 @@ module Ci
Arel.sql("(#{arel_tag_names_array.to_sql})")
]
# we use distinct to de-duplicate data
distinct.pluck(*unique_params).map do |values|
group(*unique_params).pluck('array_agg(ci_runners.id)', *unique_params).map do |values|
Gitlab::Ci::Matching::RunnerMatcher.new({
runner_type: values[0],
public_projects_minutes_cost_factor: values[1],
private_projects_minutes_cost_factor: values[2],
run_untagged: values[3],
access_level: values[4],
tag_list: values[5]
runner_ids: values[0],
runner_type: values[1],
public_projects_minutes_cost_factor: values[2],
private_projects_minutes_cost_factor: values[3],
run_untagged: values[4],
access_level: values[5],
tag_list: values[6]
})
end
end
......@@ -230,6 +230,7 @@ module Ci
def runner_matcher
strong_memoize(:runner_matcher) do
Gitlab::Ci::Matching::RunnerMatcher.new({
runner_ids: [id],
runner_type: runner_type,
public_projects_minutes_cost_factor: public_projects_minutes_cost_factor,
private_projects_minutes_cost_factor: private_projects_minutes_cost_factor,
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Ci::Matching::RunnerMatcher do
let(:dummy_attributes) do
{
runner_ids: [1],
runner_type: 'instance_type',
public_projects_minutes_cost_factor: 0.0,
private_projects_minutes_cost_factor: 1.0,
......
......@@ -18,6 +18,7 @@ module Gitlab
#
class RunnerMatcher
ATTRIBUTES = %i[
runner_ids
runner_type
public_projects_minutes_cost_factor
private_projects_minutes_cost_factor
......
......@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Ci::Matching::RunnerMatcher do
let(:dummy_attributes) do
{
runner_ids: [1],
runner_type: 'instance_type',
public_projects_minutes_cost_factor: 0,
private_projects_minutes_cost_factor: 1,
......@@ -26,6 +27,8 @@ RSpec.describe Gitlab::Ci::Matching::RunnerMatcher do
context 'with attributes' do
let(:attributes) { dummy_attributes }
it { expect(matcher.runner_ids).to eq([1]) }
it { expect(matcher.runner_type).to eq('instance_type') }
it { expect(matcher.public_projects_minutes_cost_factor).to eq(0) }
......
......@@ -1086,6 +1086,18 @@ RSpec.describe Ci::Runner do
expect(matchers.map(&:tag_list)).to match_array([%w[tag1 tag2], %w[tag3 tag4]])
end
end
context 'with runner_ids' do
before do
create_list(:ci_runner, 2)
end
it 'includes runner_ids' do
expect(matchers.size).to eq(1)
expect(matchers.first.runner_ids).to match_array(described_class.all.pluck(:id))
end
end
end
describe '#runner_matcher' do
......@@ -1095,6 +1107,8 @@ RSpec.describe Ci::Runner do
subject(:matcher) { runner.runner_matcher }
it { expect(matcher.runner_ids).to eq([runner.id]) }
it { expect(matcher.runner_type).to eq(runner.runner_type) }
it { expect(matcher.public_projects_minutes_cost_factor).to eq(runner.public_projects_minutes_cost_factor) }
......
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