Skip to content

Commit

Permalink
additional metric names should not include objective metric name (#1874)
Browse files Browse the repository at this point in the history
  • Loading branch information
henrysecond1 committed May 25, 2022
1 parent 502695a commit cc29580
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/webhook/v1beta1/experiment/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ func (g *DefaultValidator) validateObjective(obj *commonapiv1beta1.ObjectiveSpec
if obj.ObjectiveMetricName == "" {
return fmt.Errorf("no spec.objective.objectiveMetricName specified")
}
if contains(obj.AdditionalMetricNames, obj.ObjectiveMetricName) {
return fmt.Errorf("spec.objective.additionalMetricNames should not contain spec.objective.objectiveMetricName")
}
return nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/webhook/v1beta1/experiment/validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ func TestValidateExperiment(t *testing.T) {
Err: true,
testDescription: "Objective metric name is empty",
},
{
Instance: func() *experimentsv1beta1.Experiment {
i := newFakeInstance()
i.Spec.Objective.ObjectiveMetricName = "objective"
i.Spec.Objective.AdditionalMetricNames = []string{"objective", "objective-1"}
return i
}(),
Err: true,
testDescription: "additionalMetricNames should not contain objective metric name",
},
// Algorithm
{
Instance: func() *experimentsv1beta1.Experiment {
Expand Down

0 comments on commit cc29580

Please sign in to comment.