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

fix: Add test cases for validator and manifest generator #508

Merged
merged 13 commits into from
May 17, 2019

Conversation

gaocegege
Copy link
Member

@gaocegege gaocegege commented May 13, 2019

Signed-off-by: Ce Gao gaoce@caicloud.io

What this PR does / why we need it:

We do not have test for validator and metricscollector template/trial template. This PR is to add the test code about these three parts.

pkg/controller/v1alpha2/experiment/manifest coverage: 71.9% of statements
pkg/controller/v1alpha2/experiment/validator coverage: 73.9% of statements

What I do in this PR:

  • Make kubeclient an interface instead of a struct, and generate a mock implementation for it.
  • Make metricscollector template (manifest-util.go) and trial template (template-util.go) related logic an interface (producer interface), instead of several functions in util package, generate mock for it, write the unit test for it.
  • Make validator logic (webhook-util.go) in an interface, and write the unit test for it. Since it is only used in validation webhook, we do not mock it.

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 #

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:



This change is Reviewable

@gaocegege gaocegege changed the title WIP: Add test cases fix: Add test cases for validator and manifest producer May 14, 2019
@gaocegege
Copy link
Member Author

Blocked by #512

@gaocegege
Copy link
Member Author

/hold

@gaocegege
Copy link
Member Author

/hold cancel
/cc @johnugeorge @hougangliu

@gaocegege gaocegege force-pushed the test branch 2 times, most recently from 452f928 to 88ef343 Compare May 15, 2019 15:27
@gaocegege
Copy link
Member Author

/retest

@gaocegege
Copy link
Member Author

/cc @johnugeorge

@k8s-ci-robot k8s-ci-robot requested a review from johnugeorge May 16, 2019 02:40
@gaocegege gaocegege changed the title fix: Add test cases for validator and manifest producer fix: Add test cases for validator and manifest generator May 16, 2019
@gaocegege
Copy link
Member Author

/retest

gaocegege added 13 commits May 16, 2019 14:26
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
@gaocegege
Copy link
Member Author

PTAL @hougangliu @johnugeorge

}

// GetRunSpecWithHyperParameters get the specification for trial with hyperparameters.
func (g *DefaultGenerator) GetRunSpecWithHyperParameters(e *experimentsv1alpha2.Experiment, experiment, trial, namespace string, hps []*apiv1alpha2.ParameterAssignment) (string, error) {
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 namespace and experiment param can be removed since we can get them by e *experimentsv1alpha2.Experiment

@hougangliu
Copy link
Member

hougangliu commented May 16, 2019

@gaocegege I like this PR. LGTM, and only one mini comment

@gaocegege
Copy link
Member Author

/approve

@hougangliu I need your approval to merge the PR. I think your suggestion is reasonable. I will fix it in another PR. Thanks.

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gaocegege

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

The pull request process is described 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

@hougangliu
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot merged commit 04b0d91 into kubeflow:master May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants