diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-04-10 11:04:51 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-04-10 11:51:19 +0200 |
commit | 2b9492a292d389d8390a9eca6a80e730ab7b6f1e (patch) | |
tree | 5f494717d67447249f002b56cb7c84c0a4f2eb19 /spec | |
parent | e861af409df4139e2a1c7434b1ca490710c786f1 (diff) | |
download | gitlab-ce-2b9492a292d389d8390a9eca6a80e730ab7b6f1e.tar.gz |
Process at most 4 pipelines during pushlimit-amount-of-created-pipelines
This adds a limitation that we will try to create pipeline
for at most 4 first changes (branches and tags).
This does not affect processing of Pipelines for Merge Requests,
as each updated MR will have associated pipeline created.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/workers/post_receive_spec.rb | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index a3fe8fa4501..39f1beb4efa 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -99,11 +99,21 @@ describe PostReceive do end context "gitlab-ci.yml" do - let(:changes) { "123456 789012 refs/heads/feature\n654321 210987 refs/tags/tag" } + let(:changes) do + <<-EOF.strip_heredoc + 123456 789012 refs/heads/feature + 654321 210987 refs/tags/tag + 123456 789012 refs/heads/feature2 + 123458 789013 refs/heads/feature3 + 123459 789015 refs/heads/feature4 + EOF + end + + let(:changes_count) { changes.lines.count } subject { described_class.new.perform(gl_repository, key_id, base64_changes) } - context "creates a Ci::Pipeline for every change" do + context "with valid .gitlab-ci.yml" do before do stub_ci_pipeline_to_return_yaml_file @@ -116,7 +126,33 @@ describe PostReceive do .and_return(true) end - it { expect { subject }.to change { Ci::Pipeline.count }.by(2) } + context 'when git_push_create_all_pipelines is disabled' do + before do + stub_feature_flags(git_push_create_all_pipelines: false) + end + + it "creates pipeline for branches and tags" do + subject + + expect(Ci::Pipeline.pluck(:ref)).to contain_exactly("feature", "tag", "feature2", "feature3") + end + + it "creates exactly #{described_class::PIPELINE_PROCESS_LIMIT} pipelines" do + expect(changes_count).to be > described_class::PIPELINE_PROCESS_LIMIT + + expect { subject }.to change { Ci::Pipeline.count }.by(described_class::PIPELINE_PROCESS_LIMIT) + end + end + + context 'when git_push_create_all_pipelines is enabled' do + before do + stub_feature_flags(git_push_create_all_pipelines: true) + end + + it "creates all pipelines" do + expect { subject }.to change { Ci::Pipeline.count }.by(changes_count) + end + end end context "does not create a Ci::Pipeline" do |