mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-11 11:19:05 +08:00
fix: disable telemetry in test profile (#10931)
Some checks failed
CodeQL / codeql (push) Has been cancelled
Docker Build / docker-build (push) Has been cancelled
Gateway Conformance / gateway-conformance (push) Has been cancelled
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Has been cancelled
Go Build / go-build (push) Has been cancelled
Go Check / go-check (push) Has been cancelled
Go Lint / go-lint (push) Has been cancelled
Go Test / go-test (push) Has been cancelled
Interop / interop-prep (push) Has been cancelled
Sharness / sharness-test (push) Has been cancelled
Spell Check / spellcheck (push) Has been cancelled
Interop / helia-interop (push) Has been cancelled
Interop / ipfs-webui (push) Has been cancelled
Some checks failed
CodeQL / codeql (push) Has been cancelled
Docker Build / docker-build (push) Has been cancelled
Gateway Conformance / gateway-conformance (push) Has been cancelled
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Has been cancelled
Go Build / go-build (push) Has been cancelled
Go Check / go-check (push) Has been cancelled
Go Lint / go-lint (push) Has been cancelled
Go Test / go-test (push) Has been cancelled
Interop / interop-prep (push) Has been cancelled
Sharness / sharness-test (push) Has been cancelled
Spell Check / spellcheck (push) Has been cancelled
Interop / helia-interop (push) Has been cancelled
Interop / ipfs-webui (push) Has been cancelled
* 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>
This commit is contained in:
parent
ae068a8061
commit
15f723a15e
@ -7,5 +7,5 @@ type Plugins struct {
|
||||
|
||||
type Plugin struct {
|
||||
Disabled bool
|
||||
Config interface{}
|
||||
Config interface{} `json:",omitempty"`
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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" &&
|
||||
|
||||
Loading…
Reference in New Issue
Block a user