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

Monitoring parity test: better type comparisons #11720

Merged
merged 2 commits into from
Apr 9, 2019

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Apr 9, 2019

Motivated by failure in https://travis-ci.org/elastic/beats/jobs/517696747:

FAIL: Test that monitoring docs are the same, regardless of how they are shipped.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/go/src/github.com/elastic/beats/libbeat/tests/system/test_monitoring.py", line 151, in test_compare
    self.assert_same_structure(indirect_beats_stats_doc['beats_stats'], direct_beats_stats_doc['beats_stats'])
  File "/go/src/github.com/elastic/beats/libbeat/tests/system/test_monitoring.py", line 193, in assert_same_structure
    self.assert_same_structure(dict1_val, dict2_val)
  File "/go/src/github.com/elastic/beats/libbeat/tests/system/test_monitoring.py", line 193, in assert_same_structure
    self.assert_same_structure(dict1_val, dict2_val)
  File "/go/src/github.com/elastic/beats/libbeat/tests/system/test_monitoring.py", line 193, in assert_same_structure
    self.assert_same_structure(dict1_val, dict2_val)
  File "/go/src/github.com/elastic/beats/libbeat/tests/system/test_monitoring.py", line 191, in assert_same_structure
    self.assertEqual(type(dict1_val), type(dict2_val))
AssertionError: <type 'float'> != <type 'int'>

In the case of this failure, the type check is a bit too strict. We really only care that the two values are numbers. This PR makes the necessary changes.

Additionally, it also does a bit of cleanup by using isinstance instead of type to determine if a value is a dictionary. Apparently this is the more Pythonic way.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/stack-monitoring

@ycombinator ycombinator merged commit 1e6d160 into elastic:master Apr 9, 2019
@ycombinator ycombinator deleted the mon-parity-type-comp branch December 25, 2019 11:17
@ycombinator ycombinator removed the needs_backport PR is waiting to be backported to other branches. label Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants