mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
kbn-es: Support choosing the correct architecture (#61096)
This commit is contained in:
parent
676a03d8c5
commit
6950c260ef
2 changed files with 26 additions and 3 deletions
|
@ -117,11 +117,14 @@ async function getArtifactSpecForSnapshot(urlVersion, license, log) {
|
|||
const manifest = JSON.parse(json);
|
||||
|
||||
const platform = process.platform === 'win32' ? 'windows' : process.platform;
|
||||
const arch = process.arch === 'arm64' ? 'aarch64' : 'x86_64';
|
||||
|
||||
const archive = manifest.archives.find(
|
||||
archive =>
|
||||
archive.version === desiredVersion &&
|
||||
archive.platform === platform &&
|
||||
archive.license === desiredLicense
|
||||
archive.license === desiredLicense &&
|
||||
archive.architecture === arch
|
||||
);
|
||||
|
||||
if (!archive) {
|
||||
|
|
|
@ -28,6 +28,7 @@ const log = new ToolingLog();
|
|||
let MOCKS;
|
||||
|
||||
const PLATFORM = process.platform === 'win32' ? 'windows' : process.platform;
|
||||
const ARCHITECTURE = process.arch === 'arm64' ? 'aarch64' : 'x86_64';
|
||||
const MOCK_VERSION = 'test-version';
|
||||
const MOCK_URL = 'http://127.0.0.1:12345';
|
||||
const MOCK_FILENAME = 'test-filename';
|
||||
|
@ -38,13 +39,15 @@ const PERMANENT_SNAPSHOT_BASE_URL =
|
|||
|
||||
const createArchive = (params = {}) => {
|
||||
const license = params.license || 'default';
|
||||
const architecture = params.architecture || ARCHITECTURE;
|
||||
|
||||
return {
|
||||
license: 'default',
|
||||
architecture,
|
||||
version: MOCK_VERSION,
|
||||
url: MOCK_URL + `/${license}`,
|
||||
platform: PLATFORM,
|
||||
filename: MOCK_FILENAME + `.${license}`,
|
||||
filename: MOCK_FILENAME + `-${architecture}.${license}`,
|
||||
...params,
|
||||
};
|
||||
};
|
||||
|
@ -77,6 +80,12 @@ beforeEach(() => {
|
|||
valid: {
|
||||
archives: [createArchive({ license: 'oss' }), createArchive({ license: 'default' })],
|
||||
},
|
||||
multipleArch: {
|
||||
archives: [
|
||||
createArchive({ architecture: 'fake_arch', license: 'oss' }),
|
||||
createArchive({ architecture: ARCHITECTURE, license: 'oss' }),
|
||||
],
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -95,7 +104,7 @@ const artifactTest = (requestedLicense, expectedLicense, fetchTimesCalled = 1) =
|
|||
expect(artifact.getUrl()).toEqual(MOCK_URL + `/${expectedLicense}`);
|
||||
expect(artifact.getChecksumUrl()).toEqual(MOCK_URL + `/${expectedLicense}.sha512`);
|
||||
expect(artifact.getChecksumType()).toEqual('sha512');
|
||||
expect(artifact.getFilename()).toEqual(MOCK_FILENAME + `.${expectedLicense}`);
|
||||
expect(artifact.getFilename()).toEqual(MOCK_FILENAME + `-${ARCHITECTURE}.${expectedLicense}`);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -153,6 +162,17 @@ describe('Artifact', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('with snapshots for multiple architectures', () => {
|
||||
beforeEach(() => {
|
||||
mockFetch(MOCKS.multipleArch);
|
||||
});
|
||||
|
||||
it('should return artifact metadata for the correct architecture', async () => {
|
||||
const artifact = await Artifact.getSnapshot('oss', MOCK_VERSION, log);
|
||||
expect(artifact.getFilename()).toEqual(MOCK_FILENAME + `-${ARCHITECTURE}.oss`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with custom snapshot manifest URL', () => {
|
||||
const CUSTOM_URL = 'http://www.creedthoughts.gov.www/creedthoughts';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue