Commit 92e46e58 authored by Marin Jankovski's avatar Marin Jankovski

Merge branch 'feature-customize-git-home' into 'master'

Feature Customize Git Home

Hi @marin,

I'm back whit this change, which supersede my previous MR !39. This time, spec are fixed and new ones are added that check various place where git home can be customized. I touched comments about not changing attributes for app user and app root by adding "unless you know what you do".

If this MR gets merge in, it will resolve issue #12.

I'm currently doing the convergence of the recipe on CentOS and fetching opscode bento ubuntu base box. Will ping you when I finish convergence of the recipe on both system.

Regards,
Matt
parents 933a9b39 fdfb6262
...@@ -16,12 +16,23 @@ end ...@@ -16,12 +16,23 @@ end
default['gitlab']['packages'] = packages default['gitlab']['packages'] = packages
default['gitlab']['ruby'] = "2.0.0-p353" # Latest 2.0 by ruby-build 20131225.1 (Ubuntu) default['gitlab']['ruby'] = "2.0.0-p353" # Latest 2.0 by ruby-build 20131225.1 (Ubuntu)
# User
default['gitlab']['user'] = "git" # Do not change this attribute in production unless you know what you do since some code from the GitLab repo such as init.d script assume it is git.
default['gitlab']['group'] = "git"
default['gitlab']['user_uid'] = nil # Use to specify user id.
default['gitlab']['user_gid'] = nil # Use to specify group id.
default['gitlab']['home'] = "/home/git"
# GitLab hq
default['gitlab']['path'] = "#{node['gitlab']['home']}/gitlab" # Do not change this attribute in production unless you know what you do since some code from the GitLab repo such as init.d assume this path.
default['gitlab']['satellites_path'] = "#{node['gitlab']['home']}/gitlab-satellites"
# GitLab shell # GitLab shell
default['gitlab']['shell_repository'] = "https://github.com/gitlabhq/gitlab-shell.git" default['gitlab']['shell_repository'] = "https://github.com/gitlabhq/gitlab-shell.git"
# GitLab shell configuration # GitLab shell configuration
default['gitlab']['repos_path'] = "/home/git/repositories" default['gitlab']['repos_path'] = "#{node['gitlab']['home']}/repositories"
default['gitlab']['shell_path'] = "/home/git/gitlab-shell" default['gitlab']['shell_path'] = "#{node['gitlab']['home']}/gitlab-shell"
default['gitlab']['redis_path'] = "/usr/local/bin/redis-cli" default['gitlab']['redis_path'] = "/usr/local/bin/redis-cli"
default['gitlab']['redis_host'] = "127.0.0.1" default['gitlab']['redis_host'] = "127.0.0.1"
default['gitlab']['redis_port'] = "6379" default['gitlab']['redis_port'] = "6379"
...@@ -153,17 +164,6 @@ default['postfix']['mydomain'] = "localhost" ...@@ -153,17 +164,6 @@ default['postfix']['mydomain'] = "localhost"
default['postfix']['myorigin'] = "mail.localhost" default['postfix']['myorigin'] = "mail.localhost"
default['postfix']['smtp_use_tls'] = "no" default['postfix']['smtp_use_tls'] = "no"
# User
default['gitlab']['user'] = "git" # Do not change this attribute in production since some code from the GitLab repo such as init.d script assume it is git.
default['gitlab']['group'] = "git"
default['gitlab']['user_uid'] = nil # Use to specify user id.
default['gitlab']['user_gid'] = nil # Use to specify group id.
default['gitlab']['home'] = "/home/git"
# GitLab hq
default['gitlab']['path'] = "/home/git/gitlab" # Do not change this attribute in production since some code from the GitLab repo such as init.d assume this path.
default['gitlab']['satellites_path'] = "/home/git/gitlab-satellites"
# Unicorn specific configuration # Unicorn specific configuration
default['gitlab']['unicorn_workers_number'] = 2 default['gitlab']['unicorn_workers_number'] = 2
default['gitlab']['unicorn_timeout'] = 30 default['gitlab']['unicorn_timeout'] = 30
......
...@@ -63,6 +63,7 @@ template File.join(gitlab['path'], 'config', 'unicorn.rb') do ...@@ -63,6 +63,7 @@ template File.join(gitlab['path'], 'config', 'unicorn.rb') do
user gitlab['user'] user gitlab['user']
group gitlab['group'] group gitlab['group']
variables({ variables({
:app_root => gitlab['path'],
:unicorn_workers_number => gitlab['unicorn_workers_number'], :unicorn_workers_number => gitlab['unicorn_workers_number'],
:unicorn_timeout => gitlab['unicorn_timeout'] :unicorn_timeout => gitlab['unicorn_timeout']
}) })
...@@ -195,6 +196,15 @@ ruby_block "Copy from example gitlab init config" do ...@@ -195,6 +196,15 @@ ruby_block "Copy from example gitlab init config" do
end end
end end
template "/etc/default/gitlab" do
source "gitlab.default.erb"
mode 0755
variables(
:app_user => node['gitlab']['user'],
:app_root => node['gitlab']['path']
)
end
case gitlab['env'] case gitlab['env']
when 'production' when 'production'
# Updates defaults so gitlab can boot on start. As per man pages of update-rc.d runs only if links do not exist # Updates defaults so gitlab can boot on start. As per man pages of update-rc.d runs only if links do not exist
......
...@@ -6,7 +6,7 @@ describe "gitlab::clone" do ...@@ -6,7 +6,7 @@ describe "gitlab::clone" do
describe "under ubuntu" do describe "under ubuntu" do
["12.04", "10.04"].each do |version| ["12.04", "10.04"].each do |version|
let(:chef_run) do let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version) runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production" runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::clone", "gitlab::start") runner.converge("gitlab::clone", "gitlab::start")
...@@ -22,7 +22,7 @@ describe "gitlab::clone" do ...@@ -22,7 +22,7 @@ describe "gitlab::clone" do
end end
describe "in development" do describe "in development" do
let(:chef_run) do let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version) runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "development" runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::clone", "gitlab::start") runner.converge("gitlab::clone", "gitlab::start")
...@@ -37,12 +37,30 @@ describe "gitlab::clone" do ...@@ -37,12 +37,30 @@ describe "gitlab::clone" do
) )
end end
end end
describe "when customizing gitlab user home" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::clone", "gitlab::start")
end
it "clones the gitlab repository" do
expect(chef_run).to sync_git('/data/git/gitlab').with(
repository: 'https://github.com/gitlabhq/gitlabhq.git',
revision: '6-7-stable',
user: 'git',
group: 'git'
)
end
end
end end
end end
describe "under centos" do describe "under centos" do
["5.8", "6.4"].each do |version| ["5.8", "6.4"].each do |version|
let(:chef_run) do let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version) runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production" runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::clone", "gitlab::start") runner.converge("gitlab::clone", "gitlab::start")
...@@ -58,7 +76,7 @@ describe "gitlab::clone" do ...@@ -58,7 +76,7 @@ describe "gitlab::clone" do
end end
describe "in development" do describe "in development" do
let(:chef_run) do let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version) runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "development" runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::clone", "gitlab::start") runner.converge("gitlab::clone", "gitlab::start")
...@@ -73,6 +91,24 @@ describe "gitlab::clone" do ...@@ -73,6 +91,24 @@ describe "gitlab::clone" do
) )
end end
end end
describe "when customizing gitlab user home" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::clone", "gitlab::start")
end
it "clones the gitlab repository" do
expect(chef_run).to sync_git('/data/git/gitlab').with(
repository: 'https://github.com/gitlabhq/gitlabhq.git',
revision: '6-7-stable',
user: 'git',
group: 'git'
)
end
end
end end
end end
end end
...@@ -95,6 +95,60 @@ describe "gitlab::gems" do ...@@ -95,6 +95,60 @@ describe "gitlab::gems" do
end end
end end
end end
describe "when customizing gitlab user home" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gems")
end
it 'creates a gemrc from template' do
expect(chef_run).to create_template('/data/git/.gemrc')
end
it 'executes bundle without development and test' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.cwd).to eq("/data/git/gitlab")
end
describe "when using mysql" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['database_adapter'] = "mysql"
runner.node.set['gitlab']['database_password'] = "datapass"
runner.node.set['mysql']['server_root_password'] = "rootpass"
runner.node.set['mysql']['server_repl_password'] = "replpass"
runner.node.set['mysql']['server_debian_password'] = "debpass"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gems")
end
it 'executes bundle without postgres' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.cwd).to eq("/data/git/gitlab")
end
end
describe "when using postgres" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['database_adapter'] = "postgresql"
runner.node.set['gitlab']['database_password'] = "datapass"
runner.node.set['postgresql']['password']['postgres'] = "psqlpass"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gems")
end
it 'executes bundle without mysql' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.cwd).to eq("/data/git/gitlab")
end
end
end
end end
end end
...@@ -189,6 +243,60 @@ describe "gitlab::gems" do ...@@ -189,6 +243,60 @@ describe "gitlab::gems" do
end end
end end
end end
describe "when customizing gitlab user home" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gems")
end
it 'creates a gemrc from template' do
expect(chef_run).to create_template('/data/git/.gemrc')
end
it 'executes bundle without development and test' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.cwd).to eq("/data/git/gitlab")
end
describe "when using mysql" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['database_adapter'] = "mysql"
runner.node.set['gitlab']['database_password'] = "datapass"
runner.node.set['mysql']['server_root_password'] = "rootpass"
runner.node.set['mysql']['server_repl_password'] = "replpass"
runner.node.set['mysql']['server_debian_password'] = "debpass"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gems")
end
it 'executes bundle without postgres' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.cwd).to eq("/data/git/gitlab")
end
end
describe "when using postgres" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['database_adapter'] = "postgresql"
runner.node.set['gitlab']['database_password'] = "datapass"
runner.node.set['postgresql']['password']['postgres'] = "psqlpass"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gems")
end
it 'executes bundle without mysql' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.cwd).to eq("/data/git/gitlab")
end
end
end
end end
end end
end end
...@@ -6,7 +6,7 @@ describe "gitlab::gitlab_shell_clone" do ...@@ -6,7 +6,7 @@ describe "gitlab::gitlab_shell_clone" do
describe "under ubuntu" do describe "under ubuntu" do
["12.04", "10.04"].each do |version| ["12.04", "10.04"].each do |version|
let(:chef_run) do let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version) runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production" runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::gitlab_shell_clone") runner.converge("gitlab::gitlab_shell_clone")
...@@ -22,7 +22,7 @@ describe "gitlab::gitlab_shell_clone" do ...@@ -22,7 +22,7 @@ describe "gitlab::gitlab_shell_clone" do
end end
describe "in development" do describe "in development" do
let(:chef_run) do let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version) runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "development" runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::gitlab_shell_clone") runner.converge("gitlab::gitlab_shell_clone")
...@@ -37,12 +37,25 @@ describe "gitlab::gitlab_shell_clone" do ...@@ -37,12 +37,25 @@ describe "gitlab::gitlab_shell_clone" do
) )
end end
end end
describe "when customizing gitlab user home" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gitlab_shell_clone")
end
it "clones the gitlab-shell repository" do
expect(chef_run).to sync_git('/data/git/gitlab-shell')
end
end
end end
end end
describe "under centos" do describe "under centos" do
["5.8", "6.4"].each do |version| ["5.8", "6.4"].each do |version|
let(:chef_run) do let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version) runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production" runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::gitlab_shell_clone") runner.converge("gitlab::gitlab_shell_clone")
...@@ -58,7 +71,7 @@ describe "gitlab::gitlab_shell_clone" do ...@@ -58,7 +71,7 @@ describe "gitlab::gitlab_shell_clone" do
end end
describe "in development" do describe "in development" do
let(:chef_run) do let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version) runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "development" runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::gitlab_shell_clone") runner.converge("gitlab::gitlab_shell_clone")
...@@ -73,6 +86,19 @@ describe "gitlab::gitlab_shell_clone" do ...@@ -73,6 +86,19 @@ describe "gitlab::gitlab_shell_clone" do
) )
end end
end end
describe "when customizing gitlab user home" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gitlab_shell_clone")
end
it "clones the gitlab-shell repository" do
expect(chef_run).to sync_git('/data/git/gitlab-shell')
end
end
end end
end end
end end
...@@ -56,6 +56,44 @@ describe "gitlab::gitlab_shell_install" do ...@@ -56,6 +56,44 @@ describe "gitlab::gitlab_shell_install" do
it 'does not run a execute to install gitlab shell on its own' do it 'does not run a execute to install gitlab shell on its own' do
expect(chef_run).to_not run_execute('gitlab-shell install') expect(chef_run).to_not run_execute('gitlab-shell install')
end end
describe "when customizing gitlab user home" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gitlab_shell_install")
end
it 'creates a gitlab shell config' do
expect(chef_run).to create_template('/data/git/gitlab-shell/config.yml').with(
source: 'gitlab_shell.yml.erb',
variables: {
user: "git",
home: "/data/git",
url: "http://localhost:80/",
repos_path: "/data/git/repositories",
redis_path: "/usr/local/bin/redis-cli",
redis_host: "127.0.0.1",
redis_port: "6379",
namespace: "resque:gitlab",
self_signed_cert: false
}
)
end
it 'creates repository directory in the gitlab user home directory' do
expect(chef_run).to create_directory("/data/git/repositories")
end
it 'creates .ssh directory in the gitlab user home directory' do
expect(chef_run).to create_directory("/data/git/.ssh")
end
it 'creates authorized hosts file in .ssh directory' do
expect(chef_run).to create_file_if_missing("/data/git/.ssh/authorized_keys")
end
end
end end
end end
...@@ -111,6 +149,44 @@ describe "gitlab::gitlab_shell_install" do ...@@ -111,6 +149,44 @@ describe "gitlab::gitlab_shell_install" do
it 'does not run a execute to install gitlab shell on its own' do it 'does not run a execute to install gitlab shell on its own' do
expect(chef_run).to_not run_execute('gitlab-shell install') expect(chef_run).to_not run_execute('gitlab-shell install')
end end
describe "when customizing gitlab user home" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::gitlab_shell_install")
end
it 'creates a gitlab shell config' do
expect(chef_run).to create_template('/data/git/gitlab-shell/config.yml').with(
source: 'gitlab_shell.yml.erb',
variables: {
user: "git",
home: "/data/git",
url: "http://localhost:80/",
repos_path: "/data/git/repositories",
redis_path: "/usr/local/bin/redis-cli",
redis_host: "127.0.0.1",
redis_port: "6379",
namespace: "resque:gitlab",
self_signed_cert: false
}
)
end
it 'creates repository directory in the gitlab user home directory' do
expect(chef_run).to create_directory("/data/git/repositories")
end
it 'creates .ssh directory in the gitlab user home directory' do
expect(chef_run).to create_directory("/data/git/.ssh")
end
it 'creates authorized hosts file in .ssh directory' do
expect(chef_run).to create_file_if_missing("/data/git/.ssh/authorized_keys")
end
end
end end
end end
end end
...@@ -94,6 +94,7 @@ describe "gitlab::install" do ...@@ -94,6 +94,7 @@ describe "gitlab::install" do
expect(chef_run).to create_template('/home/git/gitlab/config/unicorn.rb').with( expect(chef_run).to create_template('/home/git/gitlab/config/unicorn.rb').with(
source: 'unicorn.rb.erb', source: 'unicorn.rb.erb',
variables: { variables: {
app_root: "/home/git/gitlab",
unicorn_workers_number: 2, unicorn_workers_number: 2,
unicorn_timeout: 30 unicorn_timeout: 30
} }
...@@ -278,6 +279,17 @@ describe "gitlab::install" do ...@@ -278,6 +279,17 @@ describe "gitlab::install" do
describe "creating gitlab init" do describe "creating gitlab init" do
describe "for production" do describe "for production" do
it 'creates gitlab default configuration file' do
expect(chef_run).to create_template('/etc/default/gitlab').with(
source: 'gitlab.default.erb',
mode: 0755,
variables: {
app_user: 'git',
app_root: '/home/git/gitlab'
}
)
end
# TODO Write the test that will check if notification is triggered within the ruby_block # TODO Write the test that will check if notification is triggered within the ruby_block
it 'triggers service defaults update' do it 'triggers service defaults update' do
expect(chef_run).to run_ruby_block('Copy from example gitlab init config') expect(chef_run).to run_ruby_block('Copy from example gitlab init config')
...@@ -301,6 +313,105 @@ describe "gitlab::install" do ...@@ -301,6 +313,105 @@ describe "gitlab::install" do
end end
end end
end end
describe "when customizing gitlab user home" do
# Only test stuff that change when git user home is different
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::start","gitlab::install")
end
it 'creates a gitlab config' do
expect(chef_run).to create_template('/data/git/gitlab/config/database.yml')
end
it 'updates git config' do
resource = chef_run.find_resource(:bash, 'git config')
expect(resource.environment).to eq('HOME' =>"/data/git")
end
it 'creates required directories in the rails root' do
%w{log tmp tmp/pids tmp/sockets public/uploads}.each do |path|
expect(chef_run).to create_directory("/data/git/gitlab/#{path}").with(
user: 'git',
group: 'git',
mode: 0755
)
end
end
it 'creates satellites directory' do
expect(chef_run).to create_directory("/data/git/gitlab-satellites")
end
it 'creates a unicorn config' do
expect(chef_run).to create_template('/data/git/gitlab/config/unicorn.rb')
end
describe "when using mysql" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['database_adapter'] = "mysql"
runner.node.set['gitlab']['database_password'] = "datapass"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::start","gitlab::install")
end
it 'creates a database config' do
expect(chef_run).to create_template('/data/git/gitlab/config/database.yml')
end
end
describe "when using postgresql" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['database_adapter'] = "postgresql"
runner.node.set['gitlab']['database_password'] = "datapass"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::start","gitlab::install")
end
it 'creates a database config' do
expect(chef_run).to create_template('/data/git/gitlab/config/database.yml')
end
end
describe "running database setup, migrations and seed when production" do
it 'runs db setup' do
resource = chef_run.find_resource(:execute, 'rake db:schema:load')
expect(resource.cwd).to eq("/data/git/gitlab")
end
it 'runs db migrate' do
resource = chef_run.find_resource(:execute, 'rake db:migrate')
expect(resource.cwd).to eq("/data/git/gitlab")
end
it 'runs db seed' do
resource = chef_run.find_resource(:execute, 'rake db:seed_fu')
expect(resource.cwd).to eq("/data/git/gitlab")
end
end
describe "creating gitlab init" do
describe "for production" do
it 'creates gitlab default configuration file' do
expect(chef_run).to create_template('/etc/default/gitlab').with(
source: 'gitlab.default.erb',
mode: 0755,
variables: {
app_user: 'git',
app_root: '/data/git/gitlab'
}
)
end
end
end
end
end end
end end
...@@ -394,6 +505,7 @@ describe "gitlab::install" do ...@@ -394,6 +505,7 @@ describe "gitlab::install" do
expect(chef_run).to create_template('/home/git/gitlab/config/unicorn.rb').with( expect(chef_run).to create_template('/home/git/gitlab/config/unicorn.rb').with(
source: 'unicorn.rb.erb', source: 'unicorn.rb.erb',
variables: { variables: {
app_root: "/home/git/gitlab",
unicorn_workers_number: 2, unicorn_workers_number: 2,
unicorn_timeout: 30 unicorn_timeout: 30
} }
...@@ -582,6 +694,17 @@ describe "gitlab::install" do ...@@ -582,6 +694,17 @@ describe "gitlab::install" do
describe "creating gitlab init" do describe "creating gitlab init" do
describe "for production" do describe "for production" do
it 'creates gitlab default configuration file' do
expect(chef_run).to create_template('/etc/default/gitlab').with(
source: 'gitlab.default.erb',
mode: 0755,
variables: {
app_user: 'git',
app_root: '/home/git/gitlab'
}
)
end
# TODO Write the test that will check if notification is triggered within the ruby_block # TODO Write the test that will check if notification is triggered within the ruby_block
it 'triggers service defaults update' do it 'triggers service defaults update' do
expect(chef_run).to run_ruby_block('Copy from example gitlab init config') expect(chef_run).to run_ruby_block('Copy from example gitlab init config')
...@@ -605,6 +728,105 @@ describe "gitlab::install" do ...@@ -605,6 +728,105 @@ describe "gitlab::install" do
end end
end end
end end
describe "when customizing gitlab user home" do
# Only test stuff that change when git user home is different
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.node.set['gitlab']['home'] = "/data/git"
runner.converge("gitlab::start","gitlab::install")
end
it 'creates a gitlab config' do
expect(chef_run).to create_template('/data/git/gitlab/config/database.yml')
end