@@ -43,7 +43,7 @@ func TestSyncScheduledSparkApplication_Allow(t *testing.T) {
43
43
Name : "test-app-allow" ,
44
44
},
45
45
Spec : v1beta2.ScheduledSparkApplicationSpec {
46
- Schedule : "@every 1m " ,
46
+ Schedule : "@every 10m " ,
47
47
ConcurrencyPolicy : v1beta2 .ConcurrencyAllow ,
48
48
},
49
49
}
@@ -61,8 +61,8 @@ func TestSyncScheduledSparkApplication_Allow(t *testing.T) {
61
61
// The first run should not have been triggered.
62
62
assert .True (t , app .Status .LastRunName == "" )
63
63
64
- // Advance the clock by 1 minute .
65
- clk .Step (1 * time .Minute )
64
+ // Advance the clock by 10 minutes .
65
+ clk .Step (10 * time .Minute )
66
66
if err := c .syncScheduledSparkApplication (key ); err != nil {
67
67
t .Fatal (err )
68
68
}
@@ -145,6 +145,34 @@ func TestSyncScheduledSparkApplication_Allow(t *testing.T) {
145
145
assert .Equal (t , 1 , len (app .Status .PastSuccessfulRunNames ))
146
146
run , _ = c .crdClient .SparkoperatorV1beta2 ().SparkApplications (app .Namespace ).Get (secondRunName , options )
147
147
assert .NotNil (t , run )
148
+
149
+ // Test the case where we update the schedule to be more frequent
150
+ app .Spec .Schedule = "@every 2m"
151
+ recentRunName := app .Status .LastRunName
152
+ recentRunTime := app .Status .LastRun .Time
153
+ app , _ = c .crdClient .SparkoperatorV1beta2 ().ScheduledSparkApplications (app .Namespace ).Update (app )
154
+ // sync our update
155
+ if err := c .syncScheduledSparkApplication (key ); err != nil {
156
+ t .Fatal (err )
157
+ }
158
+ // Advance the clock by 3 minutes.
159
+ clk .Step (3 * time .Minute )
160
+ if err := c .syncScheduledSparkApplication (key ); err != nil {
161
+ t .Fatal (err )
162
+ }
163
+ app , _ = c .crdClient .SparkoperatorV1beta2 ().ScheduledSparkApplications (app .Namespace ).Get (app .Name , options )
164
+ // A run should have been triggered
165
+ assert .NotEqual (t , recentRunName , app .Status .LastRunName )
166
+ assert .True (t , recentRunTime .Before (app .Status .LastRun .Time ))
167
+ run , _ = c .crdClient .SparkoperatorV1beta2 ().SparkApplications (app .Namespace ).Get (app .Status .LastRunName , options )
168
+ assert .NotNil (t , run )
169
+ // Simulate completion of the last run
170
+ run .Status .AppState .State = v1beta2 .CompletedState
171
+ c .crdClient .SparkoperatorV1beta2 ().SparkApplications (app .Namespace ).Update (run )
172
+ // This sync should not start any new run, but update Status.PastSuccessfulRunNames.
173
+ if err := c .syncScheduledSparkApplication (key ); err != nil {
174
+ t .Fatal (err )
175
+ }
148
176
}
149
177
150
178
func TestSyncScheduledSparkApplication_Forbid (t * testing.T ) {
0 commit comments