-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
There was a problem hiding this 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
- Add conformance test as this is API spec related change
- For context Validate that service accounts have the right shape #4647 (comment)
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.
/assign @mattmoor |
pkg/testing/v1beta1/service.go
Outdated
@@ -140,6 +140,13 @@ func WithRevisionTimeoutSeconds(revisionTimeoutSeconds int64) ServiceOption { | |||
} | |||
} | |||
|
|||
// WithServiceAccountName sets revision service account name | |||
func WithServiceAccountName(sericeAccountName string) ServiceOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func WithServiceAccountName(sericeAccountName string) ServiceOption { | |
func WithServiceAccountName(serviceAccountName string) ServiceOption { |
pkg/testing/v1beta1/service.go
Outdated
// WithServiceAccountName sets revision service account name | ||
func WithServiceAccountName(sericeAccountName string) ServiceOption { | ||
return func(service *v1beta1.Service) { | ||
service.Spec.Template.Spec.ServiceAccountName = sericeAccountName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
service.Spec.Template.Spec.ServiceAccountName = sericeAccountName | |
service.Spec.Template.Spec.ServiceAccountName = serviceAccountName |
/assign @vagababov |
@vagababov : Addressed your comments. Thanks for review |
t.Fatal("Expected Service creation to fail") | ||
} | ||
|
||
if !strings.Contains(err.Error(), "serviceAccountName: spec.template.spec."+invalidServiceAccountName) { |
There was a problem hiding this comment.
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)
}
There was a problem hiding this comment.
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)
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
/unassign @mattmoor |
200f7d1
to
bc20c8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[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 |
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.