diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 89b7868387a18dcbb73b906e7b32f5d79306a79d..0d0c8071e97d4fc4524939b2207370d2a19dd5a9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -124,16 +124,18 @@ package-and-test: - package-and-test-env variables: RELEASE: EE + QA_IMAGE: registry.gitlab.com/gitlab-org/gitlab/gitlab-ee-qa:jmd-offline-environment-pipeline RUN_WITH_BUNDLE: "true" SKIP_OMNIBUS_TRIGGER: "true" SKIP_REPORT_IN_ISSUES: "true" ALLURE_JOB_NAME: gitlab-qa UPDATE_QA_CACHE: $UPDATE_QA_CACHE GITLAB_QA_CACHE_KEY: $GITLAB_QA_CACHE_KEY + QA_TESTS: qa/specs/features/ee/browser_ui/2_plan/epic/epics_management_spec.rb qa/specs/features/browser_ui/1_manage/integrations/jenkins/jenkins_build_status_spec.rb qa/specs/features/ee/browser_ui/2_plan/epic/epics_management_spec.rb inherit: variables: - RUBY_VERSION - when: manual + when: on_success trigger: strategy: depend forward: @@ -141,5 +143,33 @@ package-and-test: pipeline_variables: true include: - project: gitlab-org/gitlab - ref: master + ref: jmd/offline-environment-pipeline + file: .gitlab/ci/package-and-test/main.gitlab-ci.yml + + +package-and-test-with-bundle-false: + stage: qa + needs: + - package-and-test-env + variables: + RELEASE: EE + QA_IMAGE: registry.gitlab.com/gitlab-org/gitlab/gitlab-ee-qa:jmd-offline-environment-pipeline + RUN_WITH_BUNDLE: "false" + SKIP_OMNIBUS_TRIGGER: "true" + SKIP_REPORT_IN_ISSUES: "true" + ALLURE_JOB_NAME: gitlab-qa + UPDATE_QA_CACHE: $UPDATE_QA_CACHE + GITLAB_QA_CACHE_KEY: $GITLAB_QA_CACHE_KEY + inherit: + variables: + - RUBY_VERSION + when: on_success + trigger: + strategy: depend + forward: + yaml_variables: true + pipeline_variables: true + include: + - project: gitlab-org/gitlab + ref: jmd/offline-environment-pipeline file: .gitlab/ci/package-and-test/main.gitlab-ci.yml diff --git a/lib/gitlab/qa/component/gitaly_cluster.rb b/lib/gitlab/qa/component/gitaly_cluster.rb index cd1fba3e9c29f00679e03e0cd0e66997383e0d64..4eb991e99ece5fdd7ba127164c7addc9023c7c3d 100644 --- a/lib/gitlab/qa/component/gitaly_cluster.rb +++ b/lib/gitlab/qa/component/gitaly_cluster.rb @@ -6,7 +6,7 @@ module Gitlab class GitalyCluster class GitalyClusterConfig attr_accessor :gitlab_name, :network, :airgapped_network, - :praefect_node_name, :praefect_port, :praefect_ip, + :praefect_node_name, :praefect_port, :primary_node_name, :primary_node_port, :secondary_node_name, :secondary_node_port, :tertiary_node_name, :tertiary_node_port, @@ -57,24 +57,24 @@ module Gitlab end # @param [Boolean] parallel_gitaly controls whether we start gitaly nodes in parallel to improve startup time - def instance(parallel_gitaly = false) - run_gitaly_cluster(QA::Release.new(release), parallel_gitaly) + def instance(parallel_gitaly = false, gitaly_nodes = 3) + run_gitaly_cluster(QA::Release.new(release), parallel_gitaly, gitaly_nodes) end # @param [Boolean] parallel_gitaly controls whether we start gitaly nodes in parallel to improve startup time - def run_gitaly_cluster(release, parallel_gitaly = false) + def run_gitaly_cluster(release, parallel_gitaly = false, gitaly_nodes = 3) # This also ensure that the docker network is created here, avoiding any potential race conditions later # if the gitaly-cluster and GitLab containers attempt to create a network in parallel @database_node = postgres Thread.new do Thread.current.abort_on_exception = true - start_gitaly_cluster(release, parallel_gitaly) + start_gitaly_cluster(release, parallel_gitaly, gitaly_nodes) end end # @param [Boolean] parallel_gitaly controls whether we start gitaly nodes in parallel to improve startup time - def start_gitaly_cluster(release, parallel_gitaly = false) # rubocop:disable Metrics/AbcSize + def start_gitaly_cluster(release, parallel_gitaly = false, nodes = 3) # rubocop:disable Metrics/AbcSize Runtime::Logger.info("Starting Gitaly Cluster") if parallel_gitaly @@ -84,13 +84,15 @@ module Gitlab threads << Thread.new { @gitaly_tertiary_node = gitaly(config.tertiary_node_name, config.tertiary_node_port, release) } threads.each(&:join) else - @gitaly_primary_node = gitaly(config.primary_node_name, config.primary_node_port, release) - @gitaly_secondary_node = gitaly(config.secondary_node_name, config.secondary_node_port, release) - @gitaly_tertiary_node = gitaly(config.tertiary_node_name, config.tertiary_node_port, release) + @gitaly_primary_node = gitaly(config.primary_node_name, config.primary_node_port, release) if nodes >= 1 + + name2 = config.secondary_node_name + @gitaly_secondary_node = gitaly(name2, config.secondary_node_port, release) if nodes >= 2 + + @gitaly_tertiary_node = gitaly(config.tertiary_node_name, config.tertiary_node_port, release) if nodes >= 3 end @praefect_node = praefect(release) - config.praefect_ip = praefect_node.ip_address Runtime::Logger.info("Gitaly Cluster Ready") end diff --git a/lib/gitlab/qa/scenario/test/instance/airgapped.rb b/lib/gitlab/qa/scenario/test/instance/airgapped.rb index 0d2053ad3efd650619f1e83f44d9c4abb9360907..e6ebaa9b1eaafe39f8d7bd4522e44e24d0153d52 100644 --- a/lib/gitlab/qa/scenario/test/instance/airgapped.rb +++ b/lib/gitlab/qa/scenario/test/instance/airgapped.rb @@ -7,15 +7,13 @@ module Gitlab module Instance class Airgapped < Scenario::Template require 'resolv' - attr_reader :config, :gitlab_air_gap_commands, :iptables_restricted_network, :airgapped_network_name + attr_reader :config, :gitlab_air_gap_commands, :airgapped_network_name, :runner_network def initialize - # Uses https://docs.docker.com/engine/reference/commandline/network_create/#network-internal-mode - @airgapped_network_name = 'airgapped' - # Uses iptables to deny all network traffic, with a number of exceptions for required ports and IPs - @iptables_restricted_network = 'test' + @airgapped_network_name = 'test' + @runner_network = 'airgapped' @config = Component::GitalyCluster::GitalyClusterConfig.new( - gitlab_name: "gitlab-airgapped-#{SecureRandom.hex(4)}", + gitlab_name: "gitlab-airgapped", airgapped_network: true, network: airgapped_network_name ) @@ -23,22 +21,21 @@ module Gitlab def perform(release, *rspec_args) Component::Gitlab.perform do |gitlab| - Component::GitalyCluster.perform do |cluster| + cluster = Component::GitalyCluster.perform do |cluster| cluster.config = @config cluster.release = release - # we need to get an IP for praefect before proceeding so it cannot be run in parallel with gitlab - cluster.instance(true).join + cluster.instance(false, 3) end gitlab.name = config.gitlab_name gitlab.release = release - gitlab.network = iptables_restricted_network # we use iptables to restrict access on the gitlab instance - gitlab.runner_network = config.network - gitlab.exec_commands = airgap_gitlab_commands + gitlab.network = config.network + gitlab.runner_network = runner_network gitlab.skip_availability_check = true gitlab.omnibus_configuration << gitlab_omnibus_configuration rspec_args << "--" unless rspec_args.include?('--') rspec_args << %w[--tag ~orchestrated] gitlab.instance do + cluster.join Component::Specs.perform do |specs| specs.suite = 'Test::Instance::Airgapped' specs.release = gitlab.release @@ -52,55 +49,9 @@ module Gitlab private - def airgap_gitlab_commands - gitlab_ip = Resolv.getaddress('gitlab.com') - gitlab_registry_ip = Resolv.getaddress(QA::Release::COM_REGISTRY) - dev_gitlab_registry_ip = Resolv.getaddress(QA::Release::DEV_REGISTRY.split(':')[0]) - praefect_ip = config.praefect_ip - @commands = <<~AIRGAP_AND_VERIFY_COMMAND.split(/\n+/) - # Should not fail before airgapping due to eg. DNS failure - # Ping and wget check - apt-get update && apt-get install -y iptables ncat - if ncat -zv -w 10 #{gitlab_ip} 80; then echo 'Airgapped connectivity check passed.'; else echo 'Airgapped connectivity check failed - should be able to access gitlab_ip'; exit 1; fi; - - echo "Checking regular connectivity..." \ - && wget --retry-connrefused --waitretry=1 --read-timeout=15 --timeout=10 -t 2 http://registry.gitlab.com > /dev/null 2>&1 \ - && (echo "Regular connectivity wget check passed." && exit 0) || (echo "Regular connectivity wget check failed." && exit 1) - - iptables -P INPUT DROP && iptables -P OUTPUT DROP - iptables -A INPUT -i lo -j ACCEPT && iptables -A OUTPUT -o lo -j ACCEPT # LOOPBACK - iptables -I INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT - iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT - - # Jenkins on port 8080 and 50000 - iptables -A OUTPUT -p tcp -m tcp --dport 8080 -m state --state NEW,ESTABLISHED -j ACCEPT \ - && iptables -A OUTPUT -p tcp -m tcp --dport 50000 -m state --state NEW,ESTABLISHED -j ACCEPT - iptables -A OUTPUT -p tcp -m tcp --sport 22 -m state --state NEW,ESTABLISHED -j ACCEPT - iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT - iptables -A OUTPUT -p tcp -m tcp --sport 80 -m state --state NEW,ESTABLISHED -j ACCEPT - iptables -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT - - # some exceptions to allow runners access network https://gitlab.com/gitlab-org/gitlab-qa/-/issues/700 - iptables -A OUTPUT -p tcp -d #{gitlab_registry_ip} -j ACCEPT - iptables -A OUTPUT -p tcp -d #{dev_gitlab_registry_ip} -j ACCEPT - # allow access to praefect node - iptables -A OUTPUT -p tcp -d #{praefect_ip} -j ACCEPT - - # Should now fail to ping gitlab_ip, port 22/80 should be open - if ncat -zv -w 10 #{gitlab_ip} 80; then echo 'Airgapped connectivity check failed - should not be able to access gitlab_ip'; exit 1; else echo 'Airgapped connectivity check passed.'; fi; - if ncat -zv -w 10 127.0.0.1 22; then echo 'Airgapped connectivity port 22 check passed.'; else echo 'Airgapped connectivity port 22 check failed.'; exit 1; fi; - if ncat -zv -w 10 127.0.0.1 80; then echo 'Airgapped connectivity port 80 check passed.'; else echo 'Airgapped connectivity port 80 check failed.'; exit 1 ; fi; - if ncat -zv -w 10 #{gitlab_registry_ip} 80; then echo 'Airgapped connectivity port gitlab_registry_ip check passed.'; else echo 'Airgapped connectivity port 80 check failed.'; exit 1; fi; - - echo "Checking airgapped connectivity..." \ - && 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) - AIRGAP_AND_VERIFY_COMMAND - end - def gitlab_omnibus_configuration <<~OMNIBUS - external_url 'http://#{config.gitlab_name}.#{iptables_restricted_network}'; + external_url 'http://#{config.gitlab_name}.#{airgapped_network_name}'; git_data_dirs({ 'default' => {