mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
This commit is contained in:
parent
081166bb27
commit
a499452f20
2 changed files with 12 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
import fetch from 'node-fetch';
|
||||
import pRetry from 'p-retry';
|
||||
|
||||
import { REPO_ROOT } from '@kbn/repo-info';
|
||||
import { ToolingLog } from '@kbn/tooling-log';
|
||||
|
@ -14,6 +15,7 @@ import { FetchAgentVersionsList } from './fetch_agent_versions_list';
|
|||
import { Build, Config, write } from '../lib';
|
||||
|
||||
jest.mock('node-fetch');
|
||||
jest.mock('p-retry');
|
||||
jest.mock('../lib');
|
||||
|
||||
const config = new Config(
|
||||
|
@ -44,9 +46,14 @@ const config = new Config(
|
|||
);
|
||||
|
||||
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
|
||||
const mockedPRetry = pRetry as jest.MockedFunction<typeof pRetry>;
|
||||
const mockedWrite = write as jest.MockedFunction<typeof write>;
|
||||
const mockedBuild = new Build(config);
|
||||
|
||||
mockedPRetry.mockImplementation((fn: any) => {
|
||||
return fn();
|
||||
});
|
||||
|
||||
const processEnv = process.env;
|
||||
|
||||
describe('FetchAgentVersionsList', () => {
|
||||
|
|
|
@ -7,10 +7,14 @@
|
|||
*/
|
||||
|
||||
import fetch from 'node-fetch';
|
||||
import pRetry from 'p-retry';
|
||||
|
||||
import { ToolingLog } from '@kbn/tooling-log';
|
||||
import { write, Task } from '../lib';
|
||||
|
||||
// Endpoint maintained by the web-team and hosted on the elastic website
|
||||
const PRODUCT_VERSIONS_URL = 'https://www.elastic.co/api/product_versions';
|
||||
|
||||
const isPr = () =>
|
||||
!!process.env.BUILDKITE_PULL_REQUEST && process.env.BUILDKITE_PULL_REQUEST !== 'false';
|
||||
|
||||
|
@ -20,13 +24,10 @@ const getAvailableVersions = async (log: ToolingLog) => {
|
|||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
// Endpoint maintained by the web-team and hosted on the elastic website
|
||||
// See https://github.com/elastic/website-development/issues/9331
|
||||
const url = 'https://www.elastic.co/content/product_versions';
|
||||
log.info('Fetching Elastic Agent versions list');
|
||||
|
||||
try {
|
||||
const results = await fetch(url, options);
|
||||
const results = await pRetry(() => fetch(PRODUCT_VERSIONS_URL, options), { retries: 3 });
|
||||
const rawBody = await results.text();
|
||||
|
||||
if (results.status >= 400) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue