Browse code

hack: disable go telemetry in integration tests

commit 081987b647b724b628f68bc68084341b3990d804 updated the Dockerfile
to disable go's telemetry in our dev / test-environment; as collecting
this data doesn't serve much purpose.

However, the configuration to disable telemetry is tied to the user's
home-directory (HOME); and disabling telemetry writs a config-file to the
user's home-directory (`~/.config/go/telemetry/mode`). While go provides
env-vars about the mode and location (`GOTELEMETRY` and `GOTELEMETRYDIR`),
those env-vars are read-only and cannot be used to either disable telemetry
or to set the location;

> Information about telemetry configuration is also available via read-only Go environment variables:
>
> go env GOTELEMETRY reports the telemetry mode.
> go env GOTELEMETRYDIR reports the directory holding telemetry configuration and data.

Some steps in our CI set up a different home-directory, which is not configured
to disable telemetry, which means that CI currently leaves behind a bunch of
files related to this;

make TEST_FILTER=TestPruneDontDeleteUsedDangling test-integration
tree -a bundles/test-integration/fake-HOME/
bundles/test-integration/fake-HOME/
└── .config
└── go
└── telemetry
├── local
│ ├── asm@go1.25.3-go1.25.3-linux-arm64-2025-10-21.v1.count
│ ├── compile@go1.25.3-go1.25.3-linux-arm64-2025-10-21.v1.count
│ ├── go@go1.25.3-go1.25.3-linux-arm64-2025-10-21.v1.count
│ ├── link@go1.25.3-go1.25.3-linux-arm64-2025-10-21.v1.count
│ ├── test2json@go1.25.3-go1.25.3-linux-arm64-2025-10-21.v1.count
│ ├── upload.token
│ └── weekends
└── upload

6 directories, 7 files

This patch disables go telemetry also for this home-directory to prevent
those files from being created, and to prevent go from producing the
telemetry.

With this patch, only the file to disable telemetry is produced:

make TEST_FILTER=TestPruneDontDeleteUsedDangling test-integration
tree -a bundles/test-integration/fake-HOME/
bundles/test-integration/fake-HOME/
└── .config
└── go
└── telemetry
└── mode

4 directories, 1 file

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/10/21 19:17:30
Showing 2 changed files
... ...
@@ -188,6 +188,13 @@ test_env() {
188 188
 	(
189 189
 		set -e
190 190
 		[ -n "$TESTDEBUG" ] && set -x
191
+
192
+		# Disable collecting local telemetry, as collected by Go and Delve;
193
+		#
194
+		# - https://github.com/go-delve/delve/blob/v1.24.1/CHANGELOG.md#1231-2024-09-23
195
+		# - https://go.dev/doc/telemetry#background
196
+		HOME="$ABS_DEST/fake-HOME" go telemetry off
197
+
191 198
 		env -i \
192 199
 			DEST="$ABS_DEST" \
193 200
 			DOCKER_API_VERSION="$DOCKER_API_VERSION" \
... ...
@@ -40,6 +40,13 @@ test_env() {
40 40
 	(
41 41
 		set -e +u
42 42
 		[ -n "$TESTDEBUG" ] && set -x
43
+
44
+		# Disable collecting local telemetry, as collected by Go and Delve;
45
+		#
46
+		# - https://github.com/go-delve/delve/blob/v1.24.1/CHANGELOG.md#1231-2024-09-23
47
+		# - https://go.dev/doc/telemetry#background
48
+		HOME="$ABS_DEST/fake-HOME" go telemetry off
49
+
43 50
 		env -i \
44 51
 			DOCKER_API_VERSION="$DOCKER_API_VERSION" \
45 52
 			DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \