Skip to content

Commit

Permalink
[APM] Always load esarchives from common (#77139) (#77291)
Browse files Browse the repository at this point in the history
# Conflicts:
#	x-pack/test/apm_api_integration/common/fixtures/es_archiver/ml_8.0.0/data.json.gz
#	x-pack/test/apm_api_integration/common/fixtures/es_archiver/ml_8.0.0/mappings.json

Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
  • Loading branch information
cauemarcondes and dgieselaar committed Sep 13, 2020
1 parent 037a63d commit 00737fe
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 89,130 deletions.
86 changes: 25 additions & 61 deletions x-pack/plugins/apm/scripts/create-functional-tests-archive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -98,67 +99,30 @@ async function run() {
}
);

const targetDirs = ['trial', 'basic'];

// copy the archives to the test fixtures

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
);

if (!fs.existsSync(targetArchivesPath)) {
fs.mkdirSync(targetArchivesPath);
}

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' }
);
})
);
const currentConfig = {};

// get the current metadata and extend/override metadata for the new archive
const configFilePath = path.join(commonDir, 'archives_metadata.ts');

try {
Object.assign(currentConfig, (await import(configFilePath)).default);
} catch (error) {
// do nothing
}

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);
const newConfig = {
...currentConfig,
[archiveName]: {
start: gte,
end: lt,
},
};

fs.writeFileSync(
configFilePath,
`export default ${JSON.stringify(newConfig, null, 2)}`,
{ encoding: 'utf-8' }
);

// run ESLint on the generated metadata files

Expand Down
Binary file not shown.
Loading

0 comments on commit 00737fe

Please sign in to comment.