diff --git a/config/plugins.go b/config/plugins.go index 08a1acb34f5..0c438cbd7df 100644 --- a/config/plugins.go +++ b/config/plugins.go @@ -7,5 +7,5 @@ type Plugins struct { type Plugin struct { Disabled bool - Config interface{} + Config interface{} `json:",omitempty"` } diff --git a/test/cli/harness/node.go b/test/cli/harness/node.go index 6403a2f1af6..0315e81dfc2 100644 --- a/test/cli/harness/node.go +++ b/test/cli/harness/node.go @@ -245,6 +245,14 @@ func (n *Node) Init(ipfsArgs ...string) *Node { cfg.Swarm.DisableNatPortMap = true cfg.Discovery.MDNS.Enabled = n.EnableMDNS cfg.Routing.LoopbackAddressesOnLanDHT = config.True + // Telemetry disabled by default in tests. + cfg.Plugins = config.Plugins{ + Plugins: map[string]config.Plugin{ + "telemetry": config.Plugin{ + Disabled: true, + }, + }, + } }) return n } diff --git a/test/cli/telemetry_test.go b/test/cli/telemetry_test.go index 455ea7df112..69b87e80da3 100644 --- a/test/cli/telemetry_test.go +++ b/test/cli/telemetry_test.go @@ -25,6 +25,7 @@ func TestTelemetry(t *testing.T) { // Create a new node node := harness.NewT(t).NewNode().Init() + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false) // Set the opt-out environment variable node.Runner.Env["IPFS_TELEMETRY"] = "off" @@ -64,6 +65,7 @@ func TestTelemetry(t *testing.T) { // Create a new node node := harness.NewT(t).NewNode().Init() + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false) // Set opt-out via config node.IPFS("config", "Plugins.Plugins.telemetry.Config.Mode", "off") @@ -106,6 +108,7 @@ func TestTelemetry(t *testing.T) { // Create a new node node := harness.NewT(t).NewNode().Init() + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false) // Create a UUID file manually to simulate previous telemetry run uuidPath := filepath.Join(node.Dir, "telemetry_uuid") @@ -154,6 +157,7 @@ func TestTelemetry(t *testing.T) { // Create a new node node := harness.NewT(t).NewNode().Init() + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false) // Capture daemon output stdout := &harness.Buffer{} @@ -255,6 +259,7 @@ func TestTelemetry(t *testing.T) { // Create a new node node := harness.NewT(t).NewNode().Init() + node.SetIPFSConfig("Plugins.Plugins.telemetry.Disabled", false) // Configure telemetry with a very short delay for testing node.IPFS("config", "Plugins.Plugins.telemetry.Config.Delay", "100ms") diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index e8030dcc4d0..413d0e92f78 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -205,6 +205,10 @@ test_init_ipfs() { ipfs init "${args[@]}" --profile=test > /dev/null ' + test_expect_success "disable telemetry" ' + test_config_set --bool Plugins.Plugins.telemetry.Disabled "true" + ' + test_expect_success "prepare config -- mounting" ' mkdir mountdir ipfs ipns mfs && test_config_set Mounts.IPFS "$(pwd)/ipfs" && @@ -227,6 +231,10 @@ test_init_ipfs_measure() { ipfs init "${args[@]}" --profile=test,flatfs-measure > /dev/null ' + test_expect_success "disable telemetry" ' + test_config_set --bool Plugins.Plugins.telemetry.Disabled "true" + ' + test_expect_success "prepare config -- mounting" ' mkdir mountdir ipfs ipns && test_config_set Mounts.IPFS "$(pwd)/ipfs" &&