From fc96cc3e685f94285073c919e7fa309fa2e6abb2 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Thu, 3 Feb 2022 14:02:46 -0800 Subject: [PATCH] [Tests] configurable skip checksum verification (#1207) This enables configuring the skipping of checksum verification for integration and functional tests. The out-of-box experience enables tests to pull down an artifact of OpenSearch to run frontend tests against. However, if there was an issue with the publishing of the checksum, for example: https://github.com/opensearch-project/opensearch-build/issues/1497 Then any CI for OpenSearch Dashboards is severely blocked. This lets the out-of-box experience get around this. This shouldn't be used permenantly and should be toggled off when no longer blocked. Issue resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/1205 Signed-off-by: Kawika Avilla --- .github/workflows/pr_check_workflow.yml | 1 + packages/osd-opensearch/src/artifact.js | 9 ++++++++- packages/osd-opensearch/src/artifact.test.js | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_check_workflow.yml b/.github/workflows/pr_check_workflow.yml index 34db23d69eec..efe45a5c5ad5 100644 --- a/.github/workflows/pr_check_workflow.yml +++ b/.github/workflows/pr_check_workflow.yml @@ -18,6 +18,7 @@ env: TEST_OPENSEARCH_DASHBOARDS_PORT: 6610 TEST_OPENSEARCH_TRANSPORT_PORT: 9403 TEST_OPENSEARCH_PORT: 9400 + OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true jobs: build-lint-test: diff --git a/packages/osd-opensearch/src/artifact.js b/packages/osd-opensearch/src/artifact.js index cc1f7a9c8ea6..e57987f2af1c 100644 --- a/packages/osd-opensearch/src/artifact.js +++ b/packages/osd-opensearch/src/artifact.js @@ -89,6 +89,11 @@ function shouldUseUnverifiedSnapshot() { return !!process.env.OSD_OPENSEARCH_SNAPSHOT_USE_UNVERIFIED; } +// Setting this flag provides an easy way to skip comparing the checksum +function skipVerifyChecksum() { + return !!process.env.OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM; +} + async function fetchSnapshotManifest(url, log) { log.info('Downloading snapshot manifest from %s', chalk.bold(url)); @@ -327,7 +332,9 @@ exports.Artifact = class Artifact { return; } - await this._verifyChecksum(artifactResp); + if (!skipVerifyChecksum()) { + await this._verifyChecksum(artifactResp); + } // cache the etag for future downloads cache.writeMeta(dest, { etag: artifactResp.etag }); diff --git a/packages/osd-opensearch/src/artifact.test.js b/packages/osd-opensearch/src/artifact.test.js index 5deddaf8e52a..2711f942bf1b 100644 --- a/packages/osd-opensearch/src/artifact.test.js +++ b/packages/osd-opensearch/src/artifact.test.js @@ -77,6 +77,7 @@ const previousEnvVars = {}; const ENV_VARS_TO_RESET = [ 'OPENSEARCH_SNAPSHOT_MANIFEST', 'OSD_OPENSEARCH_SNAPSHOT_USE_UNVERIFIED', + 'OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM', ]; beforeAll(() => {