diff options
author | Robert Marshall <rmarshall@gitlab.com> | 2019-02-28 19:26:46 -0500 |
---|---|---|
committer | Robert Marshall <rmarshall@gitlab.com> | 2019-03-06 11:47:47 -0500 |
commit | 984ad690ccc950b98e058c227c585f7712a86d58 (patch) | |
tree | ec753340b53a381a9362d831d0eefb0e9f3322f7 | |
parent | d86de642d16e0f7518c7f508b5282c89128e9a58 (diff) | |
download | gitlab-ce-1052-fix-git-protocol-2-tests.tar.gz |
Correct git protocol v2 tests1052-fix-git-protocol-2-tests
- Git protocol v2 tests began to fail because Result now returns a
struct object instead of a string object
- Tests will now examine the headers during the handshake process
which, by specification, are guaranteed to advertise protocol version
Resolves: https://gitlab.com/charts/gitlab/issues/1052
Signed-off-by: Robert Marshall <rmarshall@gitlab.com>
-rw-r--r-- | qa/qa/git/repository.rb | 10 | ||||
-rw-r--r-- | qa/spec/git/repository_spec.rb | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb index 0aa94101098..e6e1a618405 100644 --- a/qa/qa/git/repository.rb +++ b/qa/qa/git/repository.rb @@ -150,10 +150,12 @@ module QA end def fetch_supported_git_protocol - # ls-remote is one command known to respond to Git protocol v2 so we use - # it to get output including the version reported via Git tracing - output = run("git ls-remote #{uri}", "GIT_TRACE_PACKET=1") - output[/git< version (\d+)/, 1] || 'unknown' + # The git protocol must advertise it's version in the headers + # exchanged during the initial handshake. GIT_TRACE_CURL provides + # the header data and then GIT_TRACE_CURL_NOT_DATA ignores the + # extraneous data to keep return size down. + result = run("git ls-remote #{uri}", "GIT_TRACE_CURL=1 GIT_TRACE_CURL_NO_DATA=1") + result.response[/Git-Protocol: version=(\d+)/, 1] || 'unknown' end def try_add_credentials_to_netrc diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb index 62c81050bd9..d8200686f44 100644 --- a/qa/spec/git/repository_spec.rb +++ b/qa/spec/git/repository_spec.rb @@ -68,12 +68,12 @@ describe QA::Git::Repository do describe '#fetch_supported_git_protocol' do it "reports the detected version" do - expect(repository).to receive(:run).and_return("packet: git< version 2") + expect(repository).to receive(:run).and_return("=> Send header: Git-Protocol: version=2") expect(repository.fetch_supported_git_protocol).to eq('2') end it 'reports unknown if version is unknown' do - expect(repository).to receive(:run).and_return("packet: git< version -1") + expect(repository).to receive(:run).and_return("=> Send header: Git-Protocol: version=-1") expect(repository.fetch_supported_git_protocol).to eq('unknown') end |