mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
CloudWatch: Remove dynamic labels feature toggle (#67371)
This commit is contained in:
-19
@@ -3,7 +3,6 @@ import React from 'react';
|
||||
import selectEvent from 'react-select-event';
|
||||
|
||||
import { DataSourceInstanceSettings } from '@grafana/data';
|
||||
import { config } from '@grafana/runtime';
|
||||
import * as ui from '@grafana/ui';
|
||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
@@ -125,22 +124,4 @@ describe('QueryEditor', () => {
|
||||
expect(screen.queryByText('Alias')).toBeNull();
|
||||
expect(screen.getByText("Period: ${PROP('Period')} InstanceId: ${PROP('Dim.InstanceId')}"));
|
||||
});
|
||||
|
||||
// TODO: delete this test when dynamic labels feature flag is removed
|
||||
describe('when dynamic labels feature toggle is disabled', () => {
|
||||
it('should render alias field', async () => {
|
||||
const props = setup();
|
||||
const originalValue = config.featureToggles.cloudWatchDynamicLabels;
|
||||
config.featureToggles.cloudWatchDynamicLabels = false;
|
||||
|
||||
const expected = 'Period: {{period}} InstanceId: {{InstanceId}}';
|
||||
render(<MetricsQueryEditor {...props} query={{ ...props.query, refId: 'A', alias: expected }} />);
|
||||
|
||||
expect(await screen.findByText('Label')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Alias')).toBeNull();
|
||||
expect(screen.getByText("Period: ${PROP('Period')} InstanceId: ${PROP('Dim.InstanceId')}"));
|
||||
|
||||
config.featureToggles.cloudWatchDynamicLabels = originalValue;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { config } from '@grafana/runtime';
|
||||
|
||||
import { CloudWatchMetricsQuery } from '../types';
|
||||
|
||||
import { migrateAliasPatterns } from './metricQueryMigrations';
|
||||
@@ -74,47 +72,5 @@ describe('metricQueryMigrations', () => {
|
||||
expect(result.alias).toBe(alias);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: delete this test when dynamic labels feature flag is removed
|
||||
describe('when feature is disabled', () => {
|
||||
const cases: TestScenario[] = [
|
||||
{ alias: '{{period}}', label: "${PROP('MetricName')}" },
|
||||
{ alias: '{{metric}}', label: "${PROP('MetricName')}" },
|
||||
{ alias: '', label: "${PROP('MetricName')}" },
|
||||
{ alias: '', label: '' },
|
||||
{ description: 'Metric name', alias: '{{metric}}', label: "${PROP('MetricName')}" },
|
||||
{ description: 'Trim pattern', alias: '{{ metric }}', label: "${PROP('MetricName')}" },
|
||||
{ description: 'Namespace', alias: '{{namespace}}', label: "${PROP('Namespace')}" },
|
||||
{ description: 'Period', alias: '{{period}}', label: "${PROP('Period')}" },
|
||||
{ description: 'Region', alias: '{{region}}', label: "${PROP('Region')}" },
|
||||
{ description: 'Statistic', alias: '{{stat}}', label: "${PROP('Stat')}" },
|
||||
{ description: 'Label', alias: '{{label}}', label: '${LABEL}' },
|
||||
{
|
||||
description: 'Non-existing alias pattern',
|
||||
alias: '{{anything_else}}',
|
||||
label: "${PROP('Dim.anything_else')}",
|
||||
},
|
||||
{
|
||||
description: 'Combined patterns',
|
||||
alias: 'some {{combination}} of {{label}} and {{metric}}',
|
||||
label: "some ${PROP('Dim.combination')} of ${LABEL} and ${PROP('MetricName')}",
|
||||
},
|
||||
{
|
||||
description: 'Combined patterns not trimmed',
|
||||
alias: 'some {{combination }}{{ label}} and {{metric}}',
|
||||
label: "some ${PROP('Dim.combination')}${LABEL} and ${PROP('MetricName')}",
|
||||
},
|
||||
];
|
||||
test.each(cases)('should migrate alias anyway', ({ alias, label }) => {
|
||||
config.featureToggles.cloudWatchDynamicLabels = false;
|
||||
const testQuery = { ...baseQuery, alias: `${alias}` };
|
||||
if (label !== undefined) {
|
||||
testQuery.label = label;
|
||||
}
|
||||
const result = migrateAliasPatterns(testQuery);
|
||||
expect(result.label).toBe(label);
|
||||
expect(result.alias).toBe(alias);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { renderHook } from '@testing-library/react';
|
||||
|
||||
import { config } from '@grafana/runtime';
|
||||
|
||||
import { DEFAULT_METRICS_QUERY } from '../defaultQueries';
|
||||
import { CloudWatchMetricsQuery } from '../types';
|
||||
|
||||
@@ -21,7 +19,6 @@ describe('usePrepareMetricsQuery', () => {
|
||||
});
|
||||
});
|
||||
describe('when query has a label', () => {
|
||||
config.featureToggles.cloudWatchDynamicLabels = true;
|
||||
const testQuery: CloudWatchMetricsQuery = { ...DEFAULT_TEST_QUERY, label: 'test' };
|
||||
it('should not replace label or trigger onChange', async () => {
|
||||
const onChangeQuery = jest.fn();
|
||||
@@ -30,16 +27,4 @@ describe('usePrepareMetricsQuery', () => {
|
||||
expect(onChangeQuery).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
// TODO: delete this test when dynamic labels feature flag is removed
|
||||
describe('when dynamic labels feature flag is disabled', () => {
|
||||
const testQuery: CloudWatchMetricsQuery = { ...DEFAULT_TEST_QUERY };
|
||||
it('should replace label or trigger onChange', async () => {
|
||||
const expectedQuery: CloudWatchMetricsQuery = migrateAliasPatterns(testQuery);
|
||||
config.featureToggles.cloudWatchDynamicLabels = false;
|
||||
const onChangeQuery = jest.fn();
|
||||
const { result } = renderHook(() => useMigratedMetricsQuery(testQuery, onChangeQuery));
|
||||
expect(onChangeQuery).toHaveBeenLastCalledWith(result.current);
|
||||
expect(result.current).toEqual(expectedQuery);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user