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

Introduced error constants and replaced reflect with cmp #2289

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tariq-hasan
Copy link
Contributor

What this PR does / why we need it:

Following the suggestion #2281 (review) from @tenzen-y this code change provides a more thorough comparison of errors through the introduction of error constants and the replacement of replace.DeepEqual with cmp.Diff.

In addition some of the test cases in generator_test.go have been revised to allow for a more thorough comparison of error messages.

Finally cosmetic changes have been applied to some of the tests in order to match the style of the code in config_test.go that compares error constants.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2268

Checklist:

  • Docs included if any changes are user facing

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed only against experiments. So, could you refine other codes based on my comments?

Comment on lines 38 to 43
ErrConfigMapNotFound = errors.New("ConfigMap not found")
ErrConvertStringToUnstructuredFailed = errors.New("ConvertStringToUnstructured failed")
ErrConvertUnstructuredToStringFailed = errors.New("ConvertUnstructuredToString failed")
ErrParamNotFoundInParameterAssignment = errors.New("unable to find non-meta paramater from TrialParameters in ParameterAssignment")
ErrParamNotFoundInTrialParameters = errors.New("unable to find parameter from ParameterAssignment in TrialParameters")
ErrTemplatePathNotFound = errors.New("TemplatePath not found in ConfigMap")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ErrConfigMapNotFound = errors.New("ConfigMap not found")
ErrConvertStringToUnstructuredFailed = errors.New("ConvertStringToUnstructured failed")
ErrConvertUnstructuredToStringFailed = errors.New("ConvertUnstructuredToString failed")
ErrParamNotFoundInParameterAssignment = errors.New("unable to find non-meta paramater from TrialParameters in ParameterAssignment")
ErrParamNotFoundInTrialParameters = errors.New("unable to find parameter from ParameterAssignment in TrialParameters")
ErrTemplatePathNotFound = errors.New("TemplatePath not found in ConfigMap")
errConfigMapNotFound = errors.New("configMap not found")
errConvertStringToUnstructuredFailed = errors.New("failed to convert string to unstructured")
errConvertUnstructuredToStringFailed = errors.New("failed to convert unstructured to string")
errParamNotFoundInParameterAssignment = errors.New("unable to find non-meta parameter from TrialParameters in ParameterAssignment")
errParamNotFoundInTrialParameters = errors.New("unable to find parameter from ParameterAssignment in TrialParameters")
errTrialTemplateNotFound = errors.New("unable to find trial template in ConfigMap")

It seems that these errors do not need to be exposed, right?
Also, should we make errors more explainable?

Copy link
Contributor Author

@tariq-hasan tariq-hasan Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has been addressed in this commit.

@@ -245,18 +237,17 @@ spec:

