mirror of https://github.com/grafana/grafana
InfluxDB: Fix retention policy handling for InfluxDB 3.0 engine by bringing back the hardcoded default (#72467)
* Revert retention policy handling * Remove comment * Send retention policy with request when it's possiblepull/72925/head
parent
0d6e911fff
commit
3395ad03a7
@ -1,55 +0,0 @@ |
|||||||
import { renderHook } from '@testing-library/react-hooks'; |
|
||||||
|
|
||||||
import { FetchResponse } from '@grafana/runtime/src'; |
|
||||||
import config from 'app/core/config'; |
|
||||||
|
|
||||||
import { getMockDS, getMockDSInstanceSettings, mockBackendService } from '../../../../../specs/mocks'; |
|
||||||
|
|
||||||
import { useRetentionPolicies } from './useRetentionPolicies'; |
|
||||||
|
|
||||||
jest.mock('@grafana/runtime', () => ({ |
|
||||||
...jest.requireActual('@grafana/runtime'), |
|
||||||
})); |
|
||||||
|
|
||||||
describe('useRetentionPolicies', () => { |
|
||||||
it('should return all policies when influxdbBackendMigration feature toggle enabled', async () => { |
|
||||||
const instanceSettings = getMockDSInstanceSettings(); |
|
||||||
const datasource = getMockDS(instanceSettings); |
|
||||||
mockBackendService(response); |
|
||||||
|
|
||||||
config.featureToggles.influxdbBackendMigration = true; |
|
||||||
const { result, waitForNextUpdate } = renderHook(() => useRetentionPolicies(datasource)); |
|
||||||
await waitForNextUpdate(); |
|
||||||
expect(result.current.retentionPolicies.length).toEqual(4); |
|
||||||
expect(result.current.retentionPolicies[0]).toEqual('autogen'); |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
const response: FetchResponse = { |
|
||||||
config: { |
|
||||||
url: 'mock-response-url', |
|
||||||
}, |
|
||||||
headers: new Headers(), |
|
||||||
ok: false, |
|
||||||
redirected: false, |
|
||||||
status: 0, |
|
||||||
statusText: '', |
|
||||||
type: 'basic', |
|
||||||
url: '', |
|
||||||
data: { |
|
||||||
results: { |
|
||||||
metadataQuery: { |
|
||||||
status: 200, |
|
||||||
frames: [ |
|
||||||
{ |
|
||||||
schema: { |
|
||||||
refId: 'metadataQuery', |
|
||||||
fields: [{ name: 'value', type: 'string', typeInfo: { frame: 'string' } }], |
|
||||||
}, |
|
||||||
data: { values: [['autogen', 'bar', '5m_avg', '1m_avg']] }, |
|
||||||
}, |
|
||||||
], |
|
||||||
}, |
|
||||||
}, |
|
||||||
}, |
|
||||||
}; |
|
@ -1,15 +0,0 @@ |
|||||||
import { useEffect, useState } from 'react'; |
|
||||||
|
|
||||||
import InfluxDatasource from '../../../../../datasource'; |
|
||||||
import { getAllPolicies } from '../../../../../influxql_metadata_query'; |
|
||||||
|
|
||||||
export const useRetentionPolicies = (datasource: InfluxDatasource) => { |
|
||||||
const [retentionPolicies, setRetentionPolicies] = useState<string[]>([]); |
|
||||||
useEffect(() => { |
|
||||||
getAllPolicies(datasource).then((data) => { |
|
||||||
setRetentionPolicies(data); |
|
||||||
}); |
|
||||||
}, [datasource]); |
|
||||||
|
|
||||||
return { retentionPolicies }; |
|
||||||
}; |
|
Loading…
Reference in new issue