summaryrefslogtreecommitdiff
path: root/spec/tasks/gitlab/seed/runner_fleet_rake_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/tasks/gitlab/seed/runner_fleet_rake_spec.rb')
-rw-r--r--spec/tasks/gitlab/seed/runner_fleet_rake_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/seed/runner_fleet_rake_spec.rb b/spec/tasks/gitlab/seed/runner_fleet_rake_spec.rb
new file mode 100644
index 00000000000..e0390d2aa09
--- /dev/null
+++ b/spec/tasks/gitlab/seed/runner_fleet_rake_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require 'rake_helper'
+
+RSpec.describe 'gitlab:seed:runner_fleet rake task', :silence_stdout, feature_category: :runner_fleet do
+ let(:registration_prefix) { 'rf-' }
+ let(:runner_count) { 10 }
+ let(:job_count) { 20 }
+ let(:task_params) { [username, registration_prefix, runner_count, job_count] }
+ let(:runner_releases_url) do
+ ::Gitlab::CurrentSettings.current_application_settings.public_runner_releases_url
+ end
+
+ before do
+ Rake.application.rake_require('tasks/gitlab/seed/runner_fleet')
+
+ WebMock.stub_request(:get, runner_releases_url).to_return(
+ body: '[]',
+ status: 200,
+ headers: { 'Content-Type' => 'application/json' }
+ )
+ end
+
+ subject(:rake_task) { run_rake_task('gitlab:seed:runner_fleet', task_params) }
+
+ context 'with admin username', :enable_admin_mode do
+ let(:username) { 'runner_fleet_seed' }
+ let!(:admin) { create(:user, :admin, username: username) }
+
+ it 'performs runner fleet seed successfully' do
+ expect { rake_task }
+ .to change { Group.count }.by(6)
+ .and change { Project.count }.by(3)
+ .and change { Ci::Runner.count }.by(runner_count)
+ .and change { Ci::Runner.instance_type.count }.by(1)
+ .and change { Ci::Build.count }.by(job_count)
+
+ expect(Group.search(registration_prefix).count).to eq 6
+ expect(Project.search(registration_prefix).count).to eq 3
+ expect(Ci::Runner.search(registration_prefix).count).to eq runner_count
+ end
+ end
+end