Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 18:40:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 18:40:28 +0300
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/support/shared_examples/services
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/support/shared_examples/services')
-rw-r--r--spec/support/shared_examples/services/alert_management/alert_processing/alert_recovery_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb40
-rw-r--r--spec/support/shared_examples/services/alert_management_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb3
-rw-r--r--spec/support/shared_examples/services/feature_flags/client_shared_examples.rb19
5 files changed, 53 insertions, 21 deletions
diff --git a/spec/support/shared_examples/services/alert_management/alert_processing/alert_recovery_shared_examples.rb b/spec/support/shared_examples/services/alert_management/alert_processing/alert_recovery_shared_examples.rb
index 86e7da5bcbe..f8e096297d3 100644
--- a/spec/support/shared_examples/services/alert_management/alert_processing/alert_recovery_shared_examples.rb
+++ b/spec/support/shared_examples/services/alert_management/alert_processing/alert_recovery_shared_examples.rb
@@ -56,7 +56,7 @@ RSpec.shared_examples 'processes recovery alert' do
context 'seen for the first time' do
let(:alert) { AlertManagement::Alert.last }
- include_examples 'processes never-before-seen recovery alert'
+ it_behaves_like 'alerts service responds with an error and takes no actions', :bad_request
end
context 'for an existing alert with the same fingerprint' do
@@ -107,7 +107,7 @@ RSpec.shared_examples 'processes recovery alert' do
context 'which is resolved' do
let_it_be(:alert) { create(:alert_management_alert, :resolved, project: project, fingerprint: gitlab_fingerprint, monitoring_tool: source) }
- include_examples 'processes never-before-seen recovery alert'
+ it_behaves_like 'alerts service responds with an error and takes no actions', :bad_request
end
end
end
diff --git a/spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb b/spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb
index 132f1e0422e..3add5485fca 100644
--- a/spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb
+++ b/spec/support/shared_examples/services/alert_management/alert_processing/incident_resolution_shared_examples.rb
@@ -6,18 +6,24 @@
# - `alert`, alert for which related incidents should be closed
# - `project`, project of the alert
RSpec.shared_examples 'closes related incident if enabled' do
- context 'with issue' do
+ context 'with incident' do
before do
- alert.update!(issue: create(:issue, project: project))
+ alert.update!(issue: create(:incident, project: project))
end
- it { expect { subject }.to change { alert.issue.reload.closed? }.from(false).to(true) }
- it { expect { subject }.to change(ResourceStateEvent, :count).by(1) }
+ specify do
+ expect { Sidekiq::Testing.inline! { subject } }
+ .to change { alert.issue.reload.closed? }.from(false).to(true)
+ .and change(ResourceStateEvent, :count).by(1)
+ end
end
- context 'without issue' do
- it { expect { subject }.not_to change { alert.reload.issue } }
- it { expect { subject }.not_to change(ResourceStateEvent, :count) }
+ context 'without incident' do
+ specify do
+ expect(::IncidentManagement::CloseIncidentWorker).not_to receive(:perform_async)
+
+ subject
+ end
end
context 'with incident setting disabled' do
@@ -28,17 +34,23 @@ RSpec.shared_examples 'closes related incident if enabled' do
end
RSpec.shared_examples 'does not close related incident' do
- context 'with issue' do
+ context 'with incident' do
before do
- alert.update!(issue: create(:issue, project: project))
+ alert.update!(issue: create(:incident, project: project))
end
- it { expect { subject }.not_to change { alert.issue.reload.state } }
- it { expect { subject }.not_to change(ResourceStateEvent, :count) }
+ specify do
+ expect { Sidekiq::Testing.inline! { subject } }
+ .to not_change { alert.issue.reload.state }
+ .and not_change(ResourceStateEvent, :count)
+ end
end
- context 'without issue' do
- it { expect { subject }.not_to change { alert.reload.issue } }
- it { expect { subject }.not_to change(ResourceStateEvent, :count) }
+ context 'without incident' do
+ specify do
+ expect(::IncidentManagement::CloseIncidentWorker).not_to receive(:perform_async)
+
+ subject
+ end
end
end
diff --git a/spec/support/shared_examples/services/alert_management_shared_examples.rb b/spec/support/shared_examples/services/alert_management_shared_examples.rb
index f644f1a1687..571cb7dc03d 100644
--- a/spec/support/shared_examples/services/alert_management_shared_examples.rb
+++ b/spec/support/shared_examples/services/alert_management_shared_examples.rb
@@ -68,14 +68,14 @@ RSpec.shared_examples 'processes one firing and one resolved prometheus alerts'
expect(Gitlab::AppLogger).not_to receive(:warn)
expect { subject }
- .to change(AlertManagement::Alert, :count).by(2)
- .and change(Note, :count).by(4)
+ .to change(AlertManagement::Alert, :count).by(1)
+ .and change(Note, :count).by(1)
expect(subject).to be_success
expect(subject.payload[:alerts]).to all(be_a_kind_of(AlertManagement::Alert))
- expect(subject.payload[:alerts].size).to eq(2)
+ expect(subject.payload[:alerts].size).to eq(1)
end
it_behaves_like 'processes incident issues'
- it_behaves_like 'sends alert notification emails', count: 2
+ it_behaves_like 'sends alert notification emails'
end
diff --git a/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb b/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb
index f18869fb380..3be59af6a37 100644
--- a/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb
@@ -1,10 +1,11 @@
# frozen_string_literal: true
RSpec.shared_context 'container registry auth service context' do
+ let_it_be(:rsa_key) { OpenSSL::PKey::RSA.generate(3072) }
+
let(:current_project) { nil }
let(:current_user) { nil }
let(:current_params) { {} }
- let(:rsa_key) { OpenSSL::PKey::RSA.generate(512) }
let(:payload) { JWT.decode(subject[:token], rsa_key, true, { algorithm: 'RS256' }).first }
let(:authentication_abilities) do
diff --git a/spec/support/shared_examples/services/feature_flags/client_shared_examples.rb b/spec/support/shared_examples/services/feature_flags/client_shared_examples.rb
new file mode 100644
index 00000000000..a62cffc0e1b
--- /dev/null
+++ b/spec/support/shared_examples/services/feature_flags/client_shared_examples.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+shared_examples_for 'update feature flag client' do
+ let!(:client) { create(:operations_feature_flags_client, project: project) }
+
+ it 'updates last feature flag updated at' do
+ freeze_time do
+ expect { subject }.to change { client.reload.last_feature_flag_updated_at }.from(nil).to(Time.current)
+ end
+ end
+end
+
+shared_examples_for 'does not update feature flag client' do
+ let!(:client) { create(:operations_feature_flags_client, project: project) }
+
+ it 'does not update last feature flag updated at' do
+ expect { subject }.not_to change { client.reload.last_feature_flag_updated_at }
+ end
+end