Skip to content

Commit

Permalink
[chore] Fix Supervisor tests on Windows (open-telemetry#35818)
Browse files Browse the repository at this point in the history
#### Description

This fixes a few tests on Windows that were failing due to a mismatch
between newline character sequences between Windows and non-Windows
operating systems.

#### Link to tracking issue
Fixes
open-telemetry#35812
  • Loading branch information
evan-bradley authored and sbylica-splunk committed Dec 17, 2024
1 parent ede722d commit 6db18bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/opampsupervisor/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
effective.yaml
agent.log
*.dat
8 changes: 6 additions & 2 deletions cmd/opampsupervisor/supervisor/supervisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"regexp"
"runtime"
"strings"
"sync/atomic"
"testing"
"time"
Expand Down Expand Up @@ -1154,6 +1155,7 @@ service:
assert.True(t, configChanged)

got := s.agentConfigOwnMetricsSection.Load().(string)
got = strings.ReplaceAll(got, "\r\n", "\n")

// replace the port because that changes on each run
portRegex := regexp.MustCompile(":[0-9]{5}")
Expand Down Expand Up @@ -1320,6 +1322,7 @@ service:
assert.Equal(t, remoteCfg.String(), s.remoteConfig.String())

gotMergedConfig := s.cfgState.Load().(*configState).mergedConfig
gotMergedConfig = strings.ReplaceAll(gotMergedConfig, "\r\n", "\n")
// replace random port numbers
portRegex := regexp.MustCompile(":[0-9]{5}")
replacedMergedConfig := portRegex.ReplaceAll([]byte(gotMergedConfig), []byte(":55555"))
Expand Down Expand Up @@ -1363,8 +1366,9 @@ service:

require.NoError(t, s.createTemplates())

noopConfig, err := s.composeNoopConfig()
noopConfigBytes, err := s.composeNoopConfig()
noopConfig := strings.ReplaceAll(string(noopConfigBytes), "\r\n", "\n")

require.NoError(t, err)
require.Equal(t, expectedConfig, string(noopConfig))
require.Equal(t, expectedConfig, noopConfig)
}

0 comments on commit 6db18bd

Please sign in to comment.