Skip to content

Commit

Permalink
Refactor Trial controller unit test (#1299)
Browse files Browse the repository at this point in the history
* Refactor Trial controller unit test
Move prometheus to util

* Change import
  • Loading branch information
andreyvelich authored Aug 11, 2020
1 parent cca0358 commit 77dd34e
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestReconcile(t *testing.T) {
configMap := newKatibConfigMapInstance()

// Test 1 - Regural suggestion run
// Create the suggestion and expect the service, deployment, pvc and pv is created
// Create the suggestion
g.Expect(c.Create(context.TODO(), instance)).NotTo(gomega.HaveOccurred())
// Create ConfigMap with suggestion data
g.Expect(c.Create(context.TODO(), configMap)).NotTo(gomega.HaveOccurred())
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller.v1beta1/trial/trial_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (

trialsv1beta1 "github.com/kubeflow/katib/pkg/apis/controller/trials/v1beta1"
"github.com/kubeflow/katib/pkg/controller.v1beta1/trial/managerclient"
trialutil "github.com/kubeflow/katib/pkg/controller.v1beta1/trial/util"
"github.com/kubeflow/katib/pkg/controller.v1beta1/util"
jobv1beta1 "github.com/kubeflow/katib/pkg/job/v1beta1"
)
Expand All @@ -69,7 +70,7 @@ func newReconciler(mgr manager.Manager) reconcile.Reconciler {
scheme: mgr.GetScheme(),
ManagerClient: managerclient.New(),
recorder: mgr.GetRecorder(ControllerName),
collector: NewTrialsCollector(mgr.GetCache(), metrics.Registry),
collector: trialutil.NewTrialsCollector(mgr.GetCache(), metrics.Registry),
}
r.updateStatusHandler = r.updateStatus
return r
Expand Down Expand Up @@ -139,7 +140,7 @@ type ReconcileTrial struct {
// updateStatusHandler is defined for test purpose.
updateStatusHandler updateStatusFunc
// collector is a wrapper for experiment metrics.
collector *TrialsCollector
collector *trialutil.TrialsCollector
}

// Reconcile reads that state of the cluster for a Trial object and makes changes based on the state read
Expand Down
Loading

0 comments on commit 77dd34e

Please sign in to comment.