expectedRunSpec, err := util.ConvertStringToUnstructured(expectedStr)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err != nil {
if diff := cmp.Diff(errConvertStringToUnstructuredFailed, err, cmpopts.EquateErrors()); len(diff) != 0 {

Should we evaluate if the error is appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expectedRunSpec is not evaluated using a function in generator.go so I am not sure if the errors defined in generator.go are applicable here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So, could we use this error? https://github.com/kubernetes/apimachinery/blob/e696ec55a32e2177cd5f2fe1ded91d9485aa5c64/pkg/util/yaml/decoder.go#L255

If it is not working well, could you define a dedicated error as well?

func ConvertStringToUnstructured(in string) (*unstructured.Unstructured, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need to define a dedicated error since the YAMLSyntaxError struct's field err cannot be exported and we therefore cannot initialize a YAMLSyntaxError struct in generator_test.go to define the expected error.

Copy link
Contributor Author

@tariq-hasan tariq-hasan Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to move both errConvertStringToUnstructuredFailed and errConvertUnstructuredToStringFailed to katib/pkg/controller.v1beta1/util/unstructured.go.

Please let me know your thoughts.

P.S.: We can also define errConvertObjectToUnstructured and use it in generator_test.go.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tariq-hasan I was missing any context here. Sorry for your confusion.
I meant like this.

	if diff := cmp.Diff(nil, err, cmpopts.EquateErrors()); len(diff) != 0 {
		t.Errorf("ConvertStringToUnstructured failed (-want,+got):\n%s", diff)
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed the comment in this commit.

@@ -245,18 +237,17 @@ spec:

expectedRunSpec, err := util.ConvertStringToUnstructured(expectedStr)
if err != nil {
t.Errorf("ConvertStringToUnstructured failed: %v", err)
t.Errorf("%v: %v", ErrConvertStringToUnstructuredFailed, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Errorf("%v: %v", ErrConvertStringToUnstructuredFailed, err)
t.Errorf("Unexpected error from ConvertStringToUnstructured (-want,+got):\n%s", diff)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above comment applies here as well.

Comment on lines 634 to 635
reflect.DeepEqual(expected.Labels, actual.Labels) &&
reflect.DeepEqual(expected.Annotations, actual.Annotations) &&
cmp.Equal(expected.Labels, actual.Labels) &&
cmp.Equal(expected.Annotations, actual.Annotations) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that these changes are not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has been addressed in this commit.

@@ -578,8 +578,8 @@ func TestConvertTrialObservation(t *testing.T) {
}
for _, tc := range tcs {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for _, tc := range tcs {
for _, tc := range tcs {
t.Run(testDescription, func(T *t.testing){

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has been addressed in this commit.

if !reflect.DeepEqual(actualObservation, tc.expectedObservation) {
t.Errorf("Case: %v failed.\nExpected observation: %v \ngot: %v", tc.testDescription, tc.expectedObservation, actualObservation)
if diff := cmp.Diff(actualObservation, tc.expectedObservation); diff != "" {
t.Errorf("Case: %v failed. Diff (-want,+got):\n%s", tc.testDescription, diff)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Errorf("Case: %v failed. Diff (-want,+got):\n%s", tc.testDescription, diff)
t.Errorf("Unexpected observation (-want,+got):\n%s", diff)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has been addressed in this commit.

@@ -311,7 +311,7 @@ func toGoptunaParams(
}
ir := float64(p)
internalParams[name] = ir
// externalParams[name] = p is prohibited because of reflect.DeepEqual() will be false
// externalParams[name] = p is prohibited because of cmp.Diff() will not be empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not follow this. Could you clarify?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has been addressed in this commit.

if reflect.DeepEqual(ktrial.Params, trials[i].Params) {
if diff := cmp.Diff(ktrial.Params, trials[i].Params); diff == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has been addressed in this commit.

@tenzen-y
Copy link
Member

tenzen-y commented Apr 6, 2024

@tariq-hasan You should follow this guide to pass DCO check.

https://github.com/kubeflow/katib/pull/2289/checks?check_run_id=23472655010

@tariq-hasan tariq-hasan force-pushed the replace-reflect.DeepEqual-with-cmp.Diff branch 2 times, most recently from 4c6db3c to 4b174b6 Compare April 7, 2024 20:08
Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this update!
I left some comments.

@@ -86,7 +96,7 @@ func (g *DefaultGenerator) GetRunSpecWithHyperParameters(experiment *experiments
// Convert Trial template to unstructured
runSpec, err := util.ConvertStringToUnstructured(replacedTemplate)
if err != nil {
return nil, fmt.Errorf("ConvertStringToUnstructured failed: %v", err)
return nil, fmt.Errorf("%w: %s", errConvertStringToUnstructuredFailed, err.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, fmt.Errorf("%w: %s", errConvertStringToUnstructuredFailed, err.Error())
return nil, fmt.Errorf("%w: %w", errConvertStringToUnstructuredFailed, err)

Could you just wrap errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been fixed in this commit.

@@ -108,7 +118,7 @@ func (g *DefaultGenerator) applyParameters(experiment *experimentsv1beta1.Experi
if trialSpec == nil {
trialSpec, err = util.ConvertStringToUnstructured(trialTemplate)
if err != nil {
return "", fmt.Errorf("ConvertStringToUnstructured failed: %v", err)
return "", fmt.Errorf("%w: %s", errConvertStringToUnstructuredFailed, err.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "", fmt.Errorf("%w: %s", errConvertStringToUnstructuredFailed, err.Error())
return "", fmt.Errorf("%w: %w", errConvertStringToUnstructuredFailed, err)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@@ -194,20 +205,20 @@ func (g *DefaultGenerator) GetTrialTemplate(instance *experimentsv1beta1.Experim
if trialSource.TrialSpec != nil {
trialTemplateString, err = util.ConvertUnstructuredToString(trialSource.TrialSpec)
if err != nil {
return "", fmt.Errorf("ConvertUnstructuredToString failed: %v", err)
return "", fmt.Errorf("%w: %s", errConvertUnstructuredToStringFailed, err.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "", fmt.Errorf("%w: %s", errConvertUnstructuredToStringFailed, err.Error())
return "", fmt.Errorf("%w: %w", errConvertUnstructuredToStringFailed, err)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

}
} else {
configMapNS := trialSource.ConfigMap.ConfigMapNamespace
configMapName := trialSource.ConfigMap.ConfigMapName
templatePath := trialSource.ConfigMap.TemplatePath
configMap, err := g.client.GetConfigMap(configMapName, configMapNS)
if err != nil {
return "", fmt.Errorf("GetConfigMap failed: %v", err)
return "", fmt.Errorf("%w: %v", errConfigMapNotFound, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "", fmt.Errorf("%w: %v", errConfigMapNotFound, err)
return "", fmt.Errorf("%w: %w", errConfigMapNotFound, err)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@@ -245,18 +237,17 @@ spec:

expectedRunSpec, err := util.ConvertStringToUnstructured(expectedStr)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So, could we use this error? https://github.com/kubernetes/apimachinery/blob/e696ec55a32e2177cd5f2fe1ded91d9485aa5c64/pkg/util/yaml/decoder.go#L255

If it is not working well, could you define a dedicated error as well?

func ConvertStringToUnstructured(in string) (*unstructured.Unstructured, error) {

}
}
if err == nil && !equality.Semantic.DeepEqual(tc.Pod.Spec.Containers, tc.WantPod.Spec.Containers) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you apply the cmp approach here as well?

Copy link
Contributor Author

@tariq-hasan tariq-hasan Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Comment on lines 638 to 639
if err == nil && !equality.Semantic.DeepEqual(tc.Pod, tc.WantPod) {
t.Errorf("Unexpected error from mutateMetricsCollectorVolume, expected pod: %v, got: %v", tc.WantPod, tc.Pod)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you apply the cmp approach here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

},
}

for _, tc := range testCases {
for _, tc := range cases {
collectorKind := getSidecarContainerName(tc.CollectorKind)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
collectorKind := getSidecarContainerName(tc.CollectorKind)
t.Run(...
collectorKind := getSidecarContainerName(tc.CollectorKind)

Could we use the t.Run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

},
}

for _, tc := range testCases {
for name, tc := range cases {
isPrimary := isPrimaryPod(tc.podLabels, tc.primaryPodLabels)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isPrimary := isPrimaryPod(tc.podLabels, tc.primaryPodLabels)
t.Run(...
isPrimary := isPrimaryPod(tc.podLabels, tc.primaryPodLabels)

Could we use the t.Run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

},
}

for _, tc := range testCases {
for _, tc := range cases {
mutatePodMetadata(tc.pod, tc.trial)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mutatePodMetadata(tc.pod, tc.trial)
t.Run(...
mutatePodMetadata(tc.pod, tc.trial)

ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tariq-hasan Thank you for this update!
Otherwise lgtm.
I left a comment for one suggestion.

@@ -245,18 +237,17 @@ spec:

expectedRunSpec, err := util.ConvertStringToUnstructured(expectedStr)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tariq-hasan I was missing any context here. Sorry for your confusion.
I meant like this.

	if diff := cmp.Diff(nil, err, cmpopts.EquateErrors()); len(diff) != 0 {
		t.Errorf("ConvertStringToUnstructured failed (-want,+got):\n%s", diff)
	}

Comment on lines 92 to 93
Instance *experimentsv1beta1.Experiment
ParameterAssignments []commonapiv1beta1.ParameterAssignment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Instance *experimentsv1beta1.Experiment
ParameterAssignments []commonapiv1beta1.ParameterAssignment
instance *experimentsv1beta1.Experiment
parameterAssignments []commonapiv1beta1.ParameterAssignment

I found these fields are exported. We should not export test fields at all points.
But this is irrelevant to this PR. So, could you open dedicated PR so that we can avoid to export test fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can open a separate PR once this one is merged.

@tenzen-y
Copy link
Member

@tariq-hasan LGTM, but the latest commit seems to violate DCO.

@tariq-hasan tariq-hasan force-pushed the replace-reflect.DeepEqual-with-cmp.Diff branch from e8afe14 to ce09054 Compare April 16, 2024 05:13
@tariq-hasan
Copy link
Contributor Author

@tariq-hasan LGTM, but the latest commit seems to violate DCO.

I addressed the issue. I am wondering if I should squash the commits given that the changes are final now.

@tenzen-y
Copy link
Member

@tariq-hasan LGTM, but the latest commit seems to violate DCO.

I addressed the issue. I am wondering if I should squash the commits given that the changes are final now.

The prow automatically squash commits into one. So, I'm ok with either way.

@tariq-hasan
Copy link
Contributor Author

Makes sense.

After reviewing the PR I find that these are the final set of changes

  • introduce error constants
  • replace reflect with cmp for error comparison
  • define test cases as maps instead of slices
  • rewrote test cases for TestGetRunSpecWithHP

I was thinking if each of these should ideally be its own commit so that we maintain a clear separation of concerns.

@tenzen-y
Copy link
Member

Makes sense.

After reviewing the PR I find that these are the final set of changes

  • introduce error constants
  • replace reflect with cmp for error comparison
  • define test cases as maps instead of slices
  • rewrote test cases for TestGetRunSpecWithHP

I was thinking if each of these should ideally be its own commit so that we maintain a clear separation of concerns.

I think that those sets depend on each. So, those should be included in a single PR.

Note that: We have no way to select the merge method merge. The prow enforces the squash method.

@tariq-hasan
Copy link
Contributor Author

Makes sense.

@tenzen-y
Copy link
Member

@tenzen-y
Copy link
Member

@tariq-hasan Could you address this error: https://github.com/kubeflow/katib/actions/runs/8700291109/job/23861062475?pr=2289?

I guess that we could avoid those errors after you rebase this PR.

@tariq-hasan
Copy link
Contributor Author

Okay. I thought that these might have been flakiness issues as the CI workflow seems to pass and fail quite unpredictably for this test case.

I am rebasing the PR.

@tariq-hasan tariq-hasan force-pushed the replace-reflect.DeepEqual-with-cmp.Diff branch from ce09054 to 6d33aa5 Compare April 16, 2024 06:07
@tenzen-y
Copy link
Member

tenzen-y commented Apr 16, 2024

Okay. I thought that these might have been flakiness issues as the CI workflow seems to pass and fail quite unpredictably for this test case.

I am rebasing the PR.

No, actually these errors were brought to us by the kubernetes issue w/o supporting SSA for the fake client.
And, I addressed that issue recently in the previous katib PR.
So, rebasing should fix those errors.

@tariq-hasan
Copy link
Contributor Author

Got it.

@tenzen-y
Copy link
Member

@tariq-hasan Uhm, it seems that meaningful errors occur. Could you investigate them?

@tariq-hasan
Copy link
Contributor Author

I am working through them now.

@tenzen-y
Copy link
Member

I am working through them now.

Thank you!

@tariq-hasan
Copy link
Contributor Author

I did run into the issues here before.

image

image

The errors are not always reproducible however. I usually get these errors in the first one to three runs of make test on my local and then the errors disappear for subsequent runs.

If I remove the kube-apiserver and etcd processes from my local and run make test then I find that the errors sometimes reappear.

That said I now restarted my local and I am running make test ENVTEST_K8S_VERSION=1.27 (or 1.28 or 1.29) but I do not see the issues appearing.

In the few cases where I ran into the errors I did root-cause that the errors were due to the order of execution of this code with the order of execution for this code.

Not sure if you have any thoughts of what might be happening here.

@tariq-hasan tariq-hasan force-pushed the replace-reflect.DeepEqual-with-cmp.Diff branch from 6d33aa5 to 87a6abc Compare April 26, 2024 03:58
@tariq-hasan
Copy link
Contributor Author

tariq-hasan commented Apr 26, 2024

Please ignore my comments above.

The error was due to the order of test case execution in cases in TestGetRunSpecWithHPConfigMap.

I fixed the issue in this commit and rebased the PR.

I ran the Go tests in a duplicate branch and it looks good.

Comment on lines 315 to 320
testCaseNames := []string{
"Run with valid parameters",
"Invalid ConfigMap name",
"Invalid template path in ConfigMap name",
"Invalid trial spec in ConfigMap",
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tariq-hasan This indicates that these tests depend on the performing order. But we should not do so.
So, could you resolve the root cause instead of such a hack?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I am looking into the issue and will have it resolved.

@tenzen-y
Copy link
Member

@tariq-hasan I merged #2316. So could you rebase this PR?

@andreyvelich
Copy link
Member

Hi @tariq-hasan, are you still working on this PR ?

@tariq-hasan
Copy link
Contributor Author

tariq-hasan commented Jun 14, 2024

Hi @tariq-hasan, are you still working on this PR ?

Hi @andreyvelich I will try to complete it ASAP. Sorry about the delay.

@tariq-hasan tariq-hasan force-pushed the replace-reflect.DeepEqual-with-cmp.Diff branch from 87a6abc to 4bc3eb5 Compare June 25, 2024 00:22
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign gaocegege for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tariq-hasan tariq-hasan force-pushed the replace-reflect.DeepEqual-with-cmp.Diff branch 2 times, most recently from 2480ef5 to a578685 Compare June 25, 2024 00:26
@tariq-hasan
Copy link
Contributor Author

tariq-hasan commented Jun 25, 2024

@tariq-hasan I merged #2316. So could you rebase this PR?

I rebased the PR.

I am now working on fixing the error in generator_test.go.

As a side note, I had to revert the change in suggestionclient_test.go as comparison using cmp threw the following error:

panic: cannot handle unexported field at {*api_v1_beta1.Observation}.state:
        "github.com/kubeflow/katib/pkg/apis/manager/v1beta1".Observation
consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported [recovered]

@tariq-hasan tariq-hasan force-pushed the replace-reflect.DeepEqual-with-cmp.Diff branch 2 times, most recently from 03faf2b to fa2cfa2 Compare June 29, 2024 17:26
Signed-off-by: tariq-hasan <mmtariquehsn@gmail.com>
Signed-off-by: tariq-hasan <mmtariquehsn@gmail.com>
@tariq-hasan tariq-hasan force-pushed the replace-reflect.DeepEqual-with-cmp.Diff branch from fa2cfa2 to 4e1acc7 Compare June 29, 2024 17:30
@tariq-hasan
Copy link
Contributor Author

tariq-hasan commented Jun 29, 2024

I added this commit to tie up each mock method call with the execution of the associated test case.

Please let me know if you have any feedback and if this would fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace reflect.DeepEqual with cmp.Diff in tests
3 participants