Skip to content

Commit

Permalink
[APM] Always load esarchives from common (#77139)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar authored Sep 10, 2020
1 parent 524f30a commit 0f249d7
Show file tree
Hide file tree
Showing 20 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 0f249d7

Please sign in to comment.