-
Notifications
You must be signed in to change notification settings - Fork 105
Add unit test to test various special characters in tag values #1217
Conversation
wouldn't it be simpler and more robust to iterate the ascii table (or a subrange of it) ? |
Yeah, I guess that would work. I wanted to test some UTF-8 as well. But i can replace the ASCII chars with some loop that just iterates over the table. |
This is now iterating over the ascii table and tests all characters except those on a short blacklist: 9d93f6d |
idx/memory/tag_query_test.go
Outdated
|
||
blackList := []int{ | ||
59, // ; not allowed in values | ||
126, // ~ can't query values starting with ~ because =~ looks like a regular expression query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't you just specify the actual characters like ':'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that works too: 42c75fa
for i := 0; i < 128; i++ { | ||
firstChar := i | ||
for isBlacklisted(rune(firstChar)) { | ||
firstChar = (firstChar + 1) % 128 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like % 128
is redundant given the check below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change to for isBlacklisted(rune(firstChar)) && i < 128 {
data := []testCase{} | ||
|
||
for i := 0; i < 6; i++ { | ||
data = append(data, testCase{ids[i], 1, []string{}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of setting these very low lastUpdate values?
seems it has nothing to do with what is being tested, and i would emit this from the testCase types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, having all these predeclared id's complicates things needlessly. just generate them as you need them
I'm not sure how useful this PR is. It seems more useful to think about where special characters may be problematic and either test those or analyze and document them.
|
@replay what's the status of this? |
@Dieterbe Ok, in that case we can close this PR and I'll make another one with unit tests which test via the APIs and the MetricData input, instead of directly testing on the index interface. |
This is a regression test to ensure that we continue supporting special characters in the tag values
Related #1216
Note: Github does not display all of it correctly. For some of the values to be shown correctly it is necessary to
git fetch
the commit and look at it locally.