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 e2e test for different service and revision label #766

Merged
merged 2 commits into from
Apr 14, 2020

Conversation

shashwathi
Copy link
Contributor

Description

Add e2e test for different service and revision label

Reference

Fixes #718

/assign @rhuss

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 30, 2020
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:

Description

Add e2e test for different service and revision label

Reference

Fixes #718

/assign @rhuss

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.

@knative-prow-robot knative-prow-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 30, 2020
Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

See comment.

Thanks for the contribution.

templateLabelsJsonpathFormat := "jsonpath={.spec.template.metadata.labels.%s}"

for k, v := range serviceLabels {
out := test.kn.Run("service", "describe", serviceName, "-o", fmt.Sprintf(metadataLabelsJsonpathFormat, k))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you not run the command once and verify output with all labels after?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback. I have updated the PR to do the same.

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 31, 2020
Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Looks good except there is an issue with the validation logic.

gotServiceLabels := service.ObjectMeta.GetLabels()
for k, v := range serviceLabels {
assert.Equal(t, gotServiceLabels[k], v)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

For a full check, you would also need to check that every label in gotServiceLabels has been verified (i.e. that the labels returned by the service are really all stored in gotServiceLabels).

Imagine that GetLabels returns an empty map (so no label has been created, which would be a bug). But your validation would still succeed.

Actually you should remove the entry in gotServiceLabels after each assert and then check after the loop that gotServiceLabels is indeed empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same btw for the loop above, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Imagine that GetLabels returns an empty map (so no label has been created, which would be a bug). But your validation would still succeed.

If GetLabels returns an empty map and serviceLabels has any label to be validated then validation logic will fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, you are right with GetLabel returning an empty map would lead to an error. But would happen if GetLabel returns more labels than expected ? Is this supposed to be an error is this something that is also expected ?

Of course this is a question for what to check. If you have full control over the service, I would expect that there are no extra labels being added to revisions and annotations (so would still suggest to check that all of the labels you get with GetLabel are really expected). In other words, I would check that both maps are equal not that the expected map is subset of the actual map.

Copy link
Contributor Author

@shashwathi shashwathi Apr 9, 2020

Choose a reason for hiding this comment

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

If you have full control over the service, I would expect that there are no extra labels being added to revisions and annotations

Thanks for explaining the pretext here. I see your argument now about checking for exact match. 👍

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 have updated the PR. Please review it at your convenience

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 4, 2020
@knative-prow-robot knative-prow-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 4, 2020
- Store results from one call and validate both revision and service labels
- Update var name for more better readability

Signed-off-by: Andrew Su <[email protected]>
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 9, 2020
Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Thanks !

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 9, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maximilien, rhuss, shashwathi

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

@andrew-su
Copy link
Member

/test pull-knative-client-integration-tests-latest-release

@rhuss
Copy link
Contributor

rhuss commented Apr 9, 2020

/retest

1 similar comment
@rhuss
Copy link
Contributor

rhuss commented Apr 14, 2020

/retest

@knative-prow-robot knative-prow-robot merged commit 88109bd into knative:master Apr 14, 2020
mgencur added a commit to openshift-knative/client that referenced this pull request Nov 21, 2022
…e#766)

* Introduce -reusenamespace test flag (knative#1383)

* Introduce -reusenamespace test flag

* allows for reusing test namespaces that were created in advance
(possibly by a cluster admininstrator)

* Fix gofmt

* Run tests as project admin (knative#1384)

* Create Broker explicitly rather than by labeling namespace

* creating explicity is allowed for users with project admin permissions
in the given project

* Use Role instead of ClusterRole to work with Sources

* this allows for running the tests as project admin users and don't
require cluster-admin permissions

* Separate SourceList test for cluster admin and regular user

* Instructions for running E2E as project admin

* Fix imports

* Define output as a new variable in source_list_crd_test

* Fix golint

* Reference an issue created for source list-types

* Use namespaced kubectl for sa,role,rolebinding in tests (knative#1396)
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. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add e2e tests and command line tests for "--labels" options
6 participants