Коммит 56a7ef41 создал по автору Sanad Liaquat (Personal)'s avatar Sanad Liaquat (Personal)
Просмотр файлов

Add a case for when auto_disabling_web_hooks ff is not on

владелец ee101a3e
......@@ -63,7 +63,7 @@ module QA
end
expect { smocker.events(session).size }.to eventually_eq(2)
.within(max_duration: 30, sleep_interval: 2),
.within(max_duration: 30, sleep_interval: 2),
-> { "Should have 2 events, got: #{smocker.stringified_history(session)}" }
events = smocker.events(session)
......@@ -111,29 +111,45 @@ module QA
let(:hook_trigger_times) { 5 }
let(:disabled_after) { 4 }
before do
Runtime::Feature.enable(:auto_disabling_web_hooks)
end
context 'when auto_disabling_web_hooks feature flag is disabled' do
before do
Runtime::Feature.disable(:auto_disabling_web_hooks)
end
it 'webhook is not auto-disabled',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/389595' do
Resource::ProjectWebHook.setup(fail_mock, session: session, issues: true) do |webhook, smocker|
create_multiple_issues(hook_trigger_times, webhook.project)
expect { smocker.events(session).size }.to eventually_eq(hook_trigger_times)
.within(max_duration: 30, sleep_interval: 2),
-> { "Should have #{hook_trigger_times} events, got: #{smocker.events(session).size}" }
it 'hook is auto-disabled',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/389595' do
Resource::ProjectWebHook.setup(fail_mock, session: session, issues: true) do |webhook, smocker|
hook_trigger_times.times do
Resource::Issue.fabricate_via_api! do |issue_init|
issue_init.project = webhook.project
end
webhook.reload!
# using sleep to give rate limiter a chance to activate.
sleep 0.5
expect(webhook.alert_status).to eql('executable')
end
end
end
context 'and auto_disabling_web_hooks feature flag is enabled' do
before do
Runtime::Feature.enable(:auto_disabling_web_hooks)
end
expect { smocker.events(session).size }.to eventually_eq(disabled_after)
.within(max_duration: 30, sleep_interval: 2),
-> { "Should have #{disabled_after} events, got: #{smocker.events(session).size}" }
it 'webhook is auto-disabled',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/389595' do
Resource::ProjectWebHook.setup(fail_mock, session: session, issues: true) do |webhook, smocker|
create_multiple_issues(hook_trigger_times, webhook.project)
webhook.reload!
expect { smocker.events(session).size }.to eventually_eq(disabled_after)
.within(max_duration: 30, sleep_interval: 2),
-> { "Should have #{disabled_after} events, got: #{smocker.events(session).size}" }
expect(webhook.alert_status).to eql('disabled')
webhook.reload!
expect(webhook.alert_status).to eql('disabled')
end
end
end
end
......@@ -141,9 +157,20 @@ module QA
private
def create_multiple_issues(no_of_issues, project)
no_of_issues.times do
Resource::Issue.fabricate_via_api! do |issue_init|
issue_init.project = project
end
# using sleep to give rate limiter a chance to activate.
sleep 0.5
end
end
def expect_web_hook_single_event_success(webhook, smocker, type:)
expect { smocker.events(session).size }.to eventually_eq(1)
.within(max_duration: 30, sleep_interval: 2),
.within(max_duration: 30, sleep_interval: 2),
-> { "Should have 1 events, got: #{smocker.stringified_history(session)}" }
event = smocker.events(session).first
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать