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

[query] Fix nil panic for error response for PromReadInstantHandler #1611

Merged
merged 4 commits into from
May 18, 2019

Conversation

robskillington
Copy link
Collaborator

What this PR does / why we need it:

Fixes panic when returning a query error from PromReadInstantHandler, also adds some tests.

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:

Fixes panic when returning a query error from PromReadInstantHandler

Does this PR require updating code package or user-facing documentation?:

NONE

false,
),
Handlers: testSetupHandlers{
Read: NewPromReadHandler(engine, tagOpts, limitsConfig,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: think it might read a little nicer if these handlers were defined before the return statement; line breaks would probably look a bit more readable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sg.

at1, value1, err := result.Data.Result[1].Value.parse()
require.NoError(t, err)

expected := mustPrettyJSON(t, fmt.Sprintf(`
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Think it may be a little cleaner to flip this around; have expected be a vectorResult and then just check equality between it and default json decoded result?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure yeah.

"github.com/m3db/m3/src/query/block"
"github.com/m3db/m3/src/query/test"
"github.com/m3db/m3/src/query/util/logging"
xtest "github.com/m3db/m3/src/x/test"
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: newline here

}

result, err := read(ctx, h.engine, h.tagOpts, w, params)
if err != nil {
logger.Error("unable to fetch data", zap.Error(err))
httperrors.ErrorWithReqInfo(w, r, http.StatusBadRequest, rErr)
httperrors.ErrorWithReqInfo(w, r, http.StatusInternalServerError, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤦‍♂

setup := newTestSetup()
promReadInstant := setup.Handlers.InstantRead

storageErr := fmt.Errorf("storage err")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: errors.New() instead of fmt.Errorf()

@codecov
Copy link

codecov bot commented May 7, 2019

Codecov Report

Merging #1611 into master will decrease coverage by 16%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1611      +/-   ##
=========================================
- Coverage      72%     56%   -16.1%     
=========================================
  Files         963     640     -323     
  Lines       80171   46993   -33178     
=========================================
- Hits        57794   26329   -31465     
+ Misses      18608   18569      -39     
+ Partials     3769    2095    -1674
Flag Coverage Δ
#aggregator 61.2% <ø> (-21.2%) ⬇️
#cluster 51.8% <ø> (-33.9%) ⬇️
#collector 47.9% <ø> (-15.8%) ⬇️
#dbnode 71.5% <ø> (-8.5%) ⬇️
#m3em 62% <ø> (-11.3%) ⬇️
#m3ninx 63% <ø> (-11.1%) ⬇️
#m3nsch 28.4% <ø> (-22.8%) ⬇️
#metrics 17.6% <ø> (ø) ⬆️
#msg 74.7% <ø> (ø) ⬆️
#query 62.5% <50%> (-4.7%) ⬇️
#x 58.9% <ø> (-27.6%) ⬇️

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 af35762...49a0d17. Read the comment docs.

@robskillington robskillington merged commit 1ec3b0b into master May 18, 2019
@robskillington robskillington deleted the r/fix-err-handler-prom-read-instant-handler branch May 18, 2019 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants