Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] ARM64 artifacts for testing #641

Merged
merged 1 commit into from
Jul 13, 2021
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
4 changes: 2 additions & 2 deletions packages/osd-opensearch/src/artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ async function getArtifactSpecForSnapshotFromUrl(urlVersion, log) {
// issue: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/475
const platform = process.platform === 'win32' ? 'windows' : process.platform;
const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
if (platform !== 'linux' || arch !== 'x64') {
throw createCliError(`Snapshots are only available for Linux x64`);
if (platform !== 'linux') {
throw createCliError(`Snapshots are only available for Linux`);
}

const latestUrl = `${DAILY_SNAPSHOTS_BASE_URL}/${desiredVersion}`;
Expand Down
34 changes: 22 additions & 12 deletions packages/osd-opensearch/src/artifact.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ const PLATFORM = process.platform === 'win32' ? 'windows' : process.platform;
const ARCHITECTURE = process.arch === 'arm64' ? 'arm64' : 'x64';
const MOCK_VERSION = 'test-version';
const MOCK_RC_VERSION = `test-version-rc4`;
const MOCK_FILENAME = 'opensearch-test-version-SNAPSHOT-linux-x64-latest.tar.gz';
const MOCK_RC_FILENAME = `opensearch-test-version-rc4-SNAPSHOT-linux-x64-latest.tar.gz`;
const MOCK_FILENAME = `opensearch-test-version-SNAPSHOT-linux-${ARCHITECTURE}-latest.tar.gz`;
const MOCK_RC_FILENAME = `opensearch-test-version-rc4-SNAPSHOT-linux-${ARCHITECTURE}-latest.tar.gz`;
const MOCK_URL = `${DAILY_SNAPSHOT_BASE_URL}/${MOCK_VERSION}/${MOCK_FILENAME}`;
const MOCK_RC_URL = `${DAILY_SNAPSHOT_BASE_URL}/${MOCK_RC_VERSION}/${MOCK_RC_FILENAME}`;

const itif = process.platform === 'linux' && process.arch === 'x64' ? it : it.skip;
const itif = process.platform === 'linux' ? it : it.skip;

const createArchive = (params = {}) => {
const architecture = params.architecture || ARCHITECTURE;
Expand Down Expand Up @@ -106,6 +106,7 @@ beforeEach(() => {
},
multipleArch: {
archives: [
createArchive({ architecture: 'arm64', useRCVersion: false }),
createArchive({ architecture: 'fake_arch', useRCVersion: false }),
createArchive({ architecture: ARCHITECTURE, useRCVersion: false }),
],
Expand Down Expand Up @@ -164,21 +165,30 @@ describe('Artifact', () => {
});

it('should throw when on a non-Linux platform', async () => {
Object.defineProperty(process, 'platform', {
value: 'win32',
Object.defineProperties(process, {
platform: {
value: 'win32',
},
arch: {
value: ORIGINAL_ARCHITECTURE,
},
});
await expect(Artifact.getSnapshot('default', 'INVALID_PLATFORM', log)).rejects.toThrow(
'Snapshots are only available for Linux x64'
'Snapshots are only available for Linux'
);
});

it('should throw when on a non-x64 arch', async () => {
Object.defineProperty(process, 'arch', {
value: 'arm64',
it('should not throw when on a non-x64 arch', async () => {
Object.defineProperties(process, {
platform: {
value: ORIGINAL_PLATFROM,
},
arch: {
value: 'arm64',
},
});
await expect(Artifact.getSnapshot('default', 'INVALID_ARCH', log)).rejects.toThrow(
'Snapshots are only available for Linux x64'
);
mockFetch(MOCKS.multipleArch[0]);
artifactTest();
});
});

Expand Down