Skip to content

Commit

Permalink
[1.x][Tests] ARM64 artifacts for testing (#668)
Browse files Browse the repository at this point in the history
Removing the graceful failures for ARM64 snapshot testing and
updating tests.

Previously, snapshots for ARM64 were not available but now they are
so this allows developers to run tests for that arch out of the box
whereas before they had to set the snapshot manually.

Partially resolves:
#475

Backport PR:
#641

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla authored Jul 28, 2021
1 parent c93fc56 commit bf4316c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
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

0 comments on commit bf4316c

Please sign in to comment.