Skip to content

Commit a6a1944

Browse files
authored
fix(ci): Integration test improvements (#41)
* Support for running against local copy of YAML tests * Add a skipped test * Use correct file path 🤦
1 parent db1074c commit a6a1944

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

scripts/download-artifacts.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const fetch = require('node-fetch')
2626
const crossZip = require('cross-zip')
2727
const ora = require('ora')
2828

29-
const { mkdir } = promises
29+
const { mkdir, cp } = promises
3030
const pipeline = promisify(stream.pipeline)
3131
const unzip = promisify(crossZip.unzip)
3232

@@ -35,7 +35,7 @@ const zipFile = join(__dirname, '..', 'serverless-clients-tests.zip')
3535

3636
const specFolder = join(__dirname, '..', 'rest-api-spec')
3737

38-
async function downloadArtifacts () {
38+
async function downloadArtifacts (localTests) {
3939
const log = ora('Checking out spec and test').start()
4040

4141
const { GITHUB_TOKEN } = process.env
@@ -46,31 +46,36 @@ async function downloadArtifacts () {
4646

4747
log.text = 'Fetching test YAML files'
4848

49-
if (!GITHUB_TOKEN) {
50-
log.fail("Missing required environment variable 'GITHUB_TOKEN'")
51-
process.exit(1)
52-
}
53-
54-
let response = await fetch('https://api.github.com/repos/elastic/serverless-clients-tests/zipball/main', {
55-
headers: {
56-
Authorization: `Bearer ${GITHUB_TOKEN}`,
57-
Accept: "application/vnd.github+json",
49+
if (localTests) {
50+
log.text = `Copying local tests from ${localTests}`
51+
await cp(localTests, testYamlFolder, { recursive: true })
52+
} else {
53+
if (!GITHUB_TOKEN) {
54+
log.fail("Missing required environment variable 'GITHUB_TOKEN'")
55+
process.exit(1)
5856
}
59-
})
6057

61-
if (!response.ok) {
62-
log.fail(`unexpected response ${response.statusText}`)
63-
process.exit(1)
64-
}
58+
let response = await fetch('https://api.github.com/repos/elastic/serverless-clients-tests/zipball/main', {
59+
headers: {
60+
Authorization: `Bearer ${GITHUB_TOKEN}`,
61+
Accept: "application/vnd.github+json",
62+
}
63+
})
6564

66-
log.text = 'Downloading tests zipball'
67-
await pipeline(response.body, createWriteStream(zipFile))
65+
if (!response.ok) {
66+
log.fail(`unexpected response ${response.statusText}`)
67+
process.exit(1)
68+
}
6869

69-
log.text = 'Unzipping tests'
70-
await unzip(zipFile, testYamlFolder)
70+
log.text = 'Downloading tests zipball'
71+
await pipeline(response.body, createWriteStream(zipFile))
7172

72-
log.text = 'Cleanup'
73-
await rimraf(zipFile)
73+
log.text = 'Unzipping tests'
74+
await unzip(zipFile, testYamlFolder)
75+
76+
log.text = 'Cleanup'
77+
await rimraf(zipFile)
78+
}
7479

7580
log.text = 'Fetching Elasticsearch spec info'
7681
await rimraf(specFolder)

test/integration/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const MAX_TEST_TIME = 1000 * 60
4242

4343
const options = minimist(process.argv.slice(2), {
4444
boolean: ['bail'],
45-
string: ['suite', 'test'],
45+
string: ['suite', 'test', 'local'],
4646
})
4747

4848
const skips = {
@@ -54,7 +54,10 @@ const skips = {
5454
'transform/10_basic.yml': ['*'],
5555
// TODO: scripts_painless_execute expects {"result":"0.1"}, gets {"result":"0"}
5656
// body sent as Buffer, unsure if related
57-
'script/10_basic.yml': ['*']
57+
'script/10_basic.yml': ['*'],
58+
// TODO: expects {"outlier_detection.auc_roc.value":0.99995}, gets {"outlier_detection.auc_roc.value":0.5}
59+
// remove if/when https://github.com/elastic/serverless-clients-tests/issues/37 is resolved
60+
'machine_learning/data_frame_evaluate.yml': ['*'],
5861
}
5962

6063
const shouldSkip = (file, name) => {
@@ -105,7 +108,7 @@ function runner (opts = {}) {
105108

106109
async function start ({ client }) {
107110
log(`Downloading YAML test artifacts...`)
108-
await downloadArtifacts()
111+
await downloadArtifacts(options.local)
109112

110113
log(`Testing serverless API...`)
111114
const junit = createJunitReporter()

0 commit comments

Comments
 (0)