From 25eac7012c953230eefd5023369f9903336ed281 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 18 Jun 2024 14:44:25 +0200 Subject: [PATCH] Fix Test{GRPC,HTTP}ServerWarning --- config/configgrpc/configgrpc_test.go | 9 +++++++++ config/configgrpc/go.mod | 2 +- config/confighttp/confighttp_test.go | 9 +++++++++ config/confighttp/go.mod | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index c6009d347f8..010c415a441 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -32,6 +32,8 @@ import ( "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/extension/auth" "go.opentelemetry.io/collector/extension/auth/authtest" + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/internal/localhostgate" "go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp" ) @@ -437,6 +439,13 @@ func TestUseSecure(t *testing.T) { } func TestGRPCServerWarning(t *testing.T) { + prev := localhostgate.UseLocalHostAsDefaultHostfeatureGate.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(localhostgate.UseLocalHostAsDefaultHostID, false)) + defer func() { + // Restore previous value. + require.NoError(t, featuregate.GlobalRegistry().Set(localhostgate.UseLocalHostAsDefaultHostID, prev)) + }() + tests := []struct { name string settings ServerConfig diff --git a/config/configgrpc/go.mod b/config/configgrpc/go.mod index a22e4b507ff..0007c6b5454 100644 --- a/config/configgrpc/go.mod +++ b/config/configgrpc/go.mod @@ -16,6 +16,7 @@ require ( go.opentelemetry.io/collector/config/configtls v0.102.1 go.opentelemetry.io/collector/config/internal v0.102.1 go.opentelemetry.io/collector/extension/auth v0.102.1 + go.opentelemetry.io/collector/featuregate v1.9.0 go.opentelemetry.io/collector/pdata v1.9.0 go.opentelemetry.io/collector/pdata/testdata v0.102.1 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 @@ -51,7 +52,6 @@ require ( github.com/prometheus/procfs v0.15.0 // indirect go.opentelemetry.io/collector/confmap v0.102.1 // indirect go.opentelemetry.io/collector/extension v0.102.1 // indirect - go.opentelemetry.io/collector/featuregate v1.9.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.49.0 // indirect go.opentelemetry.io/otel/metric v1.27.0 // indirect go.opentelemetry.io/otel/sdk v1.27.0 // indirect diff --git a/config/confighttp/confighttp_test.go b/config/confighttp/confighttp_test.go index c7c45924783..c37acd243e6 100644 --- a/config/confighttp/confighttp_test.go +++ b/config/confighttp/confighttp_test.go @@ -33,6 +33,8 @@ import ( "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/extension/auth" "go.opentelemetry.io/collector/extension/auth/authtest" + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/internal/localhostgate" ) type customRoundTripper struct { @@ -514,6 +516,13 @@ func TestHTTPServerSettingsError(t *testing.T) { } func TestHTTPServerWarning(t *testing.T) { + prev := localhostgate.UseLocalHostAsDefaultHostfeatureGate.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(localhostgate.UseLocalHostAsDefaultHostID, false)) + defer func() { + // Restore previous value. + require.NoError(t, featuregate.GlobalRegistry().Set(localhostgate.UseLocalHostAsDefaultHostID, prev)) + }() + tests := []struct { name string settings ServerConfig diff --git a/config/confighttp/go.mod b/config/confighttp/go.mod index 0076f421a53..873d9cfa52e 100644 --- a/config/confighttp/go.mod +++ b/config/confighttp/go.mod @@ -16,6 +16,7 @@ require ( go.opentelemetry.io/collector/config/configtls v0.102.1 go.opentelemetry.io/collector/config/internal v0.102.1 go.opentelemetry.io/collector/extension/auth v0.102.1 + go.opentelemetry.io/collector/featuregate v1.9.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 go.opentelemetry.io/otel v1.27.0 go.uber.org/goleak v1.3.0 @@ -46,7 +47,6 @@ require ( github.com/prometheus/procfs v0.15.0 // indirect go.opentelemetry.io/collector/confmap v0.102.1 // indirect go.opentelemetry.io/collector/extension v0.102.1 // indirect - go.opentelemetry.io/collector/featuregate v1.9.0 // indirect go.opentelemetry.io/collector/pdata v1.9.0 // indirect go.opentelemetry.io/otel/exporters/prometheus v0.49.0 // indirect go.opentelemetry.io/otel/metric v1.27.0 // indirect