@cryptotaxi247 / kubo / commits / 15f723a15

fix: disable telemetry in test profile (#10931)

* Tests: disable telemetry in tests by default Disable the plugin in cli tests and sharness by default. Enable only in telemetry tests. There are cases when tests get stuck or get killed and leave daemons hanging around. We don't want to be getting telemetry from those. * sharness: attempt to fix * sharness: add missing --bool flag * fix(ci): add omitempty to Plugin.Config field The sharness problem is that when the telemetry plugin is configured initially with 'ipfs config --bool', it creates a structure without the 'Config: null' field, but when the config is copied and replaced, it expects the structure to be preserved. Adding omitempty ensures the Config field is omitted from JSON when nil, making the config structure consistent between initial creation and replacement operations. --------- Co-authored-by: Marcin Rataj <lidel@lidel.org>

Hector Sanjuan committed Aug 24, 2025 at 14:30 UTC 15f723a15e7c79f12857f52e652ffecb6d043e4d
4 files changed +22 -1
config/plugins.go
+1 -1
@@ -7,5 +7,5 @@ type Plugins struct {
7
8 type Plugin struct {
9 Disabled bool
10 - Config interface{}
10 + Config interface{} `json:",omitempty"`
11 }
test/cli/harness/node.go
+8
@@ -245,6 +245,14 @@ func (n *Node) Init(ipfsArgs ...string) *Node {
245 cfg.Swarm.DisableNatPortMap = true
246 cfg.Discovery.MDNS.Enabled = n.EnableMDNS
247 cfg.Routing.LoopbackAddressesOnLanDHT = config.True
248 + // Telemetry disabled by default in tests.
249 + cfg.Plugins = config.Plugins{
250 + Plugins: map[string]config.Plugin{
251 + "telemetry": config.Plugin{
252 + Disabled: true,
253 + },
254 + },
255 + }
256 })
257 return n
258 }
test/cli/telemetry_test.go
+5
@@ -25,6 +25,7 @@ func TestTelemetry(t *testing.T) {
25
26 // Create a new node
27 node := harness.NewT(t).NewNode().Init()
28 + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false)
29
30 // Set the opt-out environment variable
31 node.Runner.Env["IPFS_TELEMETRY"] = "off"
@@ -64,6 +65,7 @@ func TestTelemetry(t *testing.T) {
65
66 // Create a new node
67 node := harness.NewT(t).NewNode().Init()
68 + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false)
69
70 // Set opt-out via config
71 node.IPFS("config", "Plugins.Plugins.telemetry.Config.Mode", "off")
@@ -106,6 +108,7 @@ func TestTelemetry(t *testing.T) {
108
109 // Create a new node
110 node := harness.NewT(t).NewNode().Init()
111 + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false)
112
113 // Create a UUID file manually to simulate previous telemetry run
114 uuidPath := filepath.Join(node.Dir, "telemetry_uuid")
@@ -154,6 +157,7 @@ func TestTelemetry(t *testing.T) {
157
158 // Create a new node
159 node := harness.NewT(t).NewNode().Init()
160 + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false)
161
162 // Capture daemon output
163 stdout := &harness.Buffer{}
@@ -255,6 +259,7 @@ func TestTelemetry(t *testing.T) {
259
260 // Create a new node
261 node := harness.NewT(t).NewNode().Init()
262 + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false)
263
264 // Configure telemetry with a very short delay for testing
265 node.IPFS("config", "Plugins.Plugins.telemetry.Config.Delay", "100ms")
test/sharness/lib/test-lib.sh
+8
@@ -205,6 +205,10 @@ test_init_ipfs() {
205 ipfs init "${args[@]}" --profile=test > /dev/null
206 '
207
208 + test_expect_success "disable telemetry" '
209 + test_config_set --bool Plugins.Plugins.telemetry.Disabled "true"
210 + '
211 +
212 test_expect_success "prepare config -- mounting" '
213 mkdir mountdir ipfs ipns mfs &&
214 test_config_set Mounts.IPFS "$(pwd)/ipfs" &&
@@ -227,6 +231,10 @@ test_init_ipfs_measure() {
231 ipfs init "${args[@]}" --profile=test,flatfs-measure > /dev/null
232 '
233
234 + test_expect_success "disable telemetry" '
235 + test_config_set --bool Plugins.Plugins.telemetry.Disabled "true"
236 + '
237 +
238 test_expect_success "prepare config -- mounting" '
239 mkdir mountdir ipfs ipns &&
240 test_config_set Mounts.IPFS "$(pwd)/ipfs" &&