[APM] Always load esarchives from common (#77139)

This commit is contained in:
Dario Gieselaar 2020-09-10 12:55:21 +02:00 committed by GitHub
parent 524f30a2ec
commit 0f249d7383
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 37 additions and 89126 deletions

View file

@ -83,8 +83,9 @@ async function run() {
},
};
const archivesDir = path.join(__dirname, '.archives');
const root = path.join(__dirname, '../../../../..');
const commonDir = path.join(root, 'x-pack/test/apm_api_integration/common');
const archivesDir = path.join(commonDir, 'fixtures/es_archiver');
// create the archive
@ -98,68 +99,31 @@ async function run() {
}
);
const targetDirs = ['trial', 'basic'];
const currentConfig = {};
// copy the archives to the test fixtures
// get the current metadata and extend/override metadata for the new archive
const configFilePath = path.join(commonDir, 'archives_metadata.ts');
await Promise.all(
targetDirs.map(async (target) => {
const targetPath = path.resolve(
__dirname,
'../../../../test/apm_api_integration/',
target
);
const targetArchivesPath = path.resolve(
targetPath,
'fixtures/es_archiver',
archiveName
);
try {
Object.assign(currentConfig, (await import(configFilePath)).default);
} catch (error) {
// do nothing
}
if (!fs.existsSync(targetArchivesPath)) {
fs.mkdirSync(targetArchivesPath);
}
const newConfig = {
...currentConfig,
[archiveName]: {
start: gte,
end: lt,
},
};
fs.copyFileSync(
path.join(archivesDir, archiveName, 'data.json.gz'),
path.join(targetArchivesPath, 'data.json.gz')
);
fs.copyFileSync(
path.join(archivesDir, archiveName, 'mappings.json'),
path.join(targetArchivesPath, 'mappings.json')
);
const currentConfig = {};
// get the current metadata and extend/override metadata for the new archive
const configFilePath = path.join(targetPath, 'archives_metadata.ts');
try {
Object.assign(currentConfig, (await import(configFilePath)).default);
} catch (error) {
// do nothing
}
const newConfig = {
...currentConfig,
[archiveName]: {
start: gte,
end: lt,
},
};
fs.writeFileSync(
configFilePath,
`export default ${JSON.stringify(newConfig, null, 2)}`,
{ encoding: 'utf-8' }
);
})
fs.writeFileSync(
configFilePath,
`export default ${JSON.stringify(newConfig, null, 2)}`,
{ encoding: 'utf-8' }
);
fs.unlinkSync(path.join(archivesDir, archiveName, 'data.json.gz'));
fs.unlinkSync(path.join(archivesDir, archiveName, 'mappings.json'));
fs.rmdirSync(path.join(archivesDir, archiveName));
fs.rmdirSync(archivesDir);
// run ESLint on the generated metadata files
execSync('node scripts/eslint **/*/archives_metadata.ts --fix', {

View file

@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import archives from '../../archives_metadata';
import archives from '../../../common/archives_metadata';
export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');

View file

@ -6,7 +6,7 @@
export default {
'apm_8.0.0': {
start: '2020-09-09T06:11:22.998Z',
end: '2020-09-09T06:41:22.998Z',
start: '2020-09-10T08:07:13.274Z',
end: '2020-09-10T08:37:13.274Z',
},
};

View file

@ -7,6 +7,7 @@
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
import supertestAsPromised from 'supertest-as-promised';
import { format, UrlObject } from 'url';
import path from 'path';
import { InheritedFtrProviderContext, InheritedServices } from './ftr_provider_context';
import { PromiseReturnType } from '../../../plugins/apm/typings/common';
import { createApmUser, APM_TEST_PASSWORD, ApmUser } from './authentication';
@ -33,7 +34,7 @@ const supertestAsApmUser = (kibanaServer: UrlObject, apmUser: ApmUser) => async
return supertestAsPromised(url);
};
export function createTestConfig<T extends Settings>(settings: T) {
export function createTestConfig(settings: Settings) {
const { testFiles, license, name } = settings;
return async ({ readConfigFile }: FtrConfigProviderContext) => {
@ -49,6 +50,9 @@ export function createTestConfig<T extends Settings>(settings: T) {
return {
testFiles,
servers,
esArchiver: {
directory: path.resolve(__dirname, './fixtures/es_archiver'),
},
services: {
...services,
supertest: supertestAsApmReadUser,

View file

@ -62937,6 +62937,14 @@
"scaling_factor": 1000000,
"type": "scaled_float"
},
"firstContentfulPaint": {
"scaling_factor": 1000000,
"type": "scaled_float"
},
"largestContentfulPaint": {
"scaling_factor": 1000000,
"type": "scaled_float"
},
"timeToFirstByte": {
"scaling_factor": 1000000,
"type": "scaled_float"

View file

@ -1,12 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
export default {
'apm_8.0.0': {
start: '2020-09-09T06:11:22.998Z',
end: '2020-09-09T06:41:22.998Z',
},
};