diff --git a/pkg/scalers/aws_cloudwatch_scaler_test.go b/pkg/scalers/aws_cloudwatch_scaler_test.go index a996514d62f..521afe54f6f 100644 --- a/pkg/scalers/aws_cloudwatch_scaler_test.go +++ b/pkg/scalers/aws_cloudwatch_scaler_test.go @@ -645,6 +645,38 @@ func TestCloudwatchParseMetadata(t *testing.T) { } } +func TestAWSCloudwatchScalerMultipleDimensions(t *testing.T) { + meta := map[string]string{ + "namespace": "AWS/SQS", + "dimensionName": "QueueName;Region", + "dimensionValue": "queue1;us-west-2", + "metricName": "ApproximateNumberOfMessagesVisible", + "targetMetricValue": "5", + "minMetricValue": "1", + "metricStat": "Average", + "awsRegion": "us-west-2", + } + + config := &scalersconfig.ScalerConfig{ + TriggerMetadata: meta, + ResolvedEnv: testAWSCloudwatchResolvedEnv, + AuthParams: testAWSAuthentication, + } + + awsMeta, err := parseAwsCloudwatchMetadata(config) + if err != nil { + t.Fatalf("Expected no error, got %v", err) + } + + if assert.Equal(t, 2, len(awsMeta.DimensionName), "Expected two dimension names") && + assert.Equal(t, 2, len(awsMeta.DimensionValue), "Expected two dimension values") { + assert.Equal(t, "QueueName", awsMeta.DimensionName[0], "First dimension name should be QueueName") + assert.Equal(t, "Region", awsMeta.DimensionName[1], "Second dimension name should be Region") + assert.Equal(t, "queue1", awsMeta.DimensionValue[0], "First dimension value should be queue1") + assert.Equal(t, "us-west-2", awsMeta.DimensionValue[1], "Second dimension value should be us-west-2") + } +} + func TestAWSCloudwatchGetMetricSpecForScaling(t *testing.T) { for _, testData := range awsCloudwatchMetricIdentifiers { ctx := context.Background()