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 CheckEndpointState method to SpoofingClient #2166

Merged

Conversation

pseudorandoom
Copy link
Contributor

@pseudorandoom pseudorandoom commented Jun 23, 2021

Changes

  • New method CheckEndpointState just for checking an endpoint's response

/kind api-change

Part of knative/serving#1178

Release Note

No changes to the existing WaitForEndpointState method, these changes don't fix knative/serving#1178 but help change the way some assertions work in serving e2e tests

@knative-prow-robot knative-prow-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API area/test-and-release size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 23, 2021
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Jun 23, 2021
@codecov
Copy link

codecov bot commented Jun 23, 2021

Codecov Report

Merging #2166 (3831cd6) into main (51cfaab) will increase coverage by 0.46%.
The diff coverage is 73.46%.

❗ Current head 3831cd6 differs from pull request most recent head 5356437. Consider uploading reports for the commit 5356437 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2166      +/-   ##
==========================================
+ Coverage   66.05%   66.51%   +0.46%     
==========================================
  Files         224      224              
  Lines        9426     9472      +46     
==========================================
+ Hits         6226     6300      +74     
+ Misses       2920     2881      -39     
- Partials      280      291      +11     
Impacted Files Coverage Δ
test/request.go 0.00% <0.00%> (ø)
test/spoof/spoof.go 60.31% <87.80%> (+60.31%) ⬆️
test/gcs/mock/mock.go 90.32% <0.00%> (-1.08%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51cfaab...5356437. Read the comment docs.

test/request.go Outdated
@@ -84,6 +84,8 @@ func EventuallyMatchesBody(expected string) spoof.ResponseChecker {
}
}

type endpointStateCallable = func(ctx context.Context, u *url.URL, inState spoof.ResponseChecker, desc string, r ...spoof.RequestOption) (*spoof.Response, error)
Copy link
Member

Choose a reason for hiding this comment

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

do we think there are ever likely to be more than two possible things "implementing" this? If not I'd be very tempted to just pass down a wait bool parameter here

@dprotaso
Copy link
Member

/retest

pseudorandoom and others added 3 commits June 29, 2021 11:28
Signed-off-by: Fabian Lopez <lfabian@vmware.com>
Co-authored-by: Sameer Vohra <vsameer@vmware.com>
…checks

Signed-off-by: Fabian Lopez <lfabian@vmware.com>
Signed-off-by: Fabian Lopez <lfabian@vmware.com>
@pseudorandoom pseudorandoom force-pushed the add-check-endpoint-state-method branch from 31c7c87 to eeafd0d Compare June 30, 2021 18:29
test/request.go Outdated
return waitForEndpointStateWithTimeout(ctx, kubeClient, logf, url, inState, desc, resolvable, timeout, true, opts)
}

func waitForEndpointStateWithTimeout(
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit confusing to call this waitForEndpointStateWithTimeout but there's a wait argument that makes this check.

I think we should just change this to only create the spoof client and then in the respective Wait Check methods call client.Wait/Check

Comment on lines 319 to 322
if ok {
sc.logZipkinTrace(resp)
return resp, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

The be consistent with Poll we should log if resp != nil - thus you'll want to do the err check after this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's very similar to the Poll method but I think resp is guaranteed to be non nil at this point so I just moved the log line out of the if ok check. Let me know if that's fine

Comment on lines 126 to 136
sc, err := New(
context.TODO(),
fKlient,
t.Logf,
"some.svc.knative.dev",

false,
"host",
1,
1,
)
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 it'll be simpler to setup the tests if you just construct a SpoofingClient struct directly vs. calling the New constructor

wantCalls: 1,
}}
for _, tt := range tests {
_, fKlient := fake.With(context.TODO(), ingress)
Copy link
Member

Choose a reason for hiding this comment

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

I would just create the k8s fake client directly vs pulling in the injection library

Signed-off-by: Fabian Lopez <lfabian@vmware.com>
@dprotaso
Copy link
Member

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, shinigambit

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 13, 2021
@knative-prow-robot knative-prow-robot merged commit 459d317 into knative:main Jul 13, 2021
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 cla: yes Indicates the PR's author has signed the CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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.

4 participants