From 547d3f8f6b5f7cc16418dca7eb705b3fd58c9e14 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 29 Feb 2024 11:19:01 -0600 Subject: [PATCH 1/3] Support for running against local copy of YAML tests --- scripts/download-artifacts.js | 49 +++++++++++++++++++---------------- test/integration/index.js | 4 +-- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/scripts/download-artifacts.js b/scripts/download-artifacts.js index cd6687a..ab80c1a 100644 --- a/scripts/download-artifacts.js +++ b/scripts/download-artifacts.js @@ -26,7 +26,7 @@ const fetch = require('node-fetch') const crossZip = require('cross-zip') const ora = require('ora') -const { mkdir } = promises +const { mkdir, cp } = promises const pipeline = promisify(stream.pipeline) const unzip = promisify(crossZip.unzip) @@ -35,7 +35,7 @@ const zipFile = join(__dirname, '..', 'serverless-clients-tests.zip') const specFolder = join(__dirname, '..', 'rest-api-spec') -async function downloadArtifacts () { +async function downloadArtifacts (localTests) { const log = ora('Checking out spec and test').start() const { GITHUB_TOKEN } = process.env @@ -46,31 +46,36 @@ async function downloadArtifacts () { log.text = 'Fetching test YAML files' - if (!GITHUB_TOKEN) { - log.fail("Missing required environment variable 'GITHUB_TOKEN'") - process.exit(1) - } - - let response = await fetch('https://api.github.com/repos/elastic/serverless-clients-tests/zipball/main', { - headers: { - Authorization: `Bearer ${GITHUB_TOKEN}`, - Accept: "application/vnd.github+json", + if (localTests) { + log.text = `Copying local tests from ${localTests}` + await cp(localTests, testYamlFolder, { recursive: true }) + } else { + if (!GITHUB_TOKEN) { + log.fail("Missing required environment variable 'GITHUB_TOKEN'") + process.exit(1) } - }) - if (!response.ok) { - log.fail(`unexpected response ${response.statusText}`) - process.exit(1) - } + let response = await fetch('https://api.github.com/repos/elastic/serverless-clients-tests/zipball/main', { + headers: { + Authorization: `Bearer ${GITHUB_TOKEN}`, + Accept: "application/vnd.github+json", + } + }) - log.text = 'Downloading tests zipball' - await pipeline(response.body, createWriteStream(zipFile)) + if (!response.ok) { + log.fail(`unexpected response ${response.statusText}`) + process.exit(1) + } - log.text = 'Unzipping tests' - await unzip(zipFile, testYamlFolder) + log.text = 'Downloading tests zipball' + await pipeline(response.body, createWriteStream(zipFile)) - log.text = 'Cleanup' - await rimraf(zipFile) + log.text = 'Unzipping tests' + await unzip(zipFile, testYamlFolder) + + log.text = 'Cleanup' + await rimraf(zipFile) + } log.text = 'Fetching Elasticsearch spec info' await rimraf(specFolder) diff --git a/test/integration/index.js b/test/integration/index.js index 28ec425..ba5fcdd 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -42,7 +42,7 @@ const MAX_TEST_TIME = 1000 * 60 const options = minimist(process.argv.slice(2), { boolean: ['bail'], - string: ['suite', 'test'], + string: ['suite', 'test', 'local'], }) const skips = { @@ -105,7 +105,7 @@ function runner (opts = {}) { async function start ({ client }) { log(`Downloading YAML test artifacts...`) - await downloadArtifacts() + await downloadArtifacts(options.local) log(`Testing serverless API...`) const junit = createJunitReporter() From c7d1f9bc4e2391bee164fd5b3836306ffdf49e07 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 29 Feb 2024 11:19:52 -0600 Subject: [PATCH 2/3] Add a skipped test --- test/integration/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/integration/index.js b/test/integration/index.js index ba5fcdd..fc1e75b 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -54,7 +54,10 @@ const skips = { 'transform/10_basic.yml': ['*'], // TODO: scripts_painless_execute expects {"result":"0.1"}, gets {"result":"0"} // body sent as Buffer, unsure if related - 'script/10_basic.yml': ['*'] + 'script/10_basic.yml': ['*'], + // TODO: expects {"outlier_detection.auc_roc.value":0.99995}, gets {"outlier_detection.auc_roc.value":0.5} + // remove if/when https://github.com/elastic/serverless-clients-tests/issues/37 is resolved + 'machine_learning/start_stop_datafeed.yml': ['*'], } const shouldSkip = (file, name) => { From 3f2218263186448966a272201128e830360872e4 Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Thu, 29 Feb 2024 11:29:59 -0600 Subject: [PATCH 3/3] Use correct file path :facepalm: --- test/integration/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/index.js b/test/integration/index.js index fc1e75b..0cd89ca 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -57,7 +57,7 @@ const skips = { 'script/10_basic.yml': ['*'], // TODO: expects {"outlier_detection.auc_roc.value":0.99995}, gets {"outlier_detection.auc_roc.value":0.5} // remove if/when https://github.com/elastic/serverless-clients-tests/issues/37 is resolved - 'machine_learning/start_stop_datafeed.yml': ['*'], + 'machine_learning/data_frame_evaluate.yml': ['*'], } const shouldSkip = (file, name) => {