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

[v2] Consolidate apiHost & host for RabbitMQ scaler #1115

Merged
merged 5 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adjust tests
Signed-off-by: Tomek Urbaszek <[email protected]>
  • Loading branch information
turbaszek committed Sep 10, 2020
commit 12a6cb6078de08fe76dde12a346a56461a1c3477
2 changes: 1 addition & 1 deletion pkg/scalers/rabbitmq_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type rabbitMQScaler struct {

type rabbitMQMetadata struct {
queueName string
host string // connection string for either HTTP or AMQP protocol
queueLength int
host string // connection string for either HTTP or AMQP protocol
protocol string // either http or amqp protocol
}

Expand Down
16 changes: 7 additions & 9 deletions pkg/scalers/rabbitmq_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
)

const (
host = "myHostSecret"
apiHost = "myApiHostSecret"
host = "myHostSecret"
)

type parseRabbitMQMetadataTestData struct {
Expand All @@ -26,8 +25,7 @@ type rabbitMQMetricIdentifier struct {
}

var sampleRabbitMqResolvedEnv = map[string]string{
host: "amqp://user:[email protected]:5236/vhost",
apiHost: "https://user:[email protected]/vhost",
host: "amqp://user:[email protected]:5236/vhost",
}

var testRabbitMQMetadata = []parseRabbitMQMetadataTestData{
Expand All @@ -43,8 +41,8 @@ var testRabbitMQMetadata = []parseRabbitMQMetadataTestData{
{map[string]string{"queueLength": "10", "hostFromEnv": host}, true, map[string]string{}},
// host defined in authParams
{map[string]string{"queueLength": "10"}, true, map[string]string{"host": host}},
// properly formed metadata with includeUnacked
{map[string]string{"queueLength": "10", "queueName": "sample", "apiHostFromEnv": apiHost, "includeUnacked": "true"}, false, map[string]string{}},
// properly formed metadata with http protocol
{map[string]string{"queueLength": "10", "queueName": "sample", "host": host, "protocol": "http"}, false, map[string]string{}},
}

var rabbitMQMetricIdentifiers = []rabbitMQMetricIdentifier{
Expand All @@ -67,7 +65,7 @@ var testDefaultQueueLength = []parseRabbitMQMetadataTestData{
// use default queueLength
{map[string]string{"queueName": "sample", "host": host}, false, map[string]string{}},
// use default queueLength with includeUnacked
{map[string]string{"queueName": "sample", "apiHost": apiHost, "includeUnacked": "true"}, false, map[string]string{}},
{map[string]string{"queueName": "sample", "host": host, "protocol": "http"}, false, map[string]string{}},
}

func TestParseDefaultQueueLength(t *testing.T) {
Expand Down Expand Up @@ -118,12 +116,12 @@ func TestGetQueueInfo(t *testing.T) {
w.Write([]byte(testData.response))
}))

resolvedEnv := map[string]string{apiHost: fmt.Sprintf("%s%s", apiStub.URL, vhostPath)}
resolvedEnv := map[string]string{host: fmt.Sprintf("%s%s", apiStub.URL, vhostPath)}

metadata := map[string]string{
"queueLength": "10",
"queueName": "evaluate_trials",
"apiHostFromEnv": apiHost,
"hostFromEnv": host,
"includeUnacked": "true",
}

Expand Down