diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/requests/api/ci/runner/jobs_request_post_spec.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/requests/api/ci/runner/jobs_request_post_spec.rb')
-rw-r--r-- | spec/requests/api/ci/runner/jobs_request_post_spec.rb | 83 |
1 files changed, 33 insertions, 50 deletions
diff --git a/spec/requests/api/ci/runner/jobs_request_post_spec.rb b/spec/requests/api/ci/runner/jobs_request_post_spec.rb index cd58251cfcc..b33b97f90d7 100644 --- a/spec/requests/api/ci/runner/jobs_request_post_spec.rb +++ b/spec/requests/api/ci/runner/jobs_request_post_spec.rb @@ -17,11 +17,12 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do end describe '/api/v4/jobs' do - let(:group) { create(:group, :nested) } + let_it_be(:group) { create(:group, :nested) } + let_it_be(:user) { create(:user) } + let(:project) { create(:project, namespace: group, shared_runners_enabled: false) } - let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master') } let(:runner) { create(:ci_runner, :project, projects: [project]) } - let(:user) { create(:user) } + let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master') } let(:job) do create(:ci_build, :pending, :queued, :artifacts, :extended_options, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) @@ -145,7 +146,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do let(:expected_job_info) do { 'id' => job.id, 'name' => job.name, - 'stage' => job.stage, + 'stage' => job.stage_name, 'project_id' => job.project.id, 'project_name' => job.project.name } end @@ -354,6 +355,9 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do end context 'when GIT_DEPTH is not specified and there is no default git depth for the project' do + let(:project) { create(:project, namespace: group, shared_runners_enabled: false) } + let(:runner) { create(:ci_runner, :project, projects: [project]) } + before do project.update!(ci_default_git_depth: nil) end @@ -411,7 +415,8 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do context 'when job is made for merge request' do let(:pipeline) { create(:ci_pipeline, source: :merge_request_event, project: project, ref: 'feature', merge_request: merge_request) } let!(:job) { create(:ci_build, :pending, :queued, pipeline: pipeline, name: 'spinach', ref: 'feature', stage: 'test', stage_idx: 0) } - let(:merge_request) { create(:merge_request) } + + let_it_be(:merge_request) { create(:merge_request) } it 'sets branch as ref_type' do request_job @@ -546,9 +551,12 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do let!(:job) { create(:ci_build, :pending, :queued, :tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) } let!(:job2) { create(:ci_build, :pending, :queued, :tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) } let!(:test_job) do - create(:ci_build, :pending, :queued, pipeline: pipeline, name: 'deploy', - stage: 'deploy', stage_idx: 1, - options: { script: ['bash'], dependencies: [job2.name] }) + create(:ci_build, :pending, :queued, + pipeline: pipeline, + name: 'deploy', + stage: 'deploy', + stage_idx: 1, + options: { script: ['bash'], dependencies: [job2.name] }) end before do @@ -570,9 +578,12 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do let!(:job) { create(:ci_build, :pending, :queued, :tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) } let!(:job2) { create(:ci_build, :pending, :queued, :tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) } let!(:empty_dependencies_job) do - create(:ci_build, :pending, :queued, pipeline: pipeline, name: 'empty_dependencies_job', - stage: 'deploy', stage_idx: 1, - options: { script: ['bash'], dependencies: [] }) + create(:ci_build, :pending, :queued, + pipeline: pipeline, + name: 'empty_dependencies_job', + stage: 'deploy', + stage_idx: 1, + options: { script: ['bash'], dependencies: [] }) end before do @@ -722,7 +733,9 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do describe 'timeout support' do context 'when project specifies job timeout' do - let(:project) { create(:project, shared_runners_enabled: false, build_timeout: 1234) } + let_it_be(:project) { create(:project, shared_runners_enabled: false, build_timeout: 1234) } + + let(:runner) { create(:ci_runner, :project, projects: [project]) } it 'contains info about timeout taken from project' do request_job @@ -827,22 +840,6 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do 'image' => { 'name' => 'ruby', 'pull_policy' => ['if-not-present'], 'entrypoint' => nil, 'ports' => [] } ) end - - context 'when the FF ci_docker_image_pull_policy is disabled' do - before do - stub_feature_flags(ci_docker_image_pull_policy: false) - end - - it 'returns the image without pull policy' do - request_job - - expect(response).to have_gitlab_http_status(:created) - expect(json_response).to include( - 'id' => job.id, - 'image' => { 'name' => 'ruby', 'entrypoint' => nil, 'ports' => [] } - ) - end - end end context 'when service has pull_policy' do @@ -867,31 +864,17 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do 'ports' => [], 'pull_policy' => ['if-not-present'], 'variables' => [] }] ) end - - context 'when the FF ci_docker_image_pull_policy is disabled' do - before do - stub_feature_flags(ci_docker_image_pull_policy: false) - end - - it 'returns the service without pull policy' do - request_job - - expect(response).to have_gitlab_http_status(:created) - expect(json_response).to include( - 'id' => job.id, - 'services' => [{ 'alias' => nil, 'command' => nil, 'entrypoint' => nil, 'name' => 'postgres:11.9', - 'ports' => [], 'variables' => [] }] - ) - end - end end describe 'a job with excluded artifacts' do context 'when excluded paths are defined' do let(:job) do - create(:ci_build, :pending, :queued, pipeline: pipeline, name: 'test', - stage: 'deploy', stage_idx: 1, - options: { artifacts: { paths: ['abc'], exclude: ['cde'] } }) + create(:ci_build, :pending, :queued, + pipeline: pipeline, + name: 'test', + stage: 'deploy', + stage_idx: 1, + options: { artifacts: { paths: ['abc'], exclude: ['cde'] } }) end context 'when a runner supports this feature' do @@ -950,8 +933,8 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do end context 'when the runner is of group type' do - let(:group) { create(:group) } - let(:runner) { create(:ci_runner, :group, groups: [group]) } + let_it_be(:group) { create(:group) } + let_it_be(:runner) { create(:ci_runner, :group, groups: [group]) } it_behaves_like 'storing arguments in the application context for the API' do let(:expected_params) { { root_namespace: group.full_path_components.first, client_id: "runner/#{runner.id}" } } |