Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Fixes/msgpack default#783

Open
jgspiro wants to merge7 commits intoinfluxdata:master
base:master
Choose a base branch
Loading
fromjgspiro:fixes/msgpack_default

Conversation

jgspiro
Copy link
Contributor

@jgspirojgspiro commentedFeb 4, 2020
edited
Loading

msgpack issue

I identified an issue with the move to the default use ofmsgpack, so added this pull request to revert to the old behaviour, and optionally enable msgpack by settinguse_msgpack=True in theinit function of the client.

The testtest_write_points_mixed_type fails on purpose now because of a difference between the json and msgpack result returned by the server. The question is : is moving to msgpack going to be a breaking change? If so, I propose to merge this pull request (after fixing the test) and let users manually upgrade to msgpack based parsing.

This pull request has a couple of other changes identified while getting to the bottom of the above issue.

Fixes

  • raise proper exception when send_packet is called with invalid protocol (accessing uninitialzed member)
  • docstring : fix missing 'optional' flags for query() parameters
  • fix shadowed parameters response and filter
  • client_test : some tests using@raises(Exception) were succeedingfor the wrong reason
    (assertion in mock function): using self.assertRaises() instead.

Others

  • test all client functions with both msgpack enabled and disabled
  • add extra msgpack test starting from json with int, float and string values
  • retention policy creation : castreplication to int, adjust docs

Contributor checklist
  • Builds are passing --> waiting for feedback on msgpack issue
  • New tests have been added (for feature additions)

- raise proper exception when send_packet is called with invalid protocol- fix missing 'optional' flag for query() parameters- fix shadowed parameters response and filter- add extra msgpack test starting from json with int, float and string values- default to old behaviour for client (don't use msgpack by default - see failing test)
… is int.- retention policy creation : cast to int, adjust docs- client_test : some tests using@raises(Exception) were succeeding for the wrong reason(assertion in mock function): using self.assertRaises() instead.- test all functions with msgpack enabled and disabled (2 clients)
else:
self._headers = {
'Content-Type': 'application/json',
'Accept': 'text/plain'
Copy link
Contributor

Choose a reason for hiding this comment

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

Whytext/plain and notapplication/json ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

You would have to ask the original implementor - this is the way it was implemented before moving the default to msgpack.

@lovasoa
Copy link
Contributor

lovasoa commentedFeb 21, 2020
edited
Loading

I identified an issue with the move to the default use of msgpack

What is this issue you identified ?

Comment on lines 368 to 369
client_1 = InfluxDBClient('localhost', self.influxd_inst.http_port,
'root', '', database='db', use_msgpack=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this test should be added. There is a bug in influxdb (influxdata/influxdb#8707) that causes the JSON response to be parsed as the wrong datatype.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Like I said in the description :

The test test_write_points_mixed_type fails on purpose now because of a difference between the json and msgpack result returned by the server.

I can remove the defaulting to json and just make sure all tests run with both json and msgpack client.

I think users would want to be made aware of the consequences of defaulting to msgpack.

Copy link
Contributor

Choose a reason for hiding this comment

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

The consequences you are talking about is a bug that is now fixed with floats being misinterpreted as integers. I agree with you that this bugfix should be mentioned is the change log.

In any case, you don't want to havetest_write_points_mixed_type run with the json client, because it fails due to a bug in influxdb, not in this library.

'time': '2009-11-10T23:02:00Z',
"host": "server01",
"region": "us-west"},
{'value': 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

The fact that influxdb returns 1 instead of 1.0 here is a bug. I don't think you should assert that the bug is present. A future version of influxdb could fix that bug, and you wouldn't want the tests too break then. I think you should just remove this assertion.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

The issue you mentioned was closed without a fix, so I doubt this will change soon. It is a result of the default json marshaling in GoLang (they could probably work around it by customizing).

In contrast to you I believe it would be a good thing that the test would fail if the expected result would suddenly change (since the influx versions used to test are pinned it should not).

Copy link
Contributor

Choose a reason for hiding this comment

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

it would be a good thing that the test would fail if the expected result would suddenly change

Yes, but the expected result in this case is1.0, not1, since the database contains a float. The problem is that the library does not return the expected result. I don't think this buggy behavior should be enforced by a test.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Both are the sameNumber in JSON, which is the reason the issue was closed in InfluxDB.
Idid remove the JSON result from the test - altough I still think it should be there, because it is a way to document the current and future behaviour.

Copy link
Contributor

@lovasoalovasoaFeb 24, 2020
edited
Loading

Choose a reason for hiding this comment

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

Yes, both are the sameNumber in JSON, but that does not make this less of a bug 😛 Python has a different type for int and float, and so does InfluxDB.
And it is indeed a good idea to document the problematic behavior. Maybe you could add something to the doc comments ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I noticed I forgot to add the use_msgpack param docstring to InfluxDBClient doc, so I just pushed a commit documenting that paramter.

Is there a specific place you want me to describe the msgpack/Json difference?

Copy link
Contributor

Choose a reason for hiding this comment

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

The doc string of the influxdb client seems like a good place to me.
Also, I'm not sure it's clear: I do not have commit rights on this repository. None of the persons with commit rights are active on the repository anymore.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@lovasoalovasoalovasoa requested changes

@aviauaviauAwaiting requested review from aviauaviau is a code owner

@sebito91sebito91Awaiting requested review from sebito91

@xginn8xginn8Awaiting requested review from xginn8xginn8 is a code owner

Assignees

@sebito91sebito91

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@jgspiro@lovasoa@sebito91

[8]ページ先頭

©2009-2025 Movatter.jp