Skip to content

Commit

Permalink
Remove unnecessary public func testutil.TempSocketName (open-telemetr…
Browse files Browse the repository at this point in the history
…y#3291)

* Remove unnecessary public func testutil.TempSocketName

Signed-off-by: Bogdan Drutu <[email protected]>

* Update changelog

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored May 26, 2021
1 parent 5b5eae4 commit ab616c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Remove unused logstest package (#3222)
- Introduce `AppSettings` instead of `Parameters` (#3163)
- Remove unused testutil.TempSocketName (#3291)
- Move BigEndian helper functions in `tracetranslator` to an internal package.(#3298)

## 💡 Enhancements 💡
Expand Down
15 changes: 13 additions & 2 deletions config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package configgrpc

import (
"context"
"io/ioutil"
"os"
"path"
"runtime"
"testing"
Expand All @@ -31,7 +33,6 @@ import (
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/config/configtls"
otelcol "go.opentelemetry.io/collector/internal/data/protogen/collector/trace/v1"
"go.opentelemetry.io/collector/testutil"
)

func TestDefaultGrpcClientSettings(t *testing.T) {
Expand Down Expand Up @@ -453,7 +454,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("skipping test on windows")
}
socketName := testutil.TempSocketName(t)
socketName := tempSocketName(t)
gss := &GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: socketName,
Expand Down Expand Up @@ -525,3 +526,13 @@ func TestWithPerRPCAuthInvalidAuthType(t *testing.T) {
assert.Error(t, err)
assert.Nil(t, dialOpts)
}

// tempSocketName provides a temporary Unix socket name for testing.
func tempSocketName(t *testing.T) string {
tmpfile, err := ioutil.TempFile("", "sock")
require.NoError(t, err)
require.NoError(t, tmpfile.Close())
socket := tmpfile.Name()
require.NoError(t, os.Remove(socket))
return socket
}
12 changes: 0 additions & 12 deletions testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
package testutil

import (
"io/ioutil"
"net"
"os"
"os/exec"
"runtime"
"strconv"
Expand All @@ -32,16 +30,6 @@ type portpair struct {
last string
}

// TempSocketName provides a temporary Unix socket name for testing.
func TempSocketName(t *testing.T) string {
tmpfile, err := ioutil.TempFile("", "sock")
require.NoError(t, err)
require.NoError(t, tmpfile.Close())
socket := tmpfile.Name()
require.NoError(t, os.Remove(socket))
return socket
}

// GetAvailableLocalAddress finds an available local port and returns an endpoint
// describing it. The port is available for opening when this function returns
// provided that there is no race by some other code to grab the same port
Expand Down

0 comments on commit ab616c8

Please sign in to comment.