Skip to content

Commit

Permalink
Update script
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Sep 10, 2020
1 parent f65f352 commit 7a08441
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 76 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
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 0 additions & 12 deletions x-pack/test/apm_api_integration/trial/archives_metadata.ts

This file was deleted.

0 comments on commit 7a08441

Please sign in to comment.