Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/solace]: Update broker config #36387

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/update-broker-config.yaml
Original file line number Diff line number Diff line change
@@ -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: solacereceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Document the broker field as a string and add validation checks

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36387]

# (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: []
8 changes: 4 additions & 4 deletions receiver/solacereceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To get started with the Solace receiver, a telemetry queue and authentication de
```yaml
receivers:
solace:
broker: [localhost:5671]
broker: localhost:5671
auth:
sasl_plain:
username: otel
Expand Down Expand Up @@ -63,7 +63,7 @@ Simple single node configuration with SASL plain authentication (TLS enabled by
```yaml
receivers:
solace:
broker: [localhost:5671]
broker: localhost:5671
auth:
sasl_plain:
username: otel
Expand All @@ -80,15 +80,15 @@ High availability setup with SASL plain authentication (TLS enabled by default)
```yaml
receivers:
solace/primary:
broker: [myHost-primary:5671]
broker: myHost-primary:5671
auth:
sasl_plain:
username: otel
password: otel01$
queue: queue://#telemetry-profile123

solace/backup:
broker: [myHost-backup:5671]
broker: myHost-backup:5671
auth:
sasl_plain:
username: otel
Expand Down
6 changes: 5 additions & 1 deletion receiver/solacereceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ var (
errMissingXauth2Params = errors.New("missing xauth2 text auth params: Username, Bearer")
errMissingFlowControl = errors.New("missing flow control configuration: DelayedRetry must be selected")
errInvalidDelayedRetryDelay = errors.New("delayed_retry.delay must > 0")
errInvalidBroker = errors.New("exactly one broker must be specified")
)

// Config defines configuration for Solace receiver.
type Config struct {
// The list of solace brokers (default localhost:5671)
// The solace broker (default localhost:5671). It's a slice because of legacy reasons but it supports only one element.
Broker []string `mapstructure:"broker"`

// The name of the solace queue to consume from, it is required parameter
Expand Down Expand Up @@ -57,6 +58,9 @@ func (cfg *Config) Validate() error {
} else if cfg.Flow.DelayedRetry.Delay <= 0 {
return errInvalidDelayedRetryDelay
}
if len(cfg.Broker) != 1 {
return errInvalidBroker
}
return nil
}

Expand Down
35 changes: 35 additions & 0 deletions receiver/solacereceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ func TestLoadConfig(t *testing.T) {
},
},
},
{
id: component.NewIDWithName(metadata.Type, "brokerString"),
expected: &Config{
Broker: []string{"myHost:5671"},
Auth: Authentication{
PlainText: &SaslPlainTextConfig{
Username: "otel",
Password: "otel01$",
},
},
Queue: "queue://#trace-profile123",
MaxUnacked: 1234,
TLS: configtls.ClientConfig{
Insecure: false,
InsecureSkipVerify: false,
},
Flow: FlowControl{
DelayedRetry: &FlowControlDelayedRetry{
Delay: 1 * time.Second,
},
},
},
},
{
id: component.NewIDWithName(metadata.Type, "noauth"),
expectedErr: errMissingAuthDetails,
Expand Down Expand Up @@ -115,6 +138,18 @@ func TestConfigValidateInvalidFlowControlDelayedRetryDelay(t *testing.T) {
assert.Equal(t, errInvalidDelayedRetryDelay, err)
}

func TestConfigValidateBroker(t *testing.T) {
cfg := createDefaultConfig().(*Config)
cfg.Queue = "someQueue"
cfg.Auth.PlainText = &SaslPlainTextConfig{"Username", "Password"}
cfg.Broker = []string{}
err := component.ValidateConfig(cfg)
assert.Equal(t, errInvalidBroker, err)
cfg.Broker = []string{"broker1:5671", "broker2:5671"}
err = component.ValidateConfig(cfg)
assert.Equal(t, errInvalidBroker, err)
}

func TestConfigValidateSuccess(t *testing.T) {
successCases := map[string]func(*Config){
"With Plaintext Auth": func(c *Config) {
Expand Down
12 changes: 12 additions & 0 deletions receiver/solacereceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ solace/primary:
delayed_retry:
delay: 1s

solace/brokerString:
broker: myHost:5671
auth:
sasl_plain:
username: otel
password: otel01$
queue: queue://#trace-profile123
max_unacknowledged: 1234
flow_control:
delayed_retry:
delay: 1s

solace/backup:
auth:
sasl_xauth2:
Expand Down
Loading