Merge branch 'add-debug-add-test'

This commit is contained in:
Marin Jankovski 2016-10-21 16:06:39 +02:00
commit be305d406c
5 changed files with 78 additions and 3 deletions

View File

@ -8,6 +8,7 @@ omnibus-gitlab repository.
- Add support for registry debug addr configuration
- Add support for configuring workhorse's api limiting
- Fix unsetting the sticky bit for storage directory permissions and improved error messages
- Fixed a bug with disabling registry storage deletion
- Support specifying a post reconfigure script to run in the docker container
- Updated cacerts.pem to 2016-09-14 version
- Add support for nginx status

View File

@ -500,7 +500,7 @@ default['gitlab']['registry']['dir'] = "/var/opt/gitlab/registry"
default['gitlab']['registry']['log_directory'] = "/var/log/gitlab/registry"
default['gitlab']['registry']['log_level'] = "info"
default['gitlab']['registry']['rootcertbundle'] = nil
default['gitlab']['registry']['storage_delete_enabled'] = true
default['gitlab']['registry']['storage_delete_enabled'] = nil
default['gitlab']['registry']['storage'] = nil
default['gitlab']['registry']['debug_addr'] = nil

View File

@ -71,7 +71,7 @@ module Registry
return unless Gitlab['registry']['enable']
Gitlab['gitlab_rails']['registry_path'] = "#{Gitlab['gitlab_rails']['shared_path']}/registry" if Gitlab['gitlab_rails']['registry_path'].nil?
Gitlab['registry']['storage_delete_enabled'] ||= Gitlab['node']['gitlab']['registry']['storage_delete_enabled']
Gitlab['registry']['storage_delete_enabled'] = true if Gitlab['registry']['storage_delete_enabled'].nil?
Gitlab['registry']['storage'] ||= {
'filesystem' => { 'rootdirectory' => Gitlab['gitlab_rails']['registry_path'] }

View File

@ -76,6 +76,8 @@ describe 'registry recipe' do
.with_content(/realm: \/jwt\/auth/)
expect(chef_run).to render_file('/var/opt/gitlab/registry/config.yml')
.with_content(/addr: localhost:5000/)
expect(chef_run).to render_file('/var/opt/gitlab/registry/config.yml')
.with_content(%r(storage: {"filesystem":{"rootdirectory":"/var/opt/gitlab/gitlab-rails/shared/registry"}))
end
it 'creates a default VERSION file' do
@ -89,8 +91,8 @@ describe 'registry recipe' do
expect(chef_run).to render_file('/var/opt/gitlab/gitlab-rails/etc/gitlab.yml')
.with_content(/api_url: http:\/\/localhost:5000/)
end
end
context 'when registry port is specified' do
before { stub_gitlab_rb(registry_external_url: 'https://registry.example.com', registry: { registry_http_addr: 'localhost:5001' }) }
it 'creates registry and rails configs with specified value' do
@ -100,4 +102,13 @@ describe 'registry recipe' do
.with_content(/api_url: http:\/\/localhost:5001/)
end
end
context 'when a debug addr is specified' do
before { stub_gitlab_rb(registry_external_url: 'https://registry.example.com', registry: { debug_addr: 'localhost:5005' }) }
it 'creates the registry config with the specified debug value' do
expect(chef_run).to render_file('/var/opt/gitlab/registry/config.yml')
.with_content(/debug:\n\s*addr: localhost:5005/)
end
end
end

View File

@ -0,0 +1,63 @@
require 'chef_helper'
describe 'registry' do
let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab::default') }
before { allow(Gitlab).to receive(:[]).and_call_original }
context 'when registry is enabled' do
before { stub_gitlab_rb(registry_external_url: 'https://registry.example.com') }
it 'sets default storage options' do
expect(chef_run.node['gitlab']['registry']['storage']['filesystem'])
.to eql('rootdirectory' => '/var/opt/gitlab/gitlab-rails/shared/registry')
expect(chef_run.node['gitlab']['registry']['storage']['cache'])
.to eql('blobdescriptor'=>'inmemory')
expect(chef_run.node['gitlab']['registry']['storage']['delete'])
.to eql('enabled' => true)
end
context 'when custom storage parameters are specified' do
before do
stub_gitlab_rb(
registry: {
storage: {
s3: { accesskey: 'awsaccesskey', secretkey: 'awssecretkey', bucketname: 'bucketname' }
}
}
)
end
it 'uses custom storage instead of the default rootdirectory' do
expect(chef_run.node['gitlab']['registry']['storage'])
.to include(s3: { accesskey: 'awsaccesskey', secretkey: 'awssecretkey', bucketname: 'bucketname' })
expect(chef_run.node['gitlab']['registry']['storage'])
.not_to include('rootdirectory' => '/var/opt/gitlab/gitlab-rails/shared/registry')
end
it 'uses the default cache and delete settings if not overridden' do
expect(chef_run.node['gitlab']['registry']['storage']['cache'])
.to eql('blobdescriptor'=>'inmemory')
expect(chef_run.node['gitlab']['registry']['storage']['delete'])
.to eql('enabled' => true)
end
it 'allows the cache and delete settings to be overridden' do
stub_gitlab_rb(registry: { storage: {cache: 'somewhere-else', delete: { enabled: false } } })
expect(chef_run.node['gitlab']['registry']['storage']['cache'])
.to eql('somewhere-else')
expect(chef_run.node['gitlab']['registry']['storage']['delete'])
.to eql('enabled' => false)
end
end
context 'when storage_delete_enabled is false' do
before { stub_gitlab_rb(registry: { storage_delete_enabled: false }) }
it 'sets the delete enabled field on the storage object' do
expect(chef_run.node['gitlab']['registry']['storage']['delete'])
.to eql('enabled' => false)
end
end
end
end