diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-14 18:08:29 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-14 18:08:29 +0000 |
commit | f55c9253556dd5dab700d76fa88aa04891343100 (patch) | |
tree | b8a6bcc093304acd38c53f7fa2a6be35708c1003 /qa | |
parent | 9b762f50fee09b50b97b5ab208a9a62522447c8c (diff) | |
download | gitlab-ce-f55c9253556dd5dab700d76fa88aa04891343100.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
9 files changed, 49 insertions, 15 deletions
diff --git a/qa/qa/page/component/access_tokens.rb b/qa/qa/page/component/access_tokens.rb index 3c8a6cf6a1d..6a9249621e1 100644 --- a/qa/qa/page/component/access_tokens.rb +++ b/qa/qa/page/component/access_tokens.rb @@ -19,7 +19,7 @@ module QA end base.view 'app/views/shared/tokens/_scopes_form.html.haml' do - element :api_checkbox, '#{scope}_checkbox' # rubocop:disable QA/ElementWithPattern, Lint/InterpolationCheck + element :api_label, '#{scope}_label' # rubocop:disable QA/ElementWithPattern, Lint/InterpolationCheck end base.view 'app/views/shared/access_tokens/_created_container.html.haml' do @@ -36,7 +36,7 @@ module QA end def check_api - check_element(:api_checkbox) + click_element(:api_label) end def click_create_token_button diff --git a/qa/qa/resource/runner.rb b/qa/qa/resource/runner.rb index 2075f302370..c014563671d 100644 --- a/qa/qa/resource/runner.rb +++ b/qa/qa/resource/runner.rb @@ -31,7 +31,7 @@ module QA end def fabricate_via_api! - Service::DockerRun::GitlabRunner.new(name).tap do |runner| + @docker_container = Service::DockerRun::GitlabRunner.new(name).tap do |runner| runner.pull runner.token = @token ||= project.runners_token runner.address = Runtime::Scenario.gitlab_address @@ -48,11 +48,20 @@ module QA def remove_via_api! runners = list_of_runners(tag_list: @tags) - return if runners.blank? + # If we have no runners, print the logs from the runner docker container in case they show why it isn't running. + if runners.blank? + dump_logs + + return + end this_runner = runners.find { |runner| runner[:description] == name } + # As above, but now we should have a specific runner. If not, print the logs from the runner docker container + # to see if we can find out why the runner isn't running. unless this_runner + dump_logs + raise "Project #{project.path_with_namespace} does not have a runner with a description matching #{name} #{"or tags #{@tags}" if @tags&.any?}. Runners available: #{runners}" end @@ -73,6 +82,10 @@ module QA parse_body(response) end + def reload! + super if method(:running?).super_method.call + end + def api_delete_path "/runners/#{id}" end @@ -86,6 +99,16 @@ module QA def api_post_body end + + private + + def dump_logs + if @docker_container.running? + @docker_container.logs { |line| QA::Runtime::Logger.debug(line) } + else + QA::Runtime::Logger.debug("No runner container found named #{name}") + end + end end end end diff --git a/qa/qa/service/docker_run/base.rb b/qa/qa/service/docker_run/base.rb index 512960e8232..85c06e6c307 100644 --- a/qa/qa/service/docker_run/base.rb +++ b/qa/qa/service/docker_run/base.rb @@ -11,6 +11,12 @@ module QA @runner_network = Runtime::Scenario.attributes[:runner_network] || @network end + def logs + shell "docker logs #{@name}" do |line| + yield " #{line.chomp}" + end + end + def network shell "docker network inspect #{@network}" rescue CommandError diff --git a/qa/qa/service/docker_run/gitlab_runner.rb b/qa/qa/service/docker_run/gitlab_runner.rb index 595d47bf162..0a8ac39dabd 100644 --- a/qa/qa/service/docker_run/gitlab_runner.rb +++ b/qa/qa/service/docker_run/gitlab_runner.rb @@ -43,6 +43,8 @@ module QA #{@image} #{add_gitlab_tls_cert if @address.include? "https"} && docker exec --detach #{@name} sh -c "#{register_command}" CMD + wait_until_running_and_configured + # Prove airgappedness if runner_network == 'airgapped' shell("docker exec #{@name} sh -c '#{prove_airgap}'") @@ -111,6 +113,10 @@ module QA && docker cp #{gitlab_tls_certificate.path} #{@name}:/etc/gitlab-runner/certs/gitlab.test.crt CMD end + + def wait_until_running_and_configured + wait_until_shell_command_matches("docker logs #{@name}", /Configuration loaded/) + end end end end diff --git a/qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb b/qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb index a59e4a99b7d..79bba484bea 100644 --- a/qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb +++ b/qa/qa/specs/features/api/1_manage/import_github_repo_spec.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true module QA - RSpec.describe 'Manage', :github, :requires_admin do + # Spec uses real github.com, which means outage of github.com can actually block deployment + # Keep spec in reliable bucket but don't run in blocking pipelines + RSpec.describe 'Manage', :github, :reliable, :skip_live_env, :requires_admin do describe 'Project import', issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/353583' do let!(:api_client) { Runtime::API::Client.as_admin } let!(:group) { Resource::Group.fabricate_via_api! { |resource| resource.api_client = api_client } } diff --git a/qa/qa/specs/features/api/4_verify/remove_runner_spec.rb b/qa/qa/specs/features/api/4_verify/remove_runner_spec.rb index 64b15c6ff74..d2eba686992 100644 --- a/qa/qa/specs/features/api/4_verify/remove_runner_spec.rb +++ b/qa/qa/specs/features/api/4_verify/remove_runner_spec.rb @@ -15,15 +15,11 @@ module QA end end - before do - sleep 5 # Runner should register within 5 seconds - end - # Removing a runner via the UI is covered by `spec/features/runners_spec.rb`` it 'removes the runner' do - runners = runner.list_of_runners(tag_list: runner_tags) - - expect(runners.size).to eq(1) + runners = nil + expect { (runners = runner.list_of_runners(tag_list: runner_tags)).size } + .to eventually_eq(1).within(max_duration: 10, sleep_interval: 1) expect(runners.first[:description]).to eq(executor) request = Runtime::API::Request.new(api_client, "runners/#{runners.first[:id]}") diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/import_github_repo_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/import_github_repo_spec.rb index a74eda1596b..3bf5a11b074 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/project/import_github_repo_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/project/import_github_repo_spec.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true module QA - RSpec.describe 'Manage', :github, :requires_admin do + # Spec uses real github.com, which means outage of github can actually block deployment + # Keep spec in reliable bucket but don't run in blocking pipelines + RSpec.describe 'Manage', :github, :reliable, :skip_live_env, :requires_admin do describe 'Project import' do let(:github_repo) { 'gitlab-qa-github/import-test' } let(:api_client) { Runtime::API::Client.as_admin } diff --git a/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb index 8aa01888ae3..f8261bba342 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb @@ -22,8 +22,6 @@ module QA Page::Project::Menu.perform(&:go_to_ci_cd_settings) Page::Project::Settings::CiCd.perform do |settings| - sleep 5 # Runner should register within 5 seconds - settings.expand_runners_settings do |page| expect(page).to have_content(executor) expect(page).to have_online_runner diff --git a/qa/spec/service/docker_run/gitlab_runner_spec.rb b/qa/spec/service/docker_run/gitlab_runner_spec.rb index a8838db10cf..d9f201cf67e 100644 --- a/qa/spec/service/docker_run/gitlab_runner_spec.rb +++ b/qa/spec/service/docker_run/gitlab_runner_spec.rb @@ -24,6 +24,7 @@ module QA before do allow(subject).to receive(:shell) + allow(subject).to receive(:wait_until_running_and_configured) end context 'defaults' do |