blob: f2e658c3ae341278194fc4d71485fc5c9aa80737 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::StuckBuilds::DropScheduledService, feature_category: :runner_fleet do
let_it_be(:runner) { create :ci_runner }
let!(:job) { create :ci_build, :scheduled, scheduled_at: scheduled_at, runner: runner }
subject(:service) { described_class.new }
context 'when job is scheduled' do
context 'for more than an hour ago' do
let(:scheduled_at) { 2.hours.ago }
it_behaves_like 'job is dropped with failure reason', 'stale_schedule'
end
context 'for less than 1 hour ago' do
let(:scheduled_at) { 30.minutes.ago }
it_behaves_like 'job is unchanged'
end
end
%w(success skipped failed canceled running pending).each do |status|
context "when job is #{status}" do
before do
job.update!(status: status)
end
context 'and scheduled for more than an hour ago' do
let(:scheduled_at) { 2.hours.ago }
it_behaves_like 'job is unchanged'
end
context 'and scheduled for less than 1 hour ago' do
let(:scheduled_at) { 30.minutes.ago }
it_behaves_like 'job is unchanged'
end
end
end
context 'when there are no stale scheduled builds' do
let(:job) {}
it 'does not drop the stale scheduled build yet' do
expect { service.execute }.not_to raise_error
end
end
end
|