Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type Plugins struct {

type Plugin struct {
Disabled bool
Config interface{}
Config interface{} `json:",omitempty"`
}
8 changes: 8 additions & 0 deletions test/cli/harness/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions test/cli/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand All @@ -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" &&
Expand Down
Loading