From 00a960b6499e05eaad5fd9e0508e9fe20596837d Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 9 Jun 2022 13:10:08 -0700 Subject: [PATCH] common/testutil: Exclude port ranges for both TCP and UDP (#10872) Signed-off-by: Bogdan Drutu --- internal/common/testutil/testutil.go | 13 +++++++++---- receiver/jaegerreceiver/jaeger_agent_test.go | 7 ------- receiver/statsdreceiver/receiver_test.go | 4 ---- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/internal/common/testutil/testutil.go b/internal/common/testutil/testutil.go index deff550f8e15..abdfac652c19 100644 --- a/internal/common/testutil/testutil.go +++ b/internal/common/testutil/testutil.go @@ -85,11 +85,16 @@ func GetAvailablePort(t *testing.T) uint16 { // Get excluded ports on Windows from the command: netsh interface ipv4 show excludedportrange protocol=tcp func getExclusionsList(t *testing.T) []portpair { - cmd := exec.Command("netsh", "interface", "ipv4", "show", "excludedportrange", "protocol=tcp") - output, err := cmd.CombinedOutput() - require.NoError(t, err) + cmdTCP := exec.Command("netsh", "interface", "ipv4", "show", "excludedportrange", "protocol=tcp") + outputTCP, errTCP := cmdTCP.CombinedOutput() + require.NoError(t, errTCP) + exclusions := createExclusionsList(string(outputTCP), t) + + cmdUDP := exec.Command("netsh", "interface", "ipv4", "show", "excludedportrange", "protocol=udp") + outputUDP, errUDP := cmdUDP.CombinedOutput() + require.NoError(t, errUDP) + exclusions = append(exclusions, createExclusionsList(string(outputUDP), t)...) - exclusions := createExclusionsList(string(output), t) return exclusions } diff --git a/receiver/jaegerreceiver/jaeger_agent_test.go b/receiver/jaegerreceiver/jaeger_agent_test.go index 27af49358649..622dc5b63da1 100644 --- a/receiver/jaegerreceiver/jaeger_agent_test.go +++ b/receiver/jaegerreceiver/jaeger_agent_test.go @@ -47,12 +47,7 @@ import ( var jaegerAgent = config.NewComponentIDWithName(typeStr, "agent_test") -var skip = func(t *testing.T, why string) { - t.Skip(why) -} - func TestJaegerAgentUDP_ThriftCompact(t *testing.T) { - skip(t, "Flaky Test - See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/10368") port := testutil.GetAvailablePort(t) addrForClient := fmt.Sprintf(":%d", port) testJaegerAgent(t, addrForClient, &configuration{ @@ -76,7 +71,6 @@ func TestJaegerAgentUDP_ThriftCompact_InvalidPort(t *testing.T) { } func TestJaegerAgentUDP_ThriftBinary(t *testing.T) { - skip(t, "Flaky Test - See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/10369") port := testutil.GetAvailablePort(t) addrForClient := fmt.Sprintf(":%d", port) testJaegerAgent(t, addrForClient, &configuration{ @@ -86,7 +80,6 @@ func TestJaegerAgentUDP_ThriftBinary(t *testing.T) { } func TestJaegerAgentUDP_ThriftBinary_PortInUse(t *testing.T) { - skip(t, "Flaky Test - See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/10370") // This test confirms that the thrift binary port is opened correctly. This is all we can test at the moment. See above. port := testutil.GetAvailablePort(t) diff --git a/receiver/statsdreceiver/receiver_test.go b/receiver/statsdreceiver/receiver_test.go index bda00ae41124..1709360db873 100644 --- a/receiver/statsdreceiver/receiver_test.go +++ b/receiver/statsdreceiver/receiver_test.go @@ -19,7 +19,6 @@ import ( "context" "errors" "net" - "runtime" "strconv" "testing" "time" @@ -94,9 +93,6 @@ func TestStatsdReceiver_Flush(t *testing.T) { } func Test_statsdreceiver_EndToEnd(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("skipping test on windows, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/10151") - } addr := testutil.GetAvailableLocalAddress(t) host, portStr, err := net.SplitHostPort(addr) require.NoError(t, err)