Skip to content

Commit

Permalink
Merge branch '7.16' into infra-ui-add-missing-deprecation-levels
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Nov 9, 2021
2 parents 88db9a1 + 0338110 commit 9039c09
Show file tree
Hide file tree
Showing 340 changed files with 5,783 additions and 4,471 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,5 +268,8 @@ readonly links: {
readonly rubyOverview: string;
readonly rustGuide: string;
};
readonly endpoints: {
readonly troubleshooting: string;
};
};
```

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace",
"@elastic/apm-rum": "^5.9.1",
"@elastic/apm-rum-react": "^1.3.1",
"@elastic/charts": "38.0.2",
"@elastic/charts": "38.0.3",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^7.16.0-canary.7",
"@elastic/ems-client": "7.16.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export async function cleanWriteTargets({
index: targets,
allow_no_indices: true,
conflicts: 'proceed',
refresh: true,
body: {
query: {
match_all: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,33 @@ export class FunctionalTestRunner {
// replace the function of custom service providers so that they return
// promise-like objects which never resolve, essentially disabling them
// allowing us to load the test files and populate the mocha suites
const readStubbedProviderSpec = (type: string, providers: any) =>
const readStubbedProviderSpec = (type: string, providers: any, skip: string[]) =>
readProviderSpec(type, providers).map((p) => ({
...p,
fn: () => ({
then: () => {},
}),
fn: skip.includes(p.name)
? (...args: unknown[]) => {
const result = p.fn(...args);
if ('then' in result) {
throw new Error(
`Provider [${p.name}] returns a promise so it can't loaded during test analysis`
);
}

return result;
}
: () => ({
then: () => {},
}),
}));

const providers = new ProviderCollection(this.log, [
...coreProviders,
...readStubbedProviderSpec('Service', config.get('services')),
...readStubbedProviderSpec('PageObject', config.get('pageObjects')),
...readStubbedProviderSpec(
'Service',
config.get('services'),
config.get('servicesRequiredForTestAnalysis')
),
...readStubbedProviderSpec('PageObject', config.get('pageObjects'), []),
]);

const mocha = await setupMocha(this.lifecycle, this.log, config, providers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const schema = Joi.object()
})
.default(),

servicesRequiredForTestAnalysis: Joi.array().items(Joi.string()).default([]),
services: Joi.object().pattern(ID_PATTERN, Joi.func().required()).default(),

pageObjects: Joi.object().pattern(ID_PATTERN, Joi.func().required()).default(),
Expand Down
2 changes: 1 addition & 1 deletion scripts/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*/

require('../src/setup_node_env');
require('../src/docs/cli');
require('../src/dev/run_build_docs_cli').runBuildDocsCli();
6 changes: 6 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ export class DocLinksService {
rubyOverview: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/ruby-api/${DOC_LINK_VERSION}/ruby_client.html`,
rustGuide: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/rust-api/current/index.html`,
},
endpoints: {
troubleshooting: `${ELASTIC_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/ts-management.html#ts-endpoints`,
},
},
});
}
Expand Down Expand Up @@ -786,5 +789,8 @@ export interface DocLinksStart {
readonly rubyOverview: string;
readonly rustGuide: string;
};
readonly endpoints: {
readonly troubleshooting: string;
};
};
}
3 changes: 3 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@ export interface DocLinksStart {
readonly rubyOverview: string;
readonly rustGuide: string;
};
readonly endpoints: {
readonly troubleshooting: string;
};
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ export const cloneIndex = ({
// If the cluster state was updated and all shards ackd we're done
return TaskEither.right(res);
} else {
// Otherwise, wait until the target index has a 'green' status.
// Otherwise, wait until the target index has a 'yellow' status.
return pipe(
waitForIndexStatusYellow({ client, index: target, timeout }),
TaskEither.map((value) => {
/** When the index status is 'green' we know that all shards were started */
/** When the index status is 'yellow' we know that all shards were started */
return { acknowledged: true, shardsAcknowledged: true };
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,15 @@ describe('migration actions', () => {
timeout: '0s',
})();

await expect(cloneIndexPromise).resolves.toMatchObject({
_tag: 'Left',
left: {
error: expect.any(ResponseError),
message: expect.stringMatching(/\"timed_out\":true/),
type: 'retryable_es_client_error',
},
});
await expect(cloneIndexPromise).resolves.toMatchInlineSnapshot(`
Object {
"_tag": "Left",
"left": Object {
"message": "Timeout waiting for the status of the [clone_red_index] index to become 'yellow'",
"type": "retryable_es_client_error",
},
}
`);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,20 @@ export const waitForIndexStatusYellow =
}: WaitForIndexStatusYellowParams): TaskEither.TaskEither<RetryableEsClientError, {}> =>
() => {
return client.cluster
.health({ index, wait_for_status: 'yellow', timeout })
.then(() => {
.health({
index,
wait_for_status: 'yellow',
timeout,
// @ts-expect-error
return_200_for_cluster_health_timeout: true, // opt-in to the 8.0 breaking behaviour to prevent a deprecation log
})
.then((res) => {
if (res.body.timed_out === true) {
return Either.left({
type: 'retryable_es_client_error' as const,
message: `Timeout waiting for the status of the [${index}] index to become 'yellow'`,
});
}
return Either.right({});
})
.catch(catchRetryableEsClientErrors);
Expand Down
64 changes: 64 additions & 0 deletions src/dev/run_build_docs_cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import Path from 'path';

import dedent from 'dedent';
import { run, REPO_ROOT, createFailError } from '@kbn/dev-utils';

const DEFAULT_DOC_REPO_PATH = Path.resolve(REPO_ROOT, '..', 'docs');

const rel = (path: string) => Path.relative(process.cwd(), path);

export function runBuildDocsCli() {
run(
async ({ flags, procRunner }) => {
const docRepoPath =
typeof flags.docrepo === 'string' && flags.docrepo
? Path.resolve(process.cwd(), flags.docrepo)
: DEFAULT_DOC_REPO_PATH;

try {
await procRunner.run('build_docs', {
cmd: rel(Path.resolve(docRepoPath, 'build_docs')),
args: [
['--doc', rel(Path.resolve(REPO_ROOT, 'docs/index.asciidoc'))],
['--chunk', '1'],
flags.open ? ['--open'] : [],
].flat(),
cwd: REPO_ROOT,
wait: true,
});
} catch (error) {
if (error.code === 'ENOENT') {
throw createFailError(dedent`
Unable to run "build_docs" script from docs repo.
Does it exist at [${rel(docRepoPath)}]?
Do you need to pass --docrepo to specify the correct path or clone it there?
`);
}

throw error;
}
},
{
description: 'Build the docs and serve them from a docker container',
flags: {
string: ['docrepo'],
boolean: ['open'],
default: {
docrepo: DEFAULT_DOC_REPO_PATH,
},
help: `
--docrepo [path] Path to the doc repo, defaults to ${rel(DEFAULT_DOC_REPO_PATH)}
--open Automatically open the built docs in your default browser after building
`,
},
}
);
}
30 changes: 0 additions & 30 deletions src/docs/cli.js

This file was deleted.

28 changes: 0 additions & 28 deletions src/docs/docs_repo.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,29 @@ export const ContextApp = ({ indexPattern, anchorId }: ContextAppProps) => {
/**
* Context fetched state
*/
const { fetchedState, fetchContextRows, fetchAllRows, fetchSurroundingRows } = useContextAppFetch(
{
const { fetchedState, fetchContextRows, fetchAllRows, fetchSurroundingRows, resetFetchedState } =
useContextAppFetch({
anchorId,
indexPattern,
appState,
useNewFieldsApi,
services,
});
/**
* Reset state when anchor changes
*/
useEffect(() => {
if (prevAppState.current) {
prevAppState.current = undefined;
resetFetchedState();
}
);
}, [anchorId, resetFetchedState]);

/**
* Fetch docs on ui changes
*/
useEffect(() => {
if (!prevAppState.current || fetchedState.anchor._id !== anchorId) {
if (!prevAppState.current) {
fetchAllRows();
} else if (prevAppState.current.predecessorCount !== appState.predecessorCount) {
fetchSurroundingRows(SurrDocType.PREDECESSORS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,19 @@ export function useContextAppFetch({
[fetchSurroundingRows]
);

const fetchAllRows = useCallback(
() => fetchAnchorRow().then((anchor) => anchor && fetchContextRows(anchor)),
[fetchAnchorRow, fetchContextRows]
);
const fetchAllRows = useCallback(() => {
fetchAnchorRow().then((anchor) => anchor && fetchContextRows(anchor));
}, [fetchAnchorRow, fetchContextRows]);

const resetFetchedState = useCallback(() => {
setFetchedState(getInitialContextQueryState());
}, []);

return {
fetchedState,
fetchAllRows,
fetchContextRows,
fetchSurroundingRows,
resetFetchedState,
};
}
Loading

0 comments on commit 9039c09

Please sign in to comment.