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] Add start and end time to tag values endpoint #1601

Merged
merged 5 commits into from
May 4, 2019

Conversation

arnikola
Copy link
Collaborator

@arnikola arnikola commented May 2, 2019

Fixes an issue where the values endpoint, /label/{name}/values was not returning correct results. Issue was caused since the new optimized tag completion endpoint now considers query range params, and they were not being set correctly.

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

Fixes a user-facing bug

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

NONE

@@ -241,6 +241,9 @@ func ParseTagValuesToQuery(

nameBytes := []byte(name)
return &storage.CompleteTagsQuery{
// NB: necessarily spans the entire timerange for the index.
Start: time.Time{},
End: time.Now(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add test to catch this please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's just setting variables for a struct; since it uses this weird gorilla mux, it's not really plausible to generate a request capable of being read by it easily

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm but it wasn't working before? so we should probably have a test to make sure it doesn't break in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These weren't being set; won't really be a useful test

Copy link
Collaborator

Choose a reason for hiding this comment

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

hm maybe add an e2e test instead of a unit test, something emulating the behaviour that was failing for users but isn't now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

like ideally, that test fails without this PR and works with it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah refactored it a bit to make it nicer and added a couple of tests

@@ -25,6 +25,8 @@ import (
"net/http"
"time"

"github.com/m3db/m3/src/x/clock"

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Remove superfluous endline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do; it's odd that the linter didn't fail here

@codecov
Copy link

codecov bot commented May 2, 2019

Codecov Report

Merging #1601 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1601   +/-   ##
======================================
  Coverage    71.7%   71.7%           
======================================
  Files         953     953           
  Lines       78954   78954           
======================================
  Hits        56661   56661           
  Misses      18562   18562           
  Partials     3731    3731
Flag Coverage Δ
#aggregator 82.3% <0%> (ø) ⬆️
#cluster 85.7% <0%> (ø) ⬆️
#collector 63.7% <0%> (ø) ⬆️
#dbnode 79.4% <0%> (ø) ⬆️
#m3em 73.2% <0%> (ø) ⬆️
#m3ninx 73.9% <0%> (ø) ⬆️
#m3nsch 51.1% <0%> (ø) ⬆️
#metrics 17.6% <0%> (ø) ⬆️
#msg 74.7% <0%> (ø) ⬆️
#query 67.1% <0%> (ø) ⬆️
#x 86.8% <0%> (ø) ⬆️

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 1e486ff...89fa16f. Read the comment docs.

"github.com/stretchr/testify/require"
)

type tagValuesMatcher struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

more a FYI for future - can use google's compare method as a matcher for most things - it usually does the right thing: compare struct fields one at a time/use Equal() if it exists on a type/etc. There's a wrapper for it here: https://github.com/m3db/m3/blob/master/src/x/test/matcher.go

example usage

Copy link
Collaborator

@robskillington robskillington left a comment

Choose a reason for hiding this comment

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

LGTM

@robskillington robskillington merged commit ea7d870 into master May 4, 2019
@robskillington robskillington deleted the arnikola/fix-start-end-tag-values branch May 4, 2019 02:46
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.

4 participants