Restructure chef rspecs to match code structure

Moving around the chef rspec tests allows developers to
more easily discover and maintain them. Additionally, this
restructuring clears the path to use projectionist and more
clearly see if any test coverage is missing.

Related https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6721

Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
This commit is contained in:
Balasankar 'Balu' C 2022-03-24 04:38:17 +00:00 committed by Robert Marshall
parent ae432b33ad
commit b98c89133e
237 changed files with 86 additions and 64 deletions

View File

@ -7,5 +7,29 @@
"alternate": "lib/{}.rb",
"type": "test",
"dispatch": "bundle exec rspec {file}"
},
"files/gitlab-cookbooks/*.rb" : {
"alternate": "spec/chef/cookbooks/{}_spec.rb",
"type": "source"
},
"spec/chef/cookbooks/*_spec.rb": {
"alternate": "files/gitlab-cookbooks/{}.rb",
"type": "test"
},
"files/gitlab-ctl-commands/*.rb" : {
"alternate": "spec/chef/gitlab-ctl-commands/{}_spec.rb",
"type": "source"
},
"spec/chef/gitlab-ctl-commands/*_spec.rb": {
"alternate": "files/gitlab-ctl-commands/{}.rb",
"type": "test"
},
"files/gitlab-ctl-commands-ee/*.rb" : {
"alternate": "spec/chef/gitlab-ctl-commands-ee/{}_spec.rb",
"type": "source"
},
"spec/chef/gitlab-ctl-commands-ee/*_spec.rb": {
"alternate": "files/gitlab-ctl-commands-ee/{}.rb",
"type": "test"
}
}

View File

@ -51,9 +51,9 @@ Layout/RescueEnsureAlignment:
# Cop supports --auto-correct.
Layout/SpaceAroundMethodCallOperator:
Exclude:
- 'spec/chef/recipes/postgresql_spec.rb'
- 'spec/gitlab-ctl-commands-ee/lib/postgresql/ee_spec.rb'
- 'spec/libraries/logging_helper_spec.rb'
- 'spec/chef/cookbooks/postgresql/recipes/postgresql_spec.rb'
- 'spec/chef/gitlab-ctl-commands-ee/lib/postgresql/ee_spec.rb'
- 'spec/chef/cookbooks/package/libraries/helpers/logging_helper_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
@ -66,12 +66,12 @@ Layout/SpaceBeforeFirstArg:
Lint/ConstantDefinitionInBlock:
Exclude:
- 'files/gitlab-ctl-commands/upgrade.rb'
- 'spec/chef/secrets_spec.rb'
- 'spec/gitlab-ctl-commands/gitlab_ctl_spec.rb'
- 'spec/chef/cookbooks/package/libraries/secrets_helper_spec.rb'
- 'spec/chef/gitlab-ctl-commands/gitlab_ctl_spec.rb'
- 'spec/lib/gitlab/build/image_spec.rb'
- 'spec/lib/gitlab/tasks/qa_spec.rb'
- 'spec/support/shared_examples/geo_promotion_command_accepts_option_shared_examples.rb'
- 'spec/support/shared_examples/gitlab_geo_promotion_commands_shared_examples.rb'
- 'spec/chef/support/shared_examples/geo_promotion_command_accepts_option_shared_examples.rb'
- 'spec/chef/support/shared_examples/gitlab_geo_promotion_commands_shared_examples.rb'
# Offense count: 1
# Cop supports --auto-correct.
@ -226,11 +226,11 @@ Style/GlobalStdStream:
- 'files/gitlab-ctl-commands-ee/lib/geo/replication.rb'
- 'files/gitlab-ctl-commands/lib/gitlab_ctl/util.rb'
- 'lib/gitlab/build/trigger.rb'
- 'spec/gitlab-ctl-commands-ee/lib/geo/promote_to_primary_node_spec.rb'
- 'spec/gitlab-ctl-commands-ee/lib/geo/promotion_preflight_checks_spec.rb'
- 'spec/gitlab-ctl-commands-ee/lib/geo/replication_spec.rb'
- 'spec/gitlab-ctl-commands/lib/gitlab_ctl_backup_spec.rb'
- 'spec/gitlab-ctl-commands/lib/util_spec.rb'
- 'spec/chef/gitlab-ctl-commands-ee/lib/geo/promote_to_primary_node_spec.rb'
- 'spec/chef/gitlab-ctl-commands-ee/lib/geo/promotion_preflight_checks_spec.rb'
- 'spec/chef/gitlab-ctl-commands-ee/lib/geo/replication_spec.rb'
- 'spec/chef/gitlab-ctl-commands/lib/gitlab_ctl_backup_spec.rb'
- 'spec/chef/gitlab-ctl-commands/lib/util_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
@ -311,15 +311,15 @@ Style/RedundantRegexpEscape:
Exclude:
- 'files/gitlab-cookbooks/gitlab/libraries/registry.rb'
- 'files/gitlab-cookbooks/package/libraries/helpers/redhat_helper.rb'
- 'spec/chef/recipes/add_trusted_certs_spec.rb'
- 'spec/chef/recipes/gitlab-workhorse_spec.rb'
- 'spec/chef/recipes/mailroom_spec.rb'
- 'spec/chef/recipes/puma_spec.rb'
- 'spec/chef/recipes/registry_spec.rb'
- 'spec/chef/recipes/sidekiq_spec.rb'
- 'spec/chef/recipes/unicorn_spec.rb'
- 'spec/chef/cookbooks/gitlab/recipes/add_trusted_certs_spec.rb'
- 'spec/chef/cookbooks/gitlab/recipes/gitlab-workhorse_spec.rb'
- 'spec/chef/cookbooks/gitlab/recipes/mailroom_spec.rb'
- 'spec/chef/cookbooks/gitlab/recipes/puma_spec.rb'
- 'spec/chef/cookbooks/registry/recipes/registry_spec.rb'
- 'spec/chef/cookbooks/gitlab/recipes/sidekiq_spec.rb'
- 'spec/chef/cookbooks/gitlab/recipes/unicorn_spec.rb'
- 'spec/chef_helper.rb'
- 'spec/gitlab-ctl-commands-ee/lib/geo/promote_to_primary_node_spec.rb'
- 'spec/chef/gitlab-ctl-commands-ee/lib/geo/promote_to_primary_node_spec.rb'
# Offense count: 249
# Cop supports --auto-correct.

View File

@ -1,4 +1,3 @@
require_relative '../../../../files/gitlab-cookbooks/gitlab-ee/libraries/gitlab_geo_helper.rb'
require 'chef_helper'
RSpec.describe GitlabGeoHelper do

View File

@ -2,7 +2,6 @@
# are the ones we expect
require 'spec_helper'
require_relative '../../files/gitlab-cookbooks/gitlab/libraries/redis_uri.rb'
RSpec.describe URI::Redis do
subject { URI('redis://localhost') }

View File

@ -1,5 +1,4 @@
require 'chef_helper'
require_relative '../../files/gitlab-cookbooks/gitlab/libraries/registry'
RSpec.describe Registry do
before do

View File

@ -4,7 +4,7 @@ RSpec.describe 'gitlab::puma with Ubuntu 16.04' do
let(:chef_run) do
runner = ChefSpec::SoloRunner.new(
step_into: %w(runit_service puma_config),
path: 'spec/fixtures/fauxhai/ubuntu/16.04.json'
path: 'spec/chef/fixtures/fauxhai/ubuntu/16.04.json'
)
runner.converge('gitlab::default')
end
@ -182,7 +182,7 @@ end
RSpec.describe 'gitlab::puma Ubuntu 16.04 with no tmpfs' do
let(:chef_run) do
runner = ChefSpec::SoloRunner.new(
path: 'spec/fixtures/fauxhai/ubuntu/16.04-no-run-tmpfs.json',
path: 'spec/chef/fixtures/fauxhai/ubuntu/16.04-no-run-tmpfs.json',
step_into: %w(runit_service)
)
runner.converge('gitlab::default')
@ -208,7 +208,7 @@ end
RSpec.describe 'gitlab::puma Ubuntu 16.04 Docker' do
let(:chef_run) do
runner = ChefSpec::SoloRunner.new(
path: 'spec/fixtures/fauxhai/ubuntu/16.04-docker.json',
path: 'spec/chef/fixtures/fauxhai/ubuntu/16.04-docker.json',
step_into: %w(runit_service)
)
runner.converge('gitlab::default')
@ -235,7 +235,7 @@ RSpec.describe 'gitlab::puma with more CPUs' do
let(:chef_run) do
runner = ChefSpec::SoloRunner.new(
step_into: %w(runit_service),
path: 'spec/fixtures/fauxhai/ubuntu/16.04-more-cpus.json'
path: 'spec/chef/fixtures/fauxhai/ubuntu/16.04-more-cpus.json'
)
runner.converge('gitlab::default')
end

View File

@ -4,7 +4,7 @@ RSpec.describe 'gitlab::sidekiq' do
let(:chef_run) do
runner = ChefSpec::SoloRunner.new(
step_into: %w(sidekiq_service runit_service),
path: 'spec/fixtures/fauxhai/ubuntu/16.04.json'
path: 'spec/chef/fixtures/fauxhai/ubuntu/16.04.json'
)
runner.converge('gitlab::default')
end

Some files were not shown because too many files have changed in this diff Show More