Skip to content

Commit

Permalink
Unit test for resuming Experiment in controller reconcilers (kubeflow…
Browse files Browse the repository at this point in the history
…#1281)

* Add unit test for Experiment and Suggestion controller reconcile

* Delete buildTrialMetaForRunSpec from controller

* Modify condition check

* Fix format

* Run mock for new version

* Refactor experiment reconcile test

* Remove comment
  • Loading branch information
andreyvelich authored Aug 3, 2020
1 parent 329b22e commit 9cf4544
Show file tree
Hide file tree
Showing 8 changed files with 554 additions and 269 deletions.
4 changes: 4 additions & 0 deletions pkg/apis/controller/suggestions/v1beta1/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func (suggestion *Suggestion) IsRunning() bool {
return hasCondition(suggestion, SuggestionRunning)
}

func (suggestion *Suggestion) IsDeploymentReady() bool {
return hasCondition(suggestion, SuggestionDeploymentReady)
}

func (suggestion *Suggestion) IsCompleted() bool {
return suggestion.IsSucceeded() || suggestion.IsFailed()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/onsi/gomega"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -82,21 +81,3 @@ func StartTestManager(mgr manager.Manager, g *gomega.GomegaWithT) (chan struct{}
}()
return stop, wg
}

// addForTestPurpose adds a new Controller to mgr with r as the reconcile.Reconciler.
func addForTestPurpose(mgr manager.Manager, r reconcile.Reconciler) error {
// Create a new controller
c, err := controller.New("test-experiment-controller", mgr, controller.Options{Reconciler: r})
if err != nil {
log.Error(err, "Failed to create experiment controller for test purpose.")
return err
}

if err = addWatch(mgr, c); err != nil {
log.Error(err, "Trial watch failed")
return err
}

log.Info("Experiment controller created")
return nil
}
Loading

0 comments on commit 9cf4544

Please sign in to comment.