Skip to content

Commit

Permalink
Adds port for syslog server
Browse files Browse the repository at this point in the history
  • Loading branch information
bonzofenix committed May 7, 2024
1 parent 25ee6d9 commit 3f24873
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/autoscaler/metricsforwarder/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type LoggregatorConfig struct {

type SyslogConfig struct {
ServerAddress string `yaml:"server_address"`
Port int `yaml:"port"`
}

func LoadConfig(reader io.Reader) (*Config, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ var _ = Describe("SyslogEmitter", func() {
)

BeforeEach(func() {
listener, err = net.Listen("tcp", "127.0.0.1:")
port := 10000 + GinkgoParallelProcess()
listener, err = net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", port))

Expect(err).ToNot(HaveOccurred())

url, err := url.Parse(fmt.Sprintf("syslog://%s", listener.Addr()))
Expand All @@ -32,6 +34,7 @@ var _ = Describe("SyslogEmitter", func() {
conf = &config.Config{
SyslogConfig: config.SyslogConfig{
ServerAddress: url.Host,
Port: port,
},
}

Expand All @@ -54,7 +57,7 @@ var _ = Describe("SyslogEmitter", func() {
actual, err := buf.ReadString('\n')
Expect(err).ToNot(HaveOccurred())

expected := fmt.Sprintf(`128 <14>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}\+\d{2}:\d{2} test-hostname %s [] - [gauge@47450 name="%s" value="%f" unit="%s"]`, metric.AppGUID, metric.Name, metric.Value, metric.Unit)
expected := fmt.Sprintf(`128 <14>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}\+\d{2}:\d{2} test-hostname %s [] - [gauge@47450 name="%s" value="%.2f" unit="%s"]`, metric.AppGUID, metric.Name, metric.Value, metric.Unit)
Expect(actual).To(MatchRegexp(expected))
})
})

0 comments on commit 3f24873

Please sign in to comment.