CloudWatch: Deprecate dynamic labels feature toggle, remove support for Alias in backend (#66494)

This commit is contained in:
Shirley
2023-04-27 11:19:45 +02:00
committed by GitHub
parent 69a14b9a5e
commit e17496d79a
14 changed files with 162 additions and 411 deletions

View File

@@ -95,8 +95,8 @@ func TestMetricDataQueryBuilder(t *testing.T) {
assert.Equal(t, `SUM([a,b])`, *mdq.Expression)
})
t.Run("should set label when dynamic labels feature toggle is enabled", func(t *testing.T) {
executor := newExecutor(nil, newTestConfig(), &fakeSessionCache{}, featuremgmt.WithFeatures(featuremgmt.FlagCloudWatchDynamicLabels))
t.Run("should set label", func(t *testing.T) {
executor := newExecutor(nil, newTestConfig(), &fakeSessionCache{}, featuremgmt.WithFeatures())
query := getBaseQuery()
query.Label = "some label"
@@ -107,35 +107,19 @@ func TestMetricDataQueryBuilder(t *testing.T) {
assert.Equal(t, "some label", *mdq.Label)
})
testCases := map[string]struct {
feature *featuremgmt.FeatureManager
label string
}{
"should not set label when dynamic labels feature toggle is disabled": {
feature: featuremgmt.WithFeatures(),
label: "some label",
},
"should not set label for empty string query label": {
feature: featuremgmt.WithFeatures(featuremgmt.FlagCloudWatchDynamicLabels),
label: "",
},
}
t.Run("should not set label for empty string query label", func(t *testing.T) {
executor := newExecutor(nil, newTestConfig(), &fakeSessionCache{}, featuremgmt.WithFeatures())
query := getBaseQuery()
query.Label = ""
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
executor := newExecutor(nil, newTestConfig(), &fakeSessionCache{}, tc.feature)
query := getBaseQuery()
query.Label = tc.label
mdq, err := executor.buildMetricDataQuery(logger, query)
mdq, err := executor.buildMetricDataQuery(logger, query)
assert.NoError(t, err)
assert.Nil(t, mdq.Label)
})
}
assert.NoError(t, err)
assert.Nil(t, mdq.Label)
})
t.Run(`should not specify accountId when it is "all"`, func(t *testing.T) {
executor := newExecutor(nil, newTestConfig(), &fakeSessionCache{}, featuremgmt.WithFeatures(featuremgmt.FlagCloudWatchDynamicLabels))
executor := newExecutor(nil, newTestConfig(), &fakeSessionCache{}, featuremgmt.WithFeatures())
query := &models.CloudWatchQuery{
Namespace: "AWS/EC2",
MetricName: "CPUUtilization",
@@ -153,7 +137,7 @@ func TestMetricDataQueryBuilder(t *testing.T) {
})
t.Run("should set accountId when it is specified", func(t *testing.T) {
executor := newExecutor(nil, newTestConfig(), &fakeSessionCache{}, featuremgmt.WithFeatures(featuremgmt.FlagCloudWatchDynamicLabels))
executor := newExecutor(nil, newTestConfig(), &fakeSessionCache{}, featuremgmt.WithFeatures())
query := &models.CloudWatchQuery{
Namespace: "AWS/EC2",
MetricName: "CPUUtilization",