From d36577a17d3ad835085197912018836f70922913 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Wed, 1 May 2024 09:24:40 -0700 Subject: [PATCH] [testbed] Remove deprecated `GetAvailablePort` function --- .../remove_deprecate_GetAvailablePort.yaml | 27 +++++++++++++++++++ testbed/testbed/in_process_collector_test.go | 4 ++- testbed/testbed/mock_backend_test.go | 4 ++- testbed/testbed/utils.go | 26 ------------------ 4 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 .chloggen/remove_deprecate_GetAvailablePort.yaml delete mode 100644 testbed/testbed/utils.go diff --git a/.chloggen/remove_deprecate_GetAvailablePort.yaml b/.chloggen/remove_deprecate_GetAvailablePort.yaml new file mode 100644 index 000000000000..cae9db7c5984 --- /dev/null +++ b/.chloggen/remove_deprecate_GetAvailablePort.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: testbed + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove deprecated `GetAvailablePort` function + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [32800] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/testbed/testbed/in_process_collector_test.go b/testbed/testbed/in_process_collector_test.go index 902f4f5fb29c..81e48bb95737 100644 --- a/testbed/testbed/in_process_collector_test.go +++ b/testbed/testbed/in_process_collector_test.go @@ -9,12 +9,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" ) func TestNewInProcessPipeline(t *testing.T) { factories, err := Components() assert.NoError(t, err) - sender := NewOTLPTraceDataSender(DefaultHost, GetAvailablePort(t)) + sender := NewOTLPTraceDataSender(DefaultHost, testutil.GetAvailablePort(t)) receiver := NewOTLPDataReceiver(DefaultOTLPPort) runner, ok := NewInProcessCollector(factories).(*inProcessCollector) require.True(t, ok) diff --git a/testbed/testbed/mock_backend_test.go b/testbed/testbed/mock_backend_test.go index 98882d87cbd3..cb47f7dd2a79 100644 --- a/testbed/testbed/mock_backend_test.go +++ b/testbed/testbed/mock_backend_test.go @@ -9,10 +9,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" ) func TestGeneratorAndBackend(t *testing.T) { - port := GetAvailablePort(t) + port := testutil.GetAvailablePort(t) tests := []struct { name string diff --git a/testbed/testbed/utils.go b/testbed/testbed/utils.go deleted file mode 100644 index 92e2103a188e..000000000000 --- a/testbed/testbed/utils.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package testbed // import "github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed" - -import ( - "net" - "strconv" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" -) - -// Deprecated: [v0.94.0] Use `testutil.GetAvailablePort(t testing.TB)` instead -func GetAvailablePort(t testing.TB) int { - endpoint := testutil.GetAvailableLocalAddress(t) - _, port, err := net.SplitHostPort(endpoint) - require.NoError(t, err) - - portInt, err := strconv.Atoi(port) - require.NoError(t, err) - - return portInt -}