Skip to content

Add unit testing for our revision controller helpers. - #1160

Merged
google-prow-robot merged 1 commit into
knative:masterfrom
mattmoor:revision-coverage
Jun 12, 2018
Merged

google-prow-robot merged 1 commit into
knative:masterfrom
mattmoor:revision-coverage

Conversation

@mattmoor

Copy link
Copy Markdown
Contributor

This moves a bunch of small standalone helper functions into a separate file in our revision controller package and adds unit testing of each of them outside of the context of the controller itself.

Progress toward: #1150

@google-prow-robot google-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 12, 2018
@knative-metrics-robot

Copy link
Copy Markdown

The following is the coverage report on pkg/. Say /test pull-knative-serving-go-coverage to run the coverage report again

File Old Coverage New Coverage Delta
pkg/controller/revision/revision.go 73.6% 74.8% 1.2

*TestCoverage feature is being tested, do not rely on any info here yet

@mattmoor

Copy link
Copy Markdown
Contributor Author

FYI, since #1161 means you can't see helpers.go, the coverage is 100% when measured locally.

return nil
}

func getIsServiceReady(e *corev1.Endpoints) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't love this name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

copy/paste, so punting as out-of-scope.

if condCount == 0 {
return r.CreationTimestamp.Time
}
return r.Status.Conditions[condCount-1].LastTransitionTime.Time

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are we guaranteed that conditions always have LastTransitionTime?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is not a pointer, so this is safe.

Comment thread pkg/controller/revision/helpers.go Outdated
}

func getDeploymentProgressCondition(deployment *appsv1.Deployment) *appsv1.DeploymentCondition {
//as per https://kubernetes.io/docs/concepts/workloads/controllers/deployment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: add space after //

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread pkg/controller/revision/helpers.go Outdated
continue
}
// with Type Progressing and Reason Timeout
// TODO (arvtiwar): hard coding "ProgressDeadlineExceeded" to avoid import kubernetes/kubernetes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: no space after TODO

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

return r.Status.Conditions[condCount-1].LastTransitionTime.Time
}

func getDeploymentProgressCondition(deployment *appsv1.Deployment) *appsv1.DeploymentCondition {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This name seems more general than the implementation, which ignores anything without the reason "ProgressDeadlineExceeded".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I share your sentiment. I'm pretty sure I had this feedback on the original PR as well, and somehow it got dropped on the floor :(

I'd rather not scope creep this PR as this is copy/paste, opened: #1168

}

// TODO(mattmoor): This should be a helper on Build (upstream)
func getBuildDoneCondition(build *buildv1alpha1.Build) *buildv1alpha1.BuildCondition {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't understand why it is correct to just return the first not-Unknown condition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Build doesn't fully adhere to the errors.md guidelines yet, so it could fail with either BuildInvalid or BuildSucceeded. Eventually the former will become webhook validation, and the latter will be the only condition we should see.

@mattmoor
mattmoor force-pushed the revision-coverage branch from cdc06d4 to 235a932 Compare June 12, 2018 17:46
@knative-metrics-robot

Copy link
Copy Markdown

The following is the coverage report on pkg/. Say /test pull-knative-serving-go-coverage to run the coverage report again

File Old Coverage New Coverage Delta
pkg/controller/revision/revision.go 73.6% 74.8% 1.2

*TestCoverage feature is being tested, do not rely on any info here yet

This moves a bunch of small standalone helper functions into a separate file in our revision controller package and adds unit testing of each of them outside of the context of the controller itself.

Progress toward: knative/serving#1150
@mattmoor
mattmoor force-pushed the revision-coverage branch from 235a932 to 9e9b8a0 Compare June 12, 2018 17:50
@knative-metrics-robot

Copy link
Copy Markdown

The following is the coverage report on pkg/. Say /test pull-knative-serving-go-coverage to run the coverage report again

File Old Coverage New Coverage Delta
pkg/controller/revision/revision.go 73.1% 74.3% 1.2

*TestCoverage feature is being tested, do not rely on any info here yet

@jonjohnsonjr

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 12, 2018
@google-prow-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jonjohnsonjr, mattmoor

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

The pull request process is described here

Details 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

@google-prow-robot
google-prow-robot merged commit fda1e33 into knative:master Jun 12, 2018
@steuhs

steuhs commented Jun 19, 2018

Copy link
Copy Markdown
Contributor

/test pull-knative-serving-go-coverage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants