Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional metric names should not include objective metric name #1874

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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