Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-06-14 21:08:25 +00:00
parent ebc7110bd9
commit 6b4c082fc8
7 changed files with 64 additions and 4 deletions

View file

@ -137,6 +137,7 @@ module QA
module Instance
autoload :All, 'qa/scenario/test/instance/all'
autoload :Smoke, 'qa/scenario/test/instance/smoke'
autoload :Airgapped, 'qa/scenario/test/instance/airgapped'
end
module Integration

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
module QA
module Scenario
module Test
module Instance
class Airgapped < Template
include Bootable
include SharedAttributes
def perform(address, *rspec_options)
Runtime::Scenario.define(:runner_network, 'airgapped')
super
end
end
end
end
end
end

View file

@ -8,6 +8,7 @@ module QA
def initialize
@network = Runtime::Scenario.attributes[:network] || 'test'
@runner_network = Runtime::Scenario.attributes[:runner_network] || @network
end
def network
@ -18,6 +19,14 @@ module QA
@network
end
def runner_network
shell "docker network inspect #{@runner_network}"
rescue CommandError
network
else
@runner_network
end
def pull
shell "docker pull #{@image}"
end

View file

@ -1,5 +1,6 @@
# frozen_string_literal: true
require 'resolv'
require 'securerandom'
module QA
@ -38,11 +39,16 @@ module QA
def register!
shell <<~CMD.tr("\n", ' ')
docker run -d --rm --entrypoint=/bin/sh
--network #{network} --name #{@name}
--network #{runner_network} --name #{@name}
#{'-v /var/run/docker.sock:/var/run/docker.sock' if @executor == :docker}
--privileged
#{@image} -c "#{register_command}"
CMD
# Prove airgappedness
if runner_network == 'airgapped'
shell("docker exec #{@name} sh -c '#{prove_airgap}'")
end
end
def tags=(tags)
@ -85,6 +91,17 @@ module QA
gitlab-runner run
CMD
end
# Ping CloudFlare DNS, should fail
# Ping Registry, should fail to resolve
def prove_airgap
gitlab_ip = Resolv.getaddress 'registry.gitlab.com'
<<~CMD
echo "Checking airgapped connectivity..."
nc -zv -w 10 #{gitlab_ip} 80 && (echo "Airgapped network faulty. Connectivity netcat check failed." && exit 1) || (echo "Connectivity netcat check passed." && exit 0)
wget --retry-connrefused --waitretry=1 --read-timeout=15 --timeout=10 -t 2 http://registry.gitlab.com > /dev/null 2>&1 && (echo "Airgapped network faulty. Connectivity wget check failed." && exit 1) || (echo "Airgapped network confirmed. Connectivity wget check passed." && exit 0)
CMD
end
end
end
end

View file

@ -16,7 +16,9 @@ module QA
end
def host_name
return 'localhost' unless QA::Runtime::Env.running_in_ci?
if !QA::Runtime::Env.running_in_ci? && !runner_network.equal?('airgapped')
'localhost'
end
super
end
@ -33,7 +35,9 @@ module QA
#{@image}
CMD
command.gsub!("--network #{network} ", '') unless QA::Runtime::Env.running_in_ci?
if !QA::Runtime::Env.running_in_ci? && !runner_network.equal?('airgapped')
command.gsub!("--network #{network} ", '')
end
shell command
end

View file

@ -0,0 +1,8 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Instance::Airgapped do
describe '#perform' do
it_behaves_like 'a QA scenario class' do
end
end
end

View file

@ -3,7 +3,7 @@
require 'spec_helper'
describe BulkInsertSafe do
class BulkInsertItem < ApplicationRecord
class BulkInsertItem < ActiveRecord::Base
include BulkInsertSafe
include ShaAttribute
@ -74,6 +74,8 @@ describe BulkInsertSafe do
ActiveRecord::Schema.define do
drop_table :bulk_insert_items, force: true
end
BulkInsertItem.reset_column_information
end
describe BulkInsertItem do