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

API events: fix parsing error #7088

Merged
merged 2 commits into from
Jul 27, 2020

Conversation

vrothberg
Copy link
Member

Fix an error where an absent "filters" parameter led to JSON parsing
errors.

Fixes: #7078
Signed-off-by: Valentin Rothberg rothberg@redhat.com

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vrothberg

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 27, 2020
@vrothberg
Copy link
Member Author

@jwhonce @mheon @rhatdan PTAL

Fix an error where an absent "filters" parameter led to JSON parsing
errors.

Fixes: containers#7078
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
@vrothberg
Copy link
Member Author

I am under the impression that the tests in test/api2/rest_api are not executed. They should have caught the regression but didn't and I couldn't find any wiring in the CI.

@vrothberg
Copy link
Member Author

Added a test the apiv2 test to prevent future regressions.

Add a simple test to exercise the events API without the "filters"
parameter.  Prevents regressing on containers#7078.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
# Simple events test (see #7078)
t GET "events?stream=false" 200
t GET "libpod/events?stream=false" 200

Copy link
Member

Choose a reason for hiding this comment

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

Friendly reminder to check actual results, not just status code. From a quick look at the returned JSON, might I suggest:

t GET "events?stream=false"        200 .Type=system .scope=local .time~[0-9]\\+
t GET "libpod/events?stream=false" 200 .Type=system .scope=local .time~[0-9]\\+

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for checking! It doesn't return any data here though. I really just want to exercise this specific code which we can't with bindings as the "filters" param is set unconditionally afaics.

Copy link
Member

Choose a reason for hiding this comment

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

PS last week I looked into adding tests for /events but gave up because of the follow nature - I didn't want tests to hang. If you have hints for how to write non-hanging tests (looks like ?stream=false is the magic token I was missing) I would like to look into that again. Thank you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, ?stream=false would be a good candidate for the tests here 👍

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't return any data here

Weird! As in: when you run the test I suggested, it fails?? That alarms me a little bit: I tried my tests root and rootless.

Copy link
Member Author

Choose a reason for hiding this comment

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

It now succeeds without ?filters=.... It failed before this change with a regression I introduced. The other tests always set "filters", so here I just wanted to make sure that the code path is executed.

@rhatdan
Copy link
Member

rhatdan commented Jul 27, 2020

LGTM

@TomSweeneyRedHat
Copy link
Member

LGTM

1 similar comment
@mheon
Copy link
Member

mheon commented Jul 27, 2020

LGTM

@mheon
Copy link
Member

mheon commented Jul 27, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 27, 2020
@openshift-merge-robot openshift-merge-robot merged commit 55a7faf into containers:master Jul 27, 2020
@vrothberg vrothberg deleted the fix-7078 branch July 27, 2020 13:19
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

events Rest API changes in v1.12
7 participants