diff options
author | Nick Thomas <nick@gitlab.com> | 2018-11-08 00:13:51 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-11-08 00:13:51 +0000 |
commit | 068e75f660e0321dd5aed20217de20b6a46e43b6 (patch) | |
tree | 76b5512d56245833a41d7f9afd157f3db3879c9f /qa/spec | |
parent | daa6fe7f0a80c75fdbe03abddbc058572c1a5efc (diff) | |
parent | 765ca40d65c6644d2158eb04898a0f3d6e316e31 (diff) | |
download | gitlab-ce-068e75f660e0321dd5aed20217de20b6a46e43b6.tar.gz |
Merge branch 'ml-qa-git-protocol-v2-spec' into 'master'
Add e2e test of push over SSH using Git protocol v2
See merge request gitlab-org/gitlab-ce!22548
Diffstat (limited to 'qa/spec')
-rw-r--r-- | qa/spec/git/repository_spec.rb | 30 | ||||
-rw-r--r-- | qa/spec/runtime/env_spec.rb | 47 | ||||
-rw-r--r-- | qa/spec/specs/runner_spec.rb | 14 |
3 files changed, 80 insertions, 11 deletions
diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb index c629f802aa4..faa154c78da 100644 --- a/qa/spec/git/repository_spec.rb +++ b/qa/spec/git/repository_spec.rb @@ -26,6 +26,36 @@ describe QA::Git::Repository do end end + describe '#git_protocol=' do + [0, 1, 2].each do |version| + it "configures git to use protocol version #{version}" do + expect(repository).to receive(:run).with("git config protocol.version #{version}") + repository.git_protocol = version + end + end + + it 'raises an error if the version is unsupported' do + expect { repository.git_protocol = 'foo' }.to raise_error(ArgumentError, "Please specify the protocol you would like to use: 0, 1, or 2") + end + end + + 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.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.fetch_supported_git_protocol).to eq('unknown') + end + + it 'reports unknown if content does not identify a version' do + expect(repository).to receive(:run).and_return("foo") + expect(repository.fetch_supported_git_protocol).to eq('unknown') + end + end + def cd_empty_temp_directory tmp_dir = 'tmp/git-repository-spec/' FileUtils.rm_rf(tmp_dir) if ::File.exist?(tmp_dir) diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb index c59c415c148..ded51d5bb7c 100644 --- a/qa/spec/runtime/env_spec.rb +++ b/qa/spec/runtime/env_spec.rb @@ -3,49 +3,62 @@ describe QA::Runtime::Env do include Support::StubENV - shared_examples 'boolean method' do |method, env_key, default| + shared_examples 'boolean method' do |**kwargs| + it_behaves_like 'boolean method with parameter', kwargs + end + + shared_examples 'boolean method with parameter' do |method:, param: nil, env_key:, default:| context 'when there is an env variable set' do it 'returns false when falsey values specified' do stub_env(env_key, 'false') - expect(described_class.public_send(method)).to be_falsey + expect(described_class.public_send(method, *param)).to be_falsey stub_env(env_key, 'no') - expect(described_class.public_send(method)).to be_falsey + expect(described_class.public_send(method, *param)).to be_falsey stub_env(env_key, '0') - expect(described_class.public_send(method)).to be_falsey + expect(described_class.public_send(method, *param)).to be_falsey end it 'returns true when anything else specified' do stub_env(env_key, 'true') - expect(described_class.public_send(method)).to be_truthy + expect(described_class.public_send(method, *param)).to be_truthy stub_env(env_key, '1') - expect(described_class.public_send(method)).to be_truthy + expect(described_class.public_send(method, *param)).to be_truthy stub_env(env_key, 'anything') - expect(described_class.public_send(method)).to be_truthy + expect(described_class.public_send(method, *param)).to be_truthy end end context 'when there is no env variable set' do it "returns the default, #{default}" do stub_env(env_key, nil) - expect(described_class.public_send(method)).to be(default) + expect(described_class.public_send(method, *param)).to be(default) end end end describe '.signup_disabled?' do - it_behaves_like 'boolean method', :signup_disabled?, 'SIGNUP_DISABLED', false + it_behaves_like 'boolean method', + method: :signup_disabled?, + env_key: 'SIGNUP_DISABLED', + default: false end describe '.debug?' do - it_behaves_like 'boolean method', :debug?, 'QA_DEBUG', false + it_behaves_like 'boolean method', + method: :debug?, + env_key: 'QA_DEBUG', + default: false end describe '.chrome_headless?' do - it_behaves_like 'boolean method', :chrome_headless?, 'CHROME_HEADLESS', true + it_behaves_like 'boolean method', + method: :chrome_headless?, + env_key: 'CHROME_HEADLESS', + default: true end describe '.running_in_ci?' do @@ -182,4 +195,16 @@ describe QA::Runtime::Env do expect(described_class.log_destination).to eq('path/to_file') end end + + describe '.can_test?' do + it_behaves_like 'boolean method with parameter', + method: :can_test?, + param: :git_protocol_v2, + env_key: 'QA_CAN_TEST_GIT_PROTOCOL_V2', + default: true + + it 'raises ArgumentError if feature is unknown' do + expect { described_class.can_test? :foo }.to raise_error(ArgumentError, 'Unknown feature "foo"') + end + end end diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb index 9ddaf7ab1b3..741821ddf8c 100644 --- a/qa/spec/specs/runner_spec.rb +++ b/qa/spec/specs/runner_spec.rb @@ -76,6 +76,20 @@ describe QA::Specs::Runner do end end + context 'when git protocol v2 is not supported' do + before do + allow(QA::Runtime::Env).to receive(:can_test?).with(:git_protocol_v2).and_return(false) + end + + subject { described_class.new } + + it 'it includes default args and excludes the requires_git_protocol_v2 tag' do + expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~requires_git_protocol_v2', *described_class::DEFAULT_TEST_PATH_ARGS]) + + subject.perform + end + end + def expect_rspec_runner_arguments(arguments) expect(RSpec::Core::Runner).to receive(:run) .with(arguments, $stderr, $stdout) |