Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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