diff --git a/pkg/scalers/rabbitmq_scaler.go b/pkg/scalers/rabbitmq_scaler.go index 8eee88ee62a..07971f82c74 100644 --- a/pkg/scalers/rabbitmq_scaler.go +++ b/pkg/scalers/rabbitmq_scaler.go @@ -426,7 +426,7 @@ func (s *rabbitMQScaler) getQueueInfoViaHTTP() (*queueInfo, error) { parsedURL.Path = "" var getQueueInfoManagementURI string if s.metadata.useRegex { - getQueueInfoManagementURI = fmt.Sprintf("%s/api/queues?page=1&use_regex=true&pagination=false&name=%s&page_size=%d", parsedURL.String(), url.QueryEscape(s.metadata.queueName), s.metadata.pageSize) + getQueueInfoManagementURI = fmt.Sprintf("%s/api/queues%s?page=1&use_regex=true&pagination=false&name=%s&page_size=%d", parsedURL.String(), vhost, url.QueryEscape(s.metadata.queueName), s.metadata.pageSize) } else { getQueueInfoManagementURI = fmt.Sprintf("%s/api/queues%s/%s", parsedURL.String(), vhost, url.QueryEscape(s.metadata.queueName)) } diff --git a/pkg/scalers/rabbitmq_scaler_test.go b/pkg/scalers/rabbitmq_scaler_test.go index d41dc3feef6..ea8b6ba60fc 100644 --- a/pkg/scalers/rabbitmq_scaler_test.go +++ b/pkg/scalers/rabbitmq_scaler_test.go @@ -328,7 +328,7 @@ var testRegexQueueInfoTestData = []getQueueInfoTestData{ func TestGetQueueInfoWithRegex(t *testing.T) { for _, testData := range testRegexQueueInfoTestData { var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - expectedPath := "/api/queues?page=1&use_regex=true&pagination=false&name=%5Eevaluate_trials%24&page_size=100" + expectedPath := fmt.Sprintf("/api/queues%s?page=1&use_regex=true&pagination=false&name=%5Eevaluate_trials%24&page_size=100", testData.vhostPath) if r.RequestURI != expectedPath { t.Error("Expect request path to =", expectedPath, "but it is", r.RequestURI) } @@ -399,7 +399,7 @@ var testRegexPageSizeTestData = []getRegexPageSizeTestData{ func TestGetPageSizeWithRegex(t *testing.T) { for _, testData := range testRegexPageSizeTestData { var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - expectedPath := fmt.Sprintf("/api/queues?page=1&use_regex=true&pagination=false&name=%%5Eevaluate_trials%%24&page_size=%d", testData.pageSize) + expectedPath := fmt.Sprintf("/api/queues%s?page=1&use_regex=true&pagination=false&name=%%5Eevaluate_trials%%24&page_size=%d", testData.vhostPath, testData.pageSize) if r.RequestURI != expectedPath { t.Error("Expect request path to =", expectedPath, "but it is", r.RequestURI) } @@ -521,7 +521,7 @@ var testRegexQueueInfoNavigationTestData = []getQueueInfoNavigationTestData{ func TestRegexQueueMissingError(t *testing.T) { for _, testData := range testRegexQueueInfoNavigationTestData { var apiStub = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - expectedPath := "/api/queues?page=1&use_regex=true&pagination=false&name=evaluate_trials&page_size=100" + expectedPath := fmt.Sprintf("/api/queues%s?page=1&use_regex=true&pagination=false&name=evaluate_trials&page_size=100", testData.vhostPath) if r.RequestURI != expectedPath { t.Error("Expect request path to =", expectedPath, "but it is", r.RequestURI) }