Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
895ec1a1
Commit
895ec1a1
authored
Sep 14, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make TestInit.setup_gitlab_shell and TestInit.setup_gitaly more robust
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
82778305
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
36 deletions
+45
-36
spec/support/test_env.rb
spec/support/test_env.rb
+45
-36
No files found.
spec/support/test_env.rb
View file @
895ec1a1
...
@@ -3,6 +3,8 @@ require 'rspec/mocks'
...
@@ -3,6 +3,8 @@ require 'rspec/mocks'
module
TestEnv
module
TestEnv
extend
self
extend
self
ComponentFailedToInstallError
=
Class
.
new
(
StandardError
)
# When developing the seed repository, comment out the branch you will modify.
# When developing the seed repository, comment out the branch you will modify.
BRANCH_SHA
=
{
BRANCH_SHA
=
{
'signed-commits'
=>
'2d1096e'
,
'signed-commits'
=>
'2d1096e'
,
...
@@ -127,50 +129,23 @@ module TestEnv
...
@@ -127,50 +129,23 @@ module TestEnv
end
end
def
setup_gitlab_shell
def
setup_gitlab_shell
puts
"
\n
==> Setting up Gitlab Shell..."
component_timed_setup
(
'GitLab Shell'
,
start
=
Time
.
now
install_dir:
Gitlab
.
config
.
gitlab_shell
.
path
,
gitlab_shell_dir
=
Gitlab
.
config
.
gitlab_shell
.
path
version:
Gitlab
::
Shell
.
version_required
,
shell_needs_update
=
component_needs_update?
(
gitlab_shell_dir
,
task:
'gitlab:shell:install'
)
Gitlab
::
Shell
.
version_required
)
unless
!
shell_needs_update
||
system
(
'rake'
,
'gitlab:shell:install'
)
puts
"
\n
GitLab Shell failed to install, cleaning up
#{
gitlab_shell_dir
}
!
\n
"
FileUtils
.
rm_rf
(
gitlab_shell_dir
)
exit
1
end
puts
" GitLab Shell setup in
#{
Time
.
now
-
start
}
seconds...
\n
"
end
end
def
setup_gitaly
def
setup_gitaly
puts
"
\n
==> Setting up Gitaly..."
start
=
Time
.
now
socket_path
=
Gitlab
::
GitalyClient
.
address
(
'default'
).
sub
(
/\Aunix:/
,
''
)
socket_path
=
Gitlab
::
GitalyClient
.
address
(
'default'
).
sub
(
/\Aunix:/
,
''
)
gitaly_dir
=
File
.
dirname
(
socket_path
)
gitaly_dir
=
File
.
dirname
(
socket_path
)
if
gitaly_dir_stale?
(
gitaly_dir
)
component_timed_setup
(
'Gitaly'
,
puts
" Gitaly is outdated, cleaning up
#{
gitaly_dir
}
!"
install_dir:
gitaly_dir
,
FileUtils
.
rm_rf
(
gitaly_dir
)
version:
Gitlab
::
GitalyClient
.
expected_server_version
,
end
task:
"gitlab:gitaly:install[
#{
gitaly_dir
}
]"
)
do
gitaly_needs_update
=
component_needs_update?
(
gitaly_dir
,
start_gitaly
(
gitaly_dir
)
Gitlab
::
GitalyClient
.
expected_server_version
)
unless
!
gitaly_needs_update
||
system
(
'rake'
,
"gitlab:gitaly:install[
#{
gitaly_dir
}
]"
)
puts
"
\n
Gitaly failed to install, cleaning up
#{
gitaly_dir
}
!
\n
"
FileUtils
.
rm_rf
(
gitaly_dir
)
exit
1
end
end
start_gitaly
(
gitaly_dir
)
puts
" Gitaly setup in
#{
Time
.
now
-
start
}
seconds...
\n
"
end
def
gitaly_dir_stale?
(
dir
)
gitaly_executable
=
File
.
join
(
dir
,
'gitaly'
)
return
false
unless
File
.
exist?
(
gitaly_executable
)
File
.
mtime
(
gitaly_executable
)
<
File
.
mtime
(
Rails
.
root
.
join
(
'GITALY_SERVER_VERSION'
))
end
end
def
start_gitaly
(
gitaly_dir
)
def
start_gitaly
(
gitaly_dir
)
...
@@ -325,6 +300,40 @@ module TestEnv
...
@@ -325,6 +300,40 @@ module TestEnv
end
end
end
end
def
component_timed_setup
(
component
,
install_dir
:,
version
:,
task
:)
puts
"
\n
==> Setting up
#{
component
}
..."
start
=
Time
.
now
ensure_component_dir_name_is_correct!
(
component
,
install_dir
)
if
component_needs_update?
(
install_dir
,
version
)
# Cleanup the component entirely to ensure we start fresh
FileUtils
.
rm_rf
(
install_dir
)
unless
system
(
'rake'
,
task
)
raise
ComponentFailedToInstallError
end
end
yield
if
block_given?
rescue
ComponentFailedToInstallError
puts
"
\n
#{
component
}
failed to install, cleaning up
#{
install_dir
}
!
\n
"
FileUtils
.
rm_rf
(
install_dir
)
exit
1
ensure
puts
"
#{
component
}
setup in
#{
Time
.
now
-
start
}
seconds...
\n
"
end
def
ensure_component_dir_name_is_correct!
(
component
,
path
)
actual_component_dir_name
=
File
.
basename
(
path
)
expected_component_dir_name
=
component
.
parameterize
unless
actual_component_dir_name
==
expected_component_dir_name
puts
"
#{
component
}
install dir should be named '
#{
expected_component_dir_name
}
', not '
#{
actual_component_dir_name
}
' (full install path given was '
#{
path
}
')!
\n
"
exit
1
end
end
def
component_needs_update?
(
component_folder
,
expected_version
)
def
component_needs_update?
(
component_folder
,
expected_version
)
version
=
File
.
read
(
File
.
join
(
component_folder
,
'VERSION'
)).
strip
version
=
File
.
read
(
File
.
join
(
component_folder
,
'VERSION'
)).
strip
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment