Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Update ES archive for tests #106837

Merged
merged 9 commits into from
Jul 27, 2021
Binary file not shown.
5,382 changes: 4,352 additions & 1,030 deletions x-pack/plugins/apm/ftr_e2e/cypress/fixtures/es_archiver/apm_8.0.0/mappings.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* 2.0.
*/

/* eslint-disable import/no-default-export*/
export default {
/* eslint-disable-next-line*/
export default {
'apm_8.0.0': {
start: '2020-12-08T13:57:56.135Z',
end: '2020-12-08T14:27:56.135Z',
start: '2021-07-27T08:08:11.069Z',
end: '2021-07-27T08:38:11.069Z',
},
};
43 changes: 28 additions & 15 deletions x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ async function run() {
bool: {
must_not: [
{
term: {
'service.name': 'elastic-co-frontend',
terms: {
'service.name': [
'elastic-co-frontend',
'filebeat',
'metricbeat',
'heartbeat',
'apm-server',
],
},
},
],
Expand Down Expand Up @@ -153,15 +159,22 @@ async function run() {
(bucket) => bucket.key as string
) ?? [];

const indicesToArchive = indicesWithDocs
.filter((index) => !index.startsWith('.kibana'))
.concat('.kibana')
.join(',');

console.log({
indicesToArchive,
});

// create the archive
const tmpDir = path.join(__dirname, 'tmp/');
execSync(
`node scripts/es_archiver save ${archiveName} ${indicesWithDocs
.filter((index) => !index.startsWith('.kibana'))
.concat('.kibana')
.join(
','
)} --dir=${tmpDir} --kibana-url=${kibanaUrl} --es-url=${esUrl} --query='${JSON.stringify(
`node scripts/es_archiver save ${path.join(
tmpDir,
archiveName
)} ${indicesToArchive} --kibana-url=${kibanaUrl} --es-url=${esUrl} --query='${JSON.stringify(
query
)}'`,
{
Expand Down Expand Up @@ -192,17 +205,11 @@ async function run() {
fs.writeFileSync(
configFilePath,
`
/* eslint-disable import/no-default-export*/
/* eslint-disable-next-line*/
export default ${JSON.stringify(newConfig, null, 2)}`,
{ encoding: 'utf-8' }
);

// run ESLint on the generated metadata files
execSync('node scripts/eslint **/*/archives_metadata.ts --fix', {
cwd: root,
stdio: 'inherit',
});

const esArchiverDir = 'fixtures/es_archiver/';

const apiIntegrationDir = path.join(
Expand All @@ -220,6 +227,12 @@ async function run() {

// Delete tmp folder
execSync(`rm -rf ${tmpDir}`);

// run ESLint on the generated metadata files
execSync('node scripts/eslint x-pack/**/*/archives_metadata.ts --fix', {
cwd: root,
stdio: 'inherit',
});
}

run()
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/apm/scripts/shared/get_es_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ export function getEsClient({
auth,
});

const originalSearch = client.search.bind(client);

async function search<
TDocument = unknown,
TSearchRequest extends ESSearchRequest = ESSearchRequest
>(request: TSearchRequest) {
const response = await client.search<TDocument>(request);
const response = await originalSearch<TDocument>(request);

return {
...response,
Expand Down
2 changes: 2 additions & 0 deletions x-pack/test/apm_api_integration/common/apm_api_supertest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export function createApmApiSupertest(st: supertest.SuperTest<supertest.Test>) {
};
}

export type ApmApiSupertest = ReturnType<typeof createApmApiSupertest>;

export class ApmApiError extends Error {
res: request.Response;

Expand Down
Binary file not shown.
Loading