Skip to content

Commit

Permalink
Clean up fields and fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Marshall <[email protected]>
  • Loading branch information
michaeljmarshall committed Nov 10, 2022
1 parent 7d902b4 commit d238070
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 10 deletions.
3 changes: 0 additions & 3 deletions pkg/scalers/pulsar_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ type pulsarScaler struct {
type pulsarMetadata struct {
adminURL string
topic string
isPartitionedTopic bool
subscription string
msgBacklogThreshold int64
activationMsgBacklogThreshold int64
Expand Down Expand Up @@ -143,10 +142,8 @@ func parsePulsarMetadata(config *ScalerConfig) (pulsarMetadata, error) {

topic := strings.ReplaceAll(meta.topic, "persistent://", "")
if config.TriggerMetadata["isPartitionedTopic"] == stringTrue {
meta.isPartitionedTopic = true
meta.statsURL = meta.adminURL + "/admin/v2/persistent/" + topic + "/partitioned-stats"
} else {
meta.isPartitionedTopic = false
meta.statsURL = meta.adminURL + "/admin/v2/persistent/" + topic + "/stats"
}

Expand Down
6 changes: 0 additions & 6 deletions pkg/scalers/pulsar_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,10 @@ func TestParsePulsarMetadata(t *testing.T) {

if !testData.isError {
if testData.isPartitionedTopic {
if !meta.isPartitionedTopic {
t.Errorf("Expected isPartitionedTopic %t but got %t\n", testData.isPartitionedTopic, meta.isPartitionedTopic)
}
if !strings.HasSuffix(meta.statsURL, "/partitioned-stats") {
t.Errorf("Expected statsURL to end with /partitioned-stats but got %s\n", meta.statsURL)
}
} else {
if meta.isPartitionedTopic {
t.Errorf("Expected isPartitionedTopic %t but got %t\n", testData.isPartitionedTopic, meta.isPartitionedTopic)
}
if !strings.HasSuffix(meta.statsURL, "/stats") {
t.Errorf("Expected statsURL to end with /stats but got %s\n", meta.statsURL)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/scalers/pulsar/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ spec:
cooldownPeriod: 30 # Optional. Default: 300 seconds
maxReplicaCount: {{.MaxReplicaCount}}
minReplicaCount: {{.MinReplicaCount}}
isPartitionedTopic: {{ if .NumPartitions }} "true" {{else}} "false" {{end}}
triggers:
- type: pulsar
metadata:
msgBacklog: "{{.MsgBacklog}}"
activationMsgBacklogThreshold: "5"
adminURL: http://{{.TestName}}.{{.TestName}}:8080
topic: persistent://public/default/keda
isPartitionedTopic: {{ if .NumPartitions }} "true" {{else}} "false" {{end}}
subscription: keda
`

Expand Down

0 comments on commit d238070

Please sign in to comment.