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

Add conformance test for valid service account name #4919

Merged
merged 2 commits into from
Jul 25, 2019

Conversation

shashwathi
Copy link
Contributor

Fixes #4647

Proposed Changes

Release Note


cc @steren

Question : I am validating the error msg to check if it failed for correct reason. I could not find any pattern for similar sort of assertion in other e2e tests so if anybody has objections to what I have done/ have better way to assert the error, please leave a comment. I appreciate it.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 24, 2019
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features labels Jul 24, 2019
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@shashwathi: 0 warnings.

In response to this:

Fixes #4647

Proposed Changes

Release Note


cc @steren

Question : I am validating the error msg to check if it failed for correct reason. I could not find any pattern for similar sort of assertion in other e2e tests so if anybody has objections to what I have done/ have better way to assert the error, please leave a comment. I appreciate it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@shashwathi
Copy link
Contributor Author

/assign @mattmoor

@@ -140,6 +140,13 @@ func WithRevisionTimeoutSeconds(revisionTimeoutSeconds int64) ServiceOption {
}
}

// WithServiceAccountName sets revision service account name
func WithServiceAccountName(sericeAccountName string) ServiceOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func WithServiceAccountName(sericeAccountName string) ServiceOption {
func WithServiceAccountName(serviceAccountName string) ServiceOption {

// WithServiceAccountName sets revision service account name
func WithServiceAccountName(sericeAccountName string) ServiceOption {
return func(service *v1beta1.Service) {
service.Spec.Template.Spec.ServiceAccountName = sericeAccountName
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
service.Spec.Template.Spec.ServiceAccountName = sericeAccountName
service.Spec.Template.Spec.ServiceAccountName = serviceAccountName

@shashwathi
Copy link
Contributor Author

/assign @vagababov

@shashwathi
Copy link
Contributor Author

@vagababov : Addressed your comments. Thanks for review

t.Fatal("Expected Service creation to fail")
}

if !strings.Contains(err.Error(), "serviceAccountName: spec.template.spec."+invalidServiceAccountName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a nit: but I think there should be a single error and we should be able to check against it?

if got, want := err.Error(), "serviceAccountName: spec.template.spec."+invalidServiceAccountName; got != want {
  t.Errorf("err = %s, want: %s, diff:\n%s", got, want, cmp.Diff(got, want)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case want is a substring of the error msg. Are you suggesting something like below?

if got, want := err.Error(), "serviceAccountName: spec.template.spec."+invalidServiceAccountName; !strings.Contains(got, want) {
  t.Errorf("got = %s, want: %s ", got, want)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Eh, if we can't check the whole error? Could you post it here? That would work 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.

I was hesitant to check for exact error because that seems like a very strict error check for conformance test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, conformance is about things conforming to something :-)
But it's fine. Substring should work.
Let me know when you push the if got, want... change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vagababov : I have updated the PR

@vagababov
Copy link
Contributor

/unassign @mattmoor
Matt's on vacation

Copy link
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 25, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: shashwathi, vagababov

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 25, 2019
@knative-prow-robot knative-prow-robot merged commit 54a0e7c into knative:master Jul 25, 2019
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. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate that service accounts have the right shape
5 participants