Skip to content

Commit

Permalink
Clean up test utils (#1839)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Iwai <[email protected]>
  • Loading branch information
tenzen-y authored Mar 14, 2024
1 parent 391943c commit a96927d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
24 changes: 12 additions & 12 deletions pkg/util/testing/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type builderIndexer struct {
*fake.ClientBuilder
}

func (b *builderIndexer) IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error {
func (b *builderIndexer) IndexField(_ context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error {
b.ClientBuilder = b.ClientBuilder.WithIndex(obj, field, extractValue)
return nil
}
Expand Down Expand Up @@ -104,40 +104,40 @@ func SortEvents(ei, ej EventRecord) bool {
return false
}

func (tr *EventRecorder) Event(object runtime.Object, eventtype, reason, message string) {
tr.Eventf(object, eventtype, reason, message)
func (tr *EventRecorder) Event(object runtime.Object, eventType, reason, message string) {
tr.Eventf(object, eventType, reason, message)
}

func (tr *EventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{}) {
tr.AnnotatedEventf(object, nil, eventtype, reason, messageFmt, args...)
func (tr *EventRecorder) Eventf(object runtime.Object, eventType, reason, messageFmt string, args ...interface{}) {
tr.AnnotatedEventf(object, nil, eventType, reason, messageFmt, args...)
}

func (tr *EventRecorder) AnnotatedEventf(targetObject runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{}) {
func (tr *EventRecorder) AnnotatedEventf(targetObject runtime.Object, _ map[string]string, eventType, reason, messageFmt string, args ...interface{}) {
tr.lock.Lock()
defer tr.lock.Unlock()
key := types.NamespacedName{}
if cobj, iscobj := targetObject.(client.Object); iscobj {
key = client.ObjectKeyFromObject(cobj)
if cObj, isCObj := targetObject.(client.Object); isCObj {
key = client.ObjectKeyFromObject(cObj)
}
tr.RecordedEvents = append(tr.RecordedEvents, EventRecord{
Key: key,
EventType: eventtype,
EventType: eventType,
Reason: reason,
Message: fmt.Sprintf(messageFmt, args...),
})
}

type ssaPatchAsStretegicMerge struct {
type ssaPatchAsStrategicMerge struct {
client.Patch
}

func (*ssaPatchAsStretegicMerge) Type() types.PatchType {
func (*ssaPatchAsStrategicMerge) Type() types.PatchType {
return types.StrategicMergePatchType
}

func wrapSSAPatch(patch client.Patch) client.Patch {
if patch.Type() == types.ApplyPatchType {
return &ssaPatchAsStretegicMerge{Patch: patch}
return &ssaPatchAsStrategicMerge{Patch: patch}
}
return patch
}
Expand Down
9 changes: 0 additions & 9 deletions test/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,6 @@ func ExpectCQResourceBorrowingQuota(cq *kueue.ClusterQueue, flavor, resource str
}, Timeout, Interval).Should(gomega.Equal(v))
}

func ExpectCQResourceLendingQuota(cq *kueue.ClusterQueue, flavor, resource string, v float64) {
metric := metrics.ClusterQueueResourceLendingLimit.WithLabelValues(cq.Spec.Cohort, cq.Name, flavor, resource)
gomega.EventuallyWithOffset(1, func() float64 {
v, err := testutil.GetGaugeMetricValue(metric)
gomega.Expect(err).ToNot(gomega.HaveOccurred())
return v
}, Timeout, Interval).Should(gomega.Equal(v))
}

func ExpectCQResourceReservations(cq *kueue.ClusterQueue, flavor, resource string, v float64) {
metric := metrics.ClusterQueueResourceReservations.WithLabelValues(cq.Spec.Cohort, cq.Name, flavor, resource)
gomega.EventuallyWithOffset(1, func() float64 {
Expand Down

0 comments on commit a96927d

Please sign in to comment.