Commit f70beeb8 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Testing: Allow newer components for local tests

Rebuilding Gitaly is done for a Gitaly version that mismatches the
GITALY_SERVER_VERSION. Due to a continuous deployment, these rebuilds
are quite frequent and thus triggered a lot.

This change allows a newer Gitaly to be used, locally, for these tests.
Which in practice will decrease the number of rebuilds.

This achieved by running `git merge-base --is-ancestor` in the tmp
component directory, and depends on the HEAD being the same as the built
assets.

The other option was to parse `gitaly -version`, but this wouldn't have
worked for `gitlab-shell` etc, and thus using HEAD as heuristic was
chosen.
parent fe907c21
...@@ -517,6 +517,8 @@ module TestEnv ...@@ -517,6 +517,8 @@ module TestEnv
return false if component_matches_git_sha?(component_folder, expected_version) return false if component_matches_git_sha?(component_folder, expected_version)
return false if component_ahead_of_target?(component_folder, expected_version)
version = File.read(File.join(component_folder, 'VERSION')).strip version = File.read(File.join(component_folder, 'VERSION')).strip
# Notice that this will always yield true when using branch versions # Notice that this will always yield true when using branch versions
...@@ -527,6 +529,20 @@ module TestEnv ...@@ -527,6 +529,20 @@ module TestEnv
true true
end end
def component_ahead_of_target?(component_folder, expected_version)
# The HEAD of the component_folder will be used as heuristic for the version
# of the binaries, allowing to use Git to determine if HEAD is later than
# the expected version. Note: Git considers HEAD to be an anchestor of HEAD.
_out, exit_status = Gitlab::Popen.popen(%W[
#{Gitlab.config.git.bin_path}
-C #{component_folder}
merge-base --is-ancestor
#{expected_version} HEAD
])
exit_status == 0
end
def component_matches_git_sha?(component_folder, expected_version) def component_matches_git_sha?(component_folder, expected_version)
# Not a git SHA, so return early # Not a git SHA, so return early
return false unless expected_version =~ ::Gitlab::Git::COMMIT_ID return false unless expected_version =~ ::Gitlab::Git::COMMIT_ID
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment