test: disabling telemetry for all tests - #12573
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
julian-risch
left a comment
There was a problem hiding this comment.
Let's not send events for tests. We're paying by number of events. There are no insights for us in telemetry events coming from tests, right?
nope |
julian-risch
left a comment
There was a problem hiding this comment.
Let's move to test/conftest.py so that we cover also other places in tests where a pipeline is running, incl. test/core/super_component/ (SuperComponent runs an inner pipeline), test/tools/test_pipeline_tool.py, test/components/agents/test_agent.py, and most of test/components/retrievers/
A contributor who followed the documented opt-out gets a fresh telemetry user_id written to their home directory just by running the test suite. We should avoid that.
…p config out of $HOME Move the two autouse fixtures that were duplicated in test/conftest.py and e2e/conftest.py into haystack/testing/telemetry.py and import them from both. - Build the Telemetry instance once per session with CONFIG_PATH redirected to a tmp_path_factory directory, so running the suite no longer writes a fresh telemetry user_id into ~/.haystack/config.yaml - previously it did so even for contributors who opted out via HAYSTACK_TELEMETRY_ENABLED=false. - block_telemetry_network_calls now returns the posthog.capture mock; test_telemetry_tagging.py asserts on that mock instead of building its own, so the test fails if the network block is removed (it passed before). - Use inspect.unwrap() instead of .__wrapped__ so the module passes mypy, and rename the inner wrapper so it no longer shadows test_pipeline_running. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
julian-risch
left a comment
There was a problem hiding this comment.
Looks good to me now. I took the liberty to add a commit that builds the Telemetry instance once per session with CONFIG_PATH redirected to a tmp_path_factory directory. That way running the tests no longer writes a fresh telemetry user_id into ~/.haystack/config.yaml.
I also moved the two autouse fixtures because I realized they were now duplicated in test/conftest.py and e2e/conftest.py.
|
nice 👍🏽 |
Proposed Changes:
haystack/testing/telemetry.py: addedblock_telemetry_network_calls(andtag_pipeline_telemetry_as_test), imported as autouse fixtures intest/conftest.pyande2e/conftest.py, so they apply to every test in both suitesWhy
Pipeline.run().test/suite (6550 tests) ran with zero connection attempts recorded (mainmakes 24 attempts toeu.posthog.comfromtest/core/super_component+test/toolsalone).Why the
test_pipeline_run_reports_tagged_event_nametest?In practice
pipe.run()→ this callspipeline_running(self), which fixtures have swapped for a wrapper.telemetry.send_event(), which the fixtures forced to be a real Telemetry object.send_event calls posthog.capture(...)was replaced with a mock, so the chain ends there instead of hitting the network.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.