@@ -43,7 +43,7 @@ import (
43
43
trialsv1beta1 "github.com/kubeflow/katib/pkg/apis/controller/trials/v1beta1"
44
44
"github.com/kubeflow/katib/pkg/controller.v1beta1/consts"
45
45
experimentUtil "github.com/kubeflow/katib/pkg/controller.v1beta1/experiment/util"
46
- util "github.com/kubeflow/katib/pkg/controller.v1beta1/util"
46
+ "github.com/kubeflow/katib/pkg/controller.v1beta1/util"
47
47
manifestmock "github.com/kubeflow/katib/pkg/mock/v1beta1/experiment/manifest"
48
48
suggestionmock "github.com/kubeflow/katib/pkg/mock/v1beta1/experiment/suggestion"
49
49
)
@@ -163,7 +163,7 @@ func TestReconcile(t *testing.T) {
163
163
164
164
mockCtrl2 := gomock .NewController (t )
165
165
defer mockCtrl2 .Finish ()
166
- mockGenerator := manifestmock .NewMockGenerator (mockCtrl )
166
+ mockGenerator := manifestmock .NewMockGenerator (mockCtrl2 )
167
167
168
168
// Setup the Manager and Controller. Wrap the Controller Reconcile function so it writes each request to a
169
169
// channel when it is finished.
@@ -217,7 +217,6 @@ func TestReconcile(t *testing.T) {
217
217
nil ).AnyTimes ()
218
218
219
219
suggestionRestartNo := newFakeSuggestion ()
220
-
221
220
mockSuggestion .EXPECT ().GetOrCreateSuggestion (gomock .Any (), gomock .Any ()).Return (
222
221
suggestionRestartNo , nil ).AnyTimes ()
223
222
@@ -304,10 +303,10 @@ func TestReconcile(t *testing.T) {
304
303
)
305
304
306
305
// Test 1 - Regural experiment run
307
- instance := newFakeInstance ()
308
306
309
307
// Create the suggestion with NeverResume
310
- g .Expect (c .Create (context .TODO (), suggestionRestartNo )).NotTo (gomega .HaveOccurred ())
308
+ suggestionInstance := newFakeSuggestion ()
309
+ g .Expect (c .Create (context .TODO (), suggestionInstance )).NotTo (gomega .HaveOccurred ())
311
310
// Manually update suggestion's status with 3 suggestions
312
311
// Ones redundant trial is deleted, suggestion status must be updated
313
312
g .Eventually (func () error {
@@ -321,6 +320,7 @@ func TestReconcile(t *testing.T) {
321
320
}, timeout ).ShouldNot (gomega .HaveOccurred ())
322
321
323
322
// Create the experiment
323
+ instance := newFakeInstance ()
324
324
g .Expect (c .Create (context .TODO (), instance )).NotTo (gomega .HaveOccurred ())
325
325
326
326
// Expect that experiment status is running
@@ -382,7 +382,7 @@ func TestReconcile(t *testing.T) {
382
382
}, timeout ).Should (gomega .BeTrue ())
383
383
384
384
// Delete the suggestion
385
- g .Expect (c .Delete (context .TODO (), suggestionRestartNo )).NotTo (gomega .HaveOccurred ())
385
+ g .Expect (c .Delete (context .TODO (), suggestionInstance )).NotTo (gomega .HaveOccurred ())
386
386
387
387
// Expect that suggestion with ResumePolicy = NeverResume is deleted
388
388
g .Eventually (func () bool {
@@ -391,7 +391,9 @@ func TestReconcile(t *testing.T) {
391
391
}, timeout ).Should (gomega .BeTrue ())
392
392
393
393
// Create the suggestion with ResumePolicy = FromVolume
394
- g .Expect (c .Create (context .TODO (), suggestionRestartYes )).NotTo (gomega .HaveOccurred ())
394
+ suggestionInstance = newFakeSuggestion ()
395
+ suggestionInstance .Spec .ResumePolicy = experimentsv1beta1 .FromVolume
396
+ g .Expect (c .Create (context .TODO (), suggestionInstance )).NotTo (gomega .HaveOccurred ())
395
397
// Expect that suggestion is created
396
398
g .Eventually (func () bool {
397
399
return errors .IsNotFound (c .Get (context .TODO (),
@@ -437,7 +439,7 @@ func TestReconcile(t *testing.T) {
437
439
}, timeout ).Should (gomega .BeTrue ())
438
440
439
441
// Delete the suggestion
440
- g .Expect (c .Delete (context .TODO (), suggestionRestartYes )).NotTo (gomega .HaveOccurred ())
442
+ g .Expect (c .Delete (context .TODO (), suggestionInstance )).NotTo (gomega .HaveOccurred ())
441
443
442
444
// Expect that suggestion with ResumePolicy = FromVolume is deleted
443
445
g .Eventually (func () bool {
0 commit comments