diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e0480e894b68b2c0302eb25b45d7e0e3d9a7de3..2a5774e3e2d84713e53fb8dd2990f0e0de8aa34c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -93,3 +93,12 @@ ce:mattermost: ee:mattermost: script: bin/qa Test::Integration::Mattermost EE <<: *test + +ee:geo: + script: bin/qa Test::Integration::Geo EE + allow_failure: true + tags: + - docker + - 7gb + - triggered-packages + <<: *test diff --git a/lib/gitlab/qa.rb b/lib/gitlab/qa.rb index baab2b392b6153301eae34eeaf4907d3b1f8e04b..6be181a3f688906d4c925548b09651a5a5883a6a 100644 --- a/lib/gitlab/qa.rb +++ b/lib/gitlab/qa.rb @@ -25,6 +25,7 @@ module Gitlab module Integration autoload :Mattermost, 'qa/scenario/test/integration/mattermost' + autoload :Geo, 'qa/scenario/test/integration/geo' end module Sanity diff --git a/lib/gitlab/qa/component/gitlab.rb b/lib/gitlab/qa/component/gitlab.rb index c35ff8ea337971434fcb9d3371f43591dcdea773..ab24e94d59ee28f2f18796e0bac5f0693a0464c1 100644 --- a/lib/gitlab/qa/component/gitlab.rb +++ b/lib/gitlab/qa/component/gitlab.rb @@ -2,7 +2,6 @@ require 'securerandom' require 'net/http' require 'uri' require 'forwardable' -require 'shellwords' module Gitlab module QA @@ -14,7 +13,7 @@ module Gitlab # rubocop:disable Style/Semicolon attr_reader :release, :docker - attr_accessor :volumes, :network, :environment, :network_aliases + attr_accessor :volumes, :network, :environment def_delegators :release, :tag, :image, :edition @@ -28,7 +27,11 @@ module Gitlab end def omnibus_config=(config) - @environment['GITLAB_OMNIBUS_CONFIG'] = config + @environment['GITLAB_OMNIBUS_CONFIG'] = config.tr("\n", ' ') + end + + def add_network_alias(name) + @network_aliases.push(name) end def release=(release) @@ -79,8 +82,7 @@ module Gitlab end @environment.to_h.each do |key, value| - escaped_value = Shellwords.escape(value) - command << "--env #{key}=#{escaped_value}" + command << %(--env #{key}="#{value}") end @network_aliases.to_a.each do |network_alias| diff --git a/lib/gitlab/qa/scenario/test/integration/geo.rb b/lib/gitlab/qa/scenario/test/integration/geo.rb new file mode 100644 index 0000000000000000000000000000000000000000..cfdc9a063cff410ae06db8519781978dd5aa1dd9 --- /dev/null +++ b/lib/gitlab/qa/scenario/test/integration/geo.rb @@ -0,0 +1,72 @@ +module Gitlab + module QA + module Scenario + module Test + module Integration + class Geo < Scenario::Template + ## + # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize + # + def perform(release) + release = Release.new(release) + + unless release.edition == :ee + raise ArgumentError, 'Geo is EE only!' + end + + Component::Gitlab.perform do |primary| + primary.release = release + primary.network = 'geo' + primary.omnibus_config = <<~OMNIBUS + geo_primary_role['enable'] = true; + postgresql['listen_address'] = '0.0.0.0'; + postgresql['trust_auth_cidr_addresses'] = ['0.0.0.0/0','0.0.0.0/0']; + postgresql['md5_auth_cidr_addresses'] = ['0.0.0.0/0']; + postgresql['max_replication_slots'] = 1; + gitlab_rails['db_key_base'] = '4dd58204865eb41bca93bd38131d51cc'; + OMNIBUS + + primary.instance do + Component::Gitlab.perform do |secondary| + secondary.release = release + secondary.network = 'geo' + secondary.omnibus_config = <<~OMNIBUS + geo_secondary_role['enable'] = true; + gitlab_rails['db_key_base'] = '4dd58204865eb41bca93bd38131d51cc'; + OMNIBUS + + secondary.act do + # TODO, we do not wait for secondary to start because of + # https://gitlab.com/gitlab-org/gitlab-ee/issues/3999 + # + # rubocop:disable Style/Semicolon + prepare; start; reconfigure + + # shellout to instance specs + puts 'Running Geo primary / secondary specs!' + + Component::Specs.perform do |specs| + specs.suite = 'Test::Integration::Geo' + specs.release = release + specs.network = 'geo' + specs.args = [ + '--primary-address', primary.address, + '--primary-name', primary.name, + '--secondary-address', secondary.address, + '--secondary-name', secondary.name + ] + end + + teardown + end + end + end + end + end + end + end + end + end + end +end diff --git a/lib/gitlab/qa/scenario/test/integration/mattermost.rb b/lib/gitlab/qa/scenario/test/integration/mattermost.rb index f46d6d3bf29046373827352fd1ccb5bb5098de4a..b9685c6241fc3d7680487e04a6f34115ac3d8b23 100644 --- a/lib/gitlab/qa/scenario/test/integration/mattermost.rb +++ b/lib/gitlab/qa/scenario/test/integration/mattermost.rb @@ -11,9 +11,11 @@ module Gitlab mattermost_hostname = "mattermost.#{gitlab.network}" mattermost_external_url = "http://#{mattermost_hostname}" - gitlab.omnibus_config = - "mattermost_external_url '#{mattermost_external_url}'" - gitlab.network_aliases = [mattermost_hostname] + + gitlab.add_network_alias(mattermost_hostname) + gitlab.omnibus_config = <<~OMNIBUS + mattermost_external_url '#{mattermost_external_url}' + OMNIBUS gitlab.instance do Component::Specs.perform do |specs| diff --git a/spec/component/gitlab_spec.rb b/spec/component/gitlab_spec.rb index 8a94d57f9feb544437ee7e548251e18b8e46d25f..cba72ee647dd50c21ca496db8cc339480e965916 100644 --- a/spec/component/gitlab_spec.rb +++ b/spec/component/gitlab_spec.rb @@ -8,7 +8,7 @@ describe Gitlab::QA::Component::Gitlab do subject.omnibus_config = '# Be configured' end - it 'updates #environment' do + it 'updates environment variables' do expect(subject.environment['GITLAB_OMNIBUS_CONFIG']) .to eq('# Be configured') end @@ -135,41 +135,31 @@ describe Gitlab::QA::Component::Gitlab do it 'adds --volume switches to the command' do subject.start + expect(args).to include('--volume /from:/to:Z') end end context 'with environment' do - context 'plain values' do - before do - subject.environment = { 'TEST' => 'value' } - end - - it 'adds --env switches to the command' do - subject.start - expect(args).to include('--env TEST=value') - end + before do + subject.environment = { 'TEST' => 'a value with spaces' } end - context 'values with spaces' do - before do - subject.environment = { 'TEST' => 'a value with spaces' } - end + it 'adds quotes around env' do + subject.start - it 'adds --env shell escaped values' do - subject.start - expect(args).to include('--env TEST=a\ value\ with\ spaces') - end + expect(args).to include('--env TEST="a value with spaces"') end end - context 'with network_aliases' do + context 'with network_alias' do before do - subject.network_aliases = ['lolcathost'] + subject.add_network_alias('lolcathost') end it 'adds --network-alias switches to the command' do subject.start + expect(args).to include('--network-alias lolcathost') end end