Skip to content

Commit

Permalink
[APM] Update ES archive for tests (#106837)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar authored Jul 27, 2021
1 parent 566c16a commit 0d5d453
Show file tree
Hide file tree
Showing 49 changed files with 12,701 additions and 6,780 deletions.
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',
},
};
39 changes: 24 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,18 @@ async function run() {
(bucket) => bucket.key as string
) ?? [];

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

// 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 +201,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 +223,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

0 comments on commit 0d5d453

Please sign in to comment.