From 7b35216cfb361dbf40a7dcc8e32753f7b9f79dd9 Mon Sep 17 00:00:00 2001 From: sdairs Date: Mon, 24 Aug 2026 19:38:51 +0100 Subject: [PATCH 1/2] Disable telemetry in local integration scripts --- scripts/test-postgres-integration.sh | 1 + scripts/tests/test_script_telemetry.py | 49 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 scripts/tests/test_script_telemetry.py diff --git a/scripts/test-postgres-integration.sh b/scripts/test-postgres-integration.sh index ef0b6bf3..1354ecd0 100755 --- a/scripts/test-postgres-integration.sh +++ b/scripts/test-postgres-integration.sh @@ -13,6 +13,7 @@ # If no argument is given, falls back to $CLICKHOUSECTL or the debug build # at target/debug/clickhousectl relative to the repo root. set -u +export DO_NOT_TRACK=1 CTL="${1:-${CLICKHOUSECTL:-}}" if [[ -z "$CTL" ]]; then diff --git a/scripts/tests/test_script_telemetry.py b/scripts/tests/test_script_telemetry.py new file mode 100644 index 00000000..da48b740 --- /dev/null +++ b/scripts/tests/test_script_telemetry.py @@ -0,0 +1,49 @@ +import os +import subprocess +import tempfile +import unittest +from pathlib import Path + + +REPO_ROOT = Path(__file__).resolve().parents[2] +POSTGRES_INTEGRATION_SCRIPT = REPO_ROOT / "scripts" / "test-postgres-integration.sh" + + +class ScriptTelemetryTests(unittest.TestCase): + def test_postgres_integration_cli_processes_inherit_do_not_track(self): + with tempfile.TemporaryDirectory() as temp_dir: + temp = Path(temp_dir) + log = temp / "do-not-track.log" + cli = self._write_executable( + temp / "clickhousectl", + '#!/bin/sh\nprintf \'%s\\n\' "${DO_NOT_TRACK-unset}" >> "$DNT_LOG"\nexit 1\n', + ) + self._write_executable(temp / "docker", "#!/bin/sh\nexit 0\n") + self._write_executable(temp / "jq", "#!/bin/sh\nexit 0\n") + + env = os.environ.copy() + env["DO_NOT_TRACK"] = "0" + env["DNT_LOG"] = str(log) + env["PATH"] = f"{temp}{os.pathsep}{env['PATH']}" + result = subprocess.run( + ["bash", str(POSTGRES_INTEGRATION_SCRIPT), str(cli)], + env=env, + capture_output=True, + text=True, + timeout=10, + ) + + self.assertNotEqual(result.returncode, 0, "the fake CLI should fail the cases") + inherited_values = log.read_text().splitlines() + self.assertTrue(inherited_values, "the integration script did not invoke the CLI") + self.assertEqual(set(inherited_values), {"1"}) + + @staticmethod + def _write_executable(path: Path, contents: str) -> Path: + path.write_text(contents) + path.chmod(0o755) + return path + + +if __name__ == "__main__": + unittest.main() From c4ad7bd6926085a4df5a77ca5ca6a6cb27ca3797 Mon Sep 17 00:00:00 2001 From: sdairs Date: Tue, 25 Aug 2026 20:25:42 +0100 Subject: [PATCH 2/2] Remove disproportionate telemetry harness test --- scripts/tests/test_script_telemetry.py | 49 -------------------------- 1 file changed, 49 deletions(-) delete mode 100644 scripts/tests/test_script_telemetry.py diff --git a/scripts/tests/test_script_telemetry.py b/scripts/tests/test_script_telemetry.py deleted file mode 100644 index da48b740..00000000 --- a/scripts/tests/test_script_telemetry.py +++ /dev/null @@ -1,49 +0,0 @@ -import os -import subprocess -import tempfile -import unittest -from pathlib import Path - - -REPO_ROOT = Path(__file__).resolve().parents[2] -POSTGRES_INTEGRATION_SCRIPT = REPO_ROOT / "scripts" / "test-postgres-integration.sh" - - -class ScriptTelemetryTests(unittest.TestCase): - def test_postgres_integration_cli_processes_inherit_do_not_track(self): - with tempfile.TemporaryDirectory() as temp_dir: - temp = Path(temp_dir) - log = temp / "do-not-track.log" - cli = self._write_executable( - temp / "clickhousectl", - '#!/bin/sh\nprintf \'%s\\n\' "${DO_NOT_TRACK-unset}" >> "$DNT_LOG"\nexit 1\n', - ) - self._write_executable(temp / "docker", "#!/bin/sh\nexit 0\n") - self._write_executable(temp / "jq", "#!/bin/sh\nexit 0\n") - - env = os.environ.copy() - env["DO_NOT_TRACK"] = "0" - env["DNT_LOG"] = str(log) - env["PATH"] = f"{temp}{os.pathsep}{env['PATH']}" - result = subprocess.run( - ["bash", str(POSTGRES_INTEGRATION_SCRIPT), str(cli)], - env=env, - capture_output=True, - text=True, - timeout=10, - ) - - self.assertNotEqual(result.returncode, 0, "the fake CLI should fail the cases") - inherited_values = log.read_text().splitlines() - self.assertTrue(inherited_values, "the integration script did not invoke the CLI") - self.assertEqual(set(inherited_values), {"1"}) - - @staticmethod - def _write_executable(path: Path, contents: str) -> Path: - path.write_text(contents) - path.chmod(0o755) - return path - - -if __name__ == "__main__": - unittest.main()