Merge branch 'split-rails-spec-cron' into 'master'
Split off specs testing cron jobs in gitlab.yml to separate file See merge request gitlab-org/omnibus-gitlab!4901
This commit is contained in:
commit
8eb495e4c3
|
@ -357,49 +357,83 @@ production: &base
|
|||
# Please read here for more information: https://github.com/ondrejbartas/sidekiq-cron#adding-cron-job
|
||||
cron_jobs:
|
||||
# Flag stuck CI builds as failed
|
||||
<% unless @stuck_ci_jobs_worker_cron.nil? %>
|
||||
stuck_ci_jobs_worker:
|
||||
cron:<% if @stuck_ci_jobs_worker_cron %> "<%= @stuck_ci_jobs_worker_cron %>"<% end %>
|
||||
cron: "<%= @stuck_ci_jobs_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Remove expired build artifacts
|
||||
<% unless @expire_build_artifacts_worker_cron.nil? %>
|
||||
expire_build_artifacts_worker:
|
||||
cron:<% if @expire_build_artifacts_worker_cron %> "<%= @expire_build_artifacts_worker_cron %>"<% end %>
|
||||
cron: "<%= @expire_build_artifacts_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Stop expired environments
|
||||
<% unless @environments_auto_stop_cron_worker_cron.nil? %>
|
||||
environments_auto_stop_cron_worker:
|
||||
cron:<% if @environments_auto_stop_cron_worker_cron %> "<%= @environments_auto_stop_cron_worker_cron %>"<% end %>
|
||||
cron: "<%= @environments_auto_stop_cron_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Schedule pipelines in the near future
|
||||
<% unless @pipeline_schedule_worker_cron.nil? %>
|
||||
pipeline_schedule_worker:
|
||||
cron:<% if @pipeline_schedule_worker_cron %> "<%= @pipeline_schedule_worker_cron %>"<% end %>
|
||||
cron: "<%= @pipeline_schedule_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Periodically run 'git fsck' on all repositories. If started more than
|
||||
# once per hour you will have concurrent 'git fsck' jobs.
|
||||
<% unless @repository_check_worker_cron.nil? %>
|
||||
repository_check_worker:
|
||||
cron:<% if @repository_check_worker_cron %> "<%= @repository_check_worker_cron %>"<% end %>
|
||||
cron: "<%= @repository_check_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Send admin emails once a week
|
||||
<% unless @admin_email_worker_cron.nil? %>
|
||||
admin_email_worker:
|
||||
cron:<% if @admin_email_worker_cron %> "<%= @admin_email_worker_cron %>"<% end %>
|
||||
cron: "<%= @admin_email_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Send emails about personal tokens about to expired
|
||||
<% unless @personal_access_tokens_expiring_worker_cron.nil? %>
|
||||
personal_access_tokens_expiring_worker:
|
||||
cron:<% if @personal_access_tokens_expiring_worker_cron %> "<%= @personal_access_tokens_expiring_worker_cron %>"<% end %>
|
||||
cron: "<%= @personal_access_tokens_expiring_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Send emails about personal tokens that have expired
|
||||
<% unless @personal_access_tokens_expired_notification_worker_cron.nil? %>
|
||||
personal_access_tokens_expired_notification_worker:
|
||||
cron:<% if @personal_access_tokens_expired_notification_worker_cron %> "<%= @personal_access_tokens_expired_notification_worker_cron %>"<% end %>
|
||||
cron: "<%= @personal_access_tokens_expired_notification_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Remove outdated repository archives
|
||||
<% unless @repository_archive_cache_worker_cron.nil? %>
|
||||
repository_archive_cache_worker:
|
||||
cron:<% if @repository_archive_cache_worker_cron %> "<%= @repository_archive_cache_worker_cron %>"<% end %>
|
||||
cron: "<%= @repository_archive_cache_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Archive live traces which have not been archived yet
|
||||
<% unless @ci_archive_traces_cron_worker_cron.nil? %>
|
||||
ci_archive_traces_cron_worker:
|
||||
cron:<% if @ci_archive_traces_cron_worker_cron %> "<%= @ci_archive_traces_cron_worker_cron %>"<% end %>
|
||||
cron: "<%= @ci_archive_traces_cron_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Verify custom GitLab Pages domains
|
||||
<% unless @pages_domain_verification_cron_worker.nil? %>
|
||||
pages_domain_verification_cron_worker:
|
||||
cron:<% if @pages_domain_verification_cron_worker %> "<%= @pages_domain_verification_cron_worker %>"<% end %>
|
||||
cron: "<%= @pages_domain_verification_cron_worker %>"
|
||||
<% end %>
|
||||
|
||||
# Obtain and renew SSL certificates for pages domain through Let's Encrypt
|
||||
<% unless @pages_domain_ssl_renewal_cron_worker.nil? %>
|
||||
pages_domain_ssl_renewal_cron_worker:
|
||||
cron:<% if @pages_domain_ssl_renewal_cron_worker %> "<%= @pages_domain_ssl_renewal_cron_worker %>"<% end %>
|
||||
cron: "<%= @pages_domain_ssl_renewal_cron_worker %>"
|
||||
<% end %>
|
||||
|
||||
# Removes unverified pages domains
|
||||
<% unless @pages_domain_removal_cron_worker.nil? %>
|
||||
pages_domain_removal_cron_worker:
|
||||
cron:<% if @pages_domain_removal_cron_worker %> "<%= @pages_domain_removal_cron_worker %>"<% end %>
|
||||
cron: "<%= @pages_domain_removal_cron_worker %>"
|
||||
<% end %>
|
||||
|
||||
# Remove unaccepted member invitations
|
||||
<% unless @remove_unaccepted_member_invites_cron_worker.nil? %>
|
||||
|
@ -408,12 +442,16 @@ production: &base
|
|||
<% end %>
|
||||
|
||||
# Periodically migrate diffs from the database to external storage
|
||||
<% unless @schedule_migrate_external_diffs_worker_cron.nil? %>
|
||||
schedule_migrate_external_diffs_worker:
|
||||
cron:<% if @schedule_migrate_external_diffs_worker_cron %> "<%= @schedule_migrate_external_diffs_worker_cron %>"<% end %>
|
||||
cron: "<%= @schedule_migrate_external_diffs_worker_cron %>"
|
||||
<% end %>
|
||||
|
||||
# Update CI Platform Metrics daily
|
||||
<% unless @ci_platform_metrics_update_cron_worker.nil? %>
|
||||
ci_platform_metrics_update_cron_worker:
|
||||
cron: <% if @ci_platform_metrics_update_cron_worker %> "<%= @ci_platform_metrics_update_cron_worker %>"<% end %>
|
||||
cron: "<%= @ci_platform_metrics_update_cron_worker %>"
|
||||
<% end %>
|
||||
|
||||
##
|
||||
# GitLab EE only jobs:
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
require 'chef_helper'
|
||||
|
||||
RSpec.describe 'gitlab::gitlab-rails' do
|
||||
include_context 'gitlab-rails'
|
||||
|
||||
describe 'cron settings' do
|
||||
context 'with default values' do
|
||||
it "renders gitlab.yml without any cron settings" do
|
||||
expect(gitlab_yml[:production][:cron_jobs]).to be nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with user specified values' do
|
||||
using RSpec::Parameterized::TableSyntax
|
||||
|
||||
where(:gitlab_yml_setting, :gitlab_rb_setting) do
|
||||
'admin_email_worker' | 'admin_email_worker_cron'
|
||||
'analytics_devops_adoption_create_all_snapshots_worker' | 'analytics_devops_adoption_create_all_snapshots_worker'
|
||||
'analytics_instance_statistics_count_job_trigger_worker' | 'analytics_instance_statistics_count_job_trigger_worker_cron'
|
||||
'ci_archive_traces_cron_worker' | 'ci_archive_traces_cron_worker_cron'
|
||||
'ci_platform_metrics_update_cron_worker' | 'ci_platform_metrics_update_cron_worker'
|
||||
'elastic_index_bulk_cron_worker' | 'elastic_index_bulk_cron'
|
||||
'environments_auto_stop_cron_worker' | 'environments_auto_stop_cron_worker_cron'
|
||||
'expire_build_artifacts_worker' | 'expire_build_artifacts_worker_cron'
|
||||
'geo_file_download_dispatch_worker' | 'geo_file_download_dispatch_worker_cron'
|
||||
'geo_migrated_local_files_clean_up_worker' | 'geo_migrated_local_files_clean_up_worker_cron'
|
||||
'geo_prune_event_log_worker' | 'geo_prune_event_log_worker_cron'
|
||||
'geo_repository_sync_worker' | 'geo_repository_sync_worker_cron'
|
||||
'geo_repository_verification_primary_batch_worker' | 'geo_repository_verification_primary_batch_worker_cron'
|
||||
'geo_repository_verification_secondary_scheduler_worker' | 'geo_repository_verification_secondary_scheduler_worker_cron'
|
||||
'geo_secondary_registry_consistency_worker' | 'geo_secondary_registry_consistency_worker'
|
||||
'historical_data_worker' | 'historical_data_worker_cron'
|
||||
'ldap_group_sync_worker' | 'ldap_group_sync_worker_cron'
|
||||
'ldap_sync_worker' | 'ldap_sync_worker_cron'
|
||||
'member_invitation_reminder_emails_worker' | 'member_invitation_reminder_emails_worker_cron'
|
||||
'pages_domain_removal_cron_worker' | 'pages_domain_removal_cron_worker'
|
||||
'pages_domain_ssl_renewal_cron_worker' | 'pages_domain_ssl_renewal_cron_worker'
|
||||
'pages_domain_verification_cron_worker' | 'pages_domain_verification_cron_worker'
|
||||
'personal_access_tokens_expired_notification_worker' | 'personal_access_tokens_expired_notification_worker_cron'
|
||||
'personal_access_tokens_expiring_worker' | 'personal_access_tokens_expiring_worker_cron'
|
||||
'pipeline_schedule_worker' | 'pipeline_schedule_worker_cron'
|
||||
'pseudonymizer_worker' | 'pseudonymizer_worker_cron'
|
||||
'remove_unaccepted_member_invites_worker' | 'remove_unaccepted_member_invites_cron_worker'
|
||||
'repository_archive_cache_worker' | 'repository_archive_cache_worker_cron'
|
||||
'repository_check_worker' | 'repository_check_worker_cron'
|
||||
'schedule_migrate_external_diffs_worker' | 'schedule_migrate_external_diffs_worker_cron'
|
||||
'stuck_ci_jobs_worker' | 'stuck_ci_jobs_worker_cron'
|
||||
end
|
||||
|
||||
with_them do
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
gitlab_rails: {
|
||||
gitlab_rb_setting => '1 2 3 4 5'
|
||||
}.transform_keys(&:to_sym)
|
||||
)
|
||||
end
|
||||
|
||||
it "renders gitlab.yml with user specified cron settings" do
|
||||
config = gitlab_yml[:production][:cron_jobs][gitlab_yml_setting.to_sym][:cron]
|
||||
expect(config).to eq '1 2 3 4 5'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1573,345 +1573,6 @@ RSpec.describe 'gitlab::gitlab-rails' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'personal access token expiring worker settings' do
|
||||
let(:chef_run) do
|
||||
ChefSpec::SoloRunner.new.converge('gitlab-ee::default')
|
||||
end
|
||||
|
||||
context 'when worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { personal_access_tokens_expiring_worker_cron: '0 1 2 3 4' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'personal_access_tokens_expiring_worker_cron' => '0 1 2 3 4'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'personal_access_tokens_expiring_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'personal access token expired notification worker settings' do
|
||||
let(:chef_run) do
|
||||
ChefSpec::SoloRunner.new.converge('gitlab-ee::default')
|
||||
end
|
||||
|
||||
context 'when worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { personal_access_tokens_expired_notification_worker_cron: '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'personal_access_tokens_expired_notification_worker_cron' => '1 2 3 4 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'personal_access_tokens_expired_notification_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'devops adoption snapshots worker settings' do
|
||||
let(:chef_run) do
|
||||
ChefSpec::SoloRunner.new.converge('gitlab-ee::default')
|
||||
end
|
||||
|
||||
context 'when worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { analytics_devops_adoption_create_all_snapshots_worker_cron: '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'analytics_devops_adoption_create_all_snapshots_worker_cron' => '1 2 3 4 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'analytics_devops_adoption_create_all_snapshots_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'GitLab Geo settings' do
|
||||
let(:chef_run) do
|
||||
ChefSpec::SoloRunner.new.converge('gitlab-ee::default')
|
||||
end
|
||||
|
||||
context 'when repository sync worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { geo_repository_sync_worker_cron: '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_repository_sync_worker_cron' => '1 2 3 4 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when repository sync worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_repository_sync_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when registry backfill worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { geo_secondary_registry_consistency_worker: '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_secondary_registry_consistency_worker' => '1 2 3 4 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when registry backfill worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_secondary_registry_consistency_worker' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when geo prune event log worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { geo_prune_event_log_worker_cron: '5 4 3 2 1' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_prune_event_log_worker_cron' => '5 4 3 2 1'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when geo prune event log worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_prune_event_log_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when file download dispatch worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { geo_file_download_dispatch_worker_cron: '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_file_download_dispatch_worker_cron' => '1 2 3 4 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when file download dispatch worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_file_download_dispatch_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when repository verification primary batch worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { geo_repository_verification_primary_batch_worker_cron: '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_repository_verification_primary_batch_worker_cron' => '1 2 3 4 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when repository verification primary batch worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_repository_verification_primary_batch_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when repository verification secondary scheduler worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { geo_repository_verification_secondary_scheduler_worker_cron: '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_repository_verification_secondary_scheduler_worker_cron' => '1 2 3 4 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when repository verification secondary scheduler worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'geo_repository_verification_secondary_scheduler_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when instance statistics counter trigger worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { analytics_instance_statistics_count_job_trigger_worker_cron: '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'analytics_instance_statistics_count_job_trigger_worker_cron' => '1 2 3 4 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when instance statistics counter trigger worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'analytics_instance_statistics_count_job_trigger_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when member invitation reminder emails worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { member_invitation_reminder_emails_worker_cron: '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'member_invitation_reminder_emails_worker_cron' => '1 2 3 4 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when member invitation reminder emails worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'member_invitation_reminder_emails_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Cron workers for other EE functionality' do
|
||||
where(:gitlab_rb_key, :gitlab_yml_key) do
|
||||
:pseudonymizer_worker_cron | 'pseudonymizer_worker_cron'
|
||||
:elastic_index_bulk_cron | 'elastic_index_bulk_cron'
|
||||
end
|
||||
|
||||
with_them do
|
||||
context 'when the worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { gitlab_rb_key => '1 2 3 4 5' })
|
||||
|
||||
expect(chef_run)
|
||||
.to configure_gitlab_yml_using(hash_including(gitlab_yml_key => '1 2 3 4 5'))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run)
|
||||
.to configure_gitlab_yml_using(hash_including(gitlab_yml_key => nil))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Environments Auto Stop Cron Worker settings' do
|
||||
context 'when the cron pattern is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { environments_auto_stop_cron_worker_cron: '24 * * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'environments_auto_stop_cron_worker_cron' => '24 * * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the cron pattern is not configured' do
|
||||
it 'sets no value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'environments_auto_stop_cron_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Scheduled Pipeline settings' do
|
||||
context 'when the cron pattern is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { pipeline_schedule_worker_cron: '41 * * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'pipeline_schedule_worker_cron' => '41 * * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the cron pattern is not configured' do
|
||||
it 'sets no value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'pipeline_schedule_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Monitoring settings' do
|
||||
context 'by default' do
|
||||
it 'whitelists local subnet' do
|
||||
|
@ -2117,52 +1778,6 @@ RSpec.describe 'gitlab::gitlab-rails' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'GitLab LDAP cron_jobs settings' do
|
||||
context 'when ldap user sync worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { ldap_sync_worker_cron: '40 2 * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'ldap_sync_worker_cron' => '40 2 * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ldap user sync worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'ldap_sync_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ldap group sync worker is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { ldap_group_sync_worker_cron: '1 0 * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'ldap_group_sync_worker_cron' => '1 0 * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ldap group sync worker is not configured' do
|
||||
it 'does not set the cron value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'ldap_group_sync_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'GitLab LDAP settings' do
|
||||
context 'when ldap lowercase_usernames setting is' do
|
||||
it 'set, sets the setting value' do
|
||||
|
@ -2197,171 +1812,6 @@ RSpec.describe 'gitlab::gitlab-rails' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'Rescue stale live trace settings' do
|
||||
context 'when the cron pattern is configured' do
|
||||
it 'sets the cron value' do
|
||||
stub_gitlab_rb(gitlab_rails: { ci_archive_traces_cron_worker_cron: '17 * * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'ci_archive_traces_cron_worker_cron' => '17 * * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the cron pattern is not configured' do
|
||||
it 'sets no value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_excluding(
|
||||
'ci_archive_traces_cron_worker_cron'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'GitLab Pages verification cron job settings' do
|
||||
context 'when the cron pattern is configured' do
|
||||
it 'sets the value' do
|
||||
stub_gitlab_rb(gitlab_rails: { pages_domain_verification_cron_worker: '1 0 * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'pages_domain_verification_cron_worker' => '1 0 * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
context 'when pages domain verification cron worker is not configured' do
|
||||
it ' sets no value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'pages_domain_verification_cron_worker' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'GitLab Pages domain removal cron job settings' do
|
||||
context 'when the cron pattern is configured' do
|
||||
it 'sets the value' do
|
||||
stub_gitlab_rb(gitlab_rails: { pages_domain_removal_cron_worker: '1 0 * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'pages_domain_removal_cron_worker' => '1 0 * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
context 'when pages domain removal cron worker is not configured' do
|
||||
it ' sets no value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'pages_domain_verification_cron_worker' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'GitLab Pages domain ssl renewal job settings' do
|
||||
context 'when the cron pattern is configured' do
|
||||
it 'sets the value' do
|
||||
stub_gitlab_rb(gitlab_rails: { pages_domain_ssl_renewal_cron_worker: '1 0 * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'pages_domain_ssl_renewal_cron_worker' => '1 0 * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
context 'when cron worker is not configured' do
|
||||
it ' sets no value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'pages_domain_ssl_renewal_cron_worker' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Remove unaccepted member invitations cron job settings' do
|
||||
context 'when the cron pattern is configured' do
|
||||
it 'sets the value' do
|
||||
stub_gitlab_rb(gitlab_rails: { remove_unaccepted_member_invites_cron_worker: '1 * 3 * 5' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'remove_unaccepted_member_invites_cron_worker' => '1 * 3 * 5'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when cron worker is not configured' do
|
||||
it ' sets no value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'remove_unaccepted_member_invites_cron_worker' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'External diff migration cron job settings' do
|
||||
context 'when the cron pattern is configured' do
|
||||
it 'sets the value' do
|
||||
stub_gitlab_rb(gitlab_rails: { schedule_migrate_external_diffs_worker_cron: '1 0 * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'schedule_migrate_external_diffs_worker_cron' => '1 0 * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the cron pattern is not configured' do
|
||||
it ' sets no value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'schedule_migrate_external_diffs_worker_cron' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Update CI Platform Metrics daily cron job settings' do
|
||||
context 'when the cron pattern is configured' do
|
||||
it 'sets the value' do
|
||||
stub_gitlab_rb(gitlab_rails: { ci_platform_metrics_update_cron_worker: '47 9 * * *' })
|
||||
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'ci_platform_metrics_update_cron_worker' => '47 9 * * *'
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the cron pattern is not configured' do
|
||||
it ' sets no value' do
|
||||
expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(
|
||||
hash_including(
|
||||
'ci_platform_metrics_update_cron_worker' => nil
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Geo settings' do
|
||||
it 'sets the geo_node_name variable' do
|
||||
stub_gitlab_rb(gitlab_rails: { geo_node_name: 'the name of the node' })
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
require 'chef_helper'
|
||||
|
||||
RSpec.shared_context 'gitlab-rails' do
|
||||
let(:chef_run) { ChefSpec::SoloRunner.new(step_into: 'templatesymlink').converge('gitlab::default') }
|
||||
let(:gitlab_yml_template) { chef_run.template('/var/opt/gitlab/gitlab-rails/etc/gitlab.yml') }
|
||||
let(:gitlab_yml_file_content) { ChefSpec::Renderer.new(chef_run, gitlab_yml_template).content }
|
||||
let(:gitlab_yml) { YAML.safe_load(gitlab_yml_file_content, [], [], true, symbolize_names: true) }
|
||||
let(:config_dir) { '/var/opt/gitlab/gitlab-rails/etc/' }
|
||||
|
||||
before do
|
||||
allow(Gitlab).to receive(:[]).and_call_original
|
||||
allow(File).to receive(:symlink?).and_call_original
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue