graphite-project / carbon

Carbon is one of the components of Graphite, and is responsible for receiving metrics over the network and writing them down to disk using a storage backend.
http://graphite.readthedocs.org/
Apache License 2.0
1.5k stars 490 forks source link

Trying to fix tests #881

Closed deniszh closed 4 years ago

deniszh commented 4 years ago

Not sure why we mocking 'carbon.state.instrumentation' here. It recently start to give following error:

Traceback (most recent call last):
  File "/Users/dzhdanov/git/carbon/.tox/py37/lib/python3.7/site-packages/twisted/trial/runner.py", line 531, in loadPackage
    module = modinfo.load()
  File "/Users/dzhdanov/git/carbon/.tox/py37/lib/python3.7/site-packages/twisted/python/modules.py", line 392, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File "/Users/dzhdanov/git/carbon/.tox/py37/lib/python3.7/site-packages/twisted/python/reflect.py", line 308, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/Users/dzhdanov/git/carbon/.tox/py37/lib/python3.7/site-packages/twisted/python/reflect.py", line 247, in _importAndCheckStack
    return __import__(importName)
  File "/Users/dzhdanov/git/carbon/lib/carbon/tests/test_client.py", line 91, in <module>
    @patch('carbon.state.instrumentation', Mock(spec=instrumentation))
  File "/Users/dzhdanov/git/carbon/.tox/py37/lib/python3.7/site-packages/mock/mock.py", line 1084, in __init__
    _spec_state, _new_name, _new_parent, **kwargs
  File "/Users/dzhdanov/git/carbon/.tox/py37/lib/python3.7/site-packages/mock/mock.py", line 439, in __init__
    self._mock_add_spec(spec, spec_set, _spec_as_instance, _eat_self)
  File "/Users/dzhdanov/git/carbon/.tox/py37/lib/python3.7/site-packages/mock/mock.py", line 494, in _mock_add_spec
    if iscoroutinefunction(getattr(spec, attr, None)):
  File "/Users/dzhdanov/git/carbon/.tox/py37/lib/python3.7/site-packages/mock/backports.py", line 34, in iscoroutinefunction
    getattr(obj, '_is_coroutine', None) is _is_coroutine
builtins.KeyError: '_is_coroutine'

Commenting out works fine. Did someone maybe know why that happening and how we can fix it properly? @piotr1212 @DanCech ?

deniszh commented 4 years ago

Test are green, despite I removed patching instrumentation during the test. Hmmm.

piotr1212 commented 4 years ago

Which test fails for you. They all work here (in tox)

piotr1212 commented 4 years ago

ah, sorry I see now they fail in travis

piotr1212 commented 4 years ago

'carbon.state.instrumentation' is not being used at all, removing it makes sense. I think someone wanted to test whether those counters were increased when a metric is received but never got around to implementing it. This code also originates from the megacarbon branch, you might find some more info in that git history.

deniszh commented 4 years ago

Cool, thanks for checking! Will merge it