Skip to content

Commit

Permalink
Merge branch 'main' into generates_main_code
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshMock authored May 6, 2024
2 parents 2d591ce + 445b36f commit e4e110e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .buildkite/create-serverless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export EC_PROJECT_NAME="$EC_PROJECT_PREFIX-$BUILDKITE_JOB_ID"

# fetch cloud creds used by qaf
CLOUD_ACCESS_KEY=$(vault read -field="$EC_ENV" "$CLOUD_CREDENTIALS_PATH")
echo "{\"api_key\":{\"$EC_ENV\":\"$CLOUD_ACCESS_KEY\"}}" > "$(pwd)/cloud.json"
echo "{\"api_key\":{\"$EC_ENV\":\"$CLOUD_ACCESS_KEY\"}}" >"$(pwd)/cloud.json"

run_qaf() {
cmd=$1
Expand Down
1 change: 1 addition & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ steps:
nodejs:
- "18"
- "20"
- "22"
env:
NODE_VERSION: "{{ matrix.nodejs }}"
EC_PROJECT_PREFIX: "elasticsearch-serverless-js-node{{ matrix.nodejs }}"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Detect files changed
runs-on: ubuntu-latest
outputs:
src-only: '${{ steps.changes.outputs.src-only }}'
src-only: "${{ steps.changes.outputs.src-only }}"
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter/@v2.11.1
Expand All @@ -28,7 +28,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:

strategy:
matrix:
node-version: [20.x]
node-version: [22.x]

steps:
- uses: actions/checkout@v4
Expand Down
23 changes: 18 additions & 5 deletions test/integration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ const skips = {
// TODO: expects {"outlier_detection.auc_roc.value":0.99995}, gets {"outlier_detection.auc_roc.value":0.5}
// remove if/when https://github.com/elastic/elasticsearch-clients-tests/issues/37 is resolved
'machine_learning/data_frame_evaluate.yml': ['*'],
// TODO: wait_for_active_shards and rollover with conditions are not supported on serverless
// see https://github.com/elastic/elasticsearch-clients-tests/issues/55
'indices/rollover.yml': ['*'],
// TODO: test runner needs to support ignoring 410 errors
'indices/data_lifecycle.yml': ['*'],
// TODO: test runner needs to support ignoring 410 errors
'enrich/10_basic.yml': ['*'],

}

const shouldSkip = (file, name) => {
Expand Down Expand Up @@ -132,9 +140,9 @@ async function start ({ client }) {
const fileTime = now()
const data = readFileSync(file, 'utf8')

// get the test yaml (as object), some file has multiple yaml documents inside,
// every document is separated by '---', so we split on the separator
// and then we remove the empty strings, finally we parse them
// get the test yaml as an object. files have multiple YAML documents inside,
// separated by '---', so we split on the separator and remove the empty strings
// before parsing them
const tests = data
.split('\n---\n')
.map(s => s.trim())
Expand All @@ -144,27 +152,32 @@ async function start ({ client }) {
// null values
.filter(Boolean)

// get setup and teardown if present
// get setup, teardown and requires rules if present
let setupTest = null
let teardownTest = null
let requires = null
for (const test of tests) {
if (test.setup) setupTest = test.setup
if (test.teardown) teardownTest = test.teardown
if (test.requires) requires = test.requires
}

const cleanPath = file.slice(file.lastIndexOf(apiName))

// skip if --suite CLI arg doesn't match
if (options.suite && !cleanPath.endsWith(options.suite)) continue

// skip if `requires.serverless` is not true
if (typeof requires === 'object' && requires.serverless != true) continue

const junitTestSuite = junitTestSuites.testsuite(apiName.slice(1) + ' - ' + cleanPath)

for (const test of tests) {
const testTime = now()
const name = Object.keys(test)[0]

// skip setups, teardowns and anything that doesn't match --test flag when present
if (name === 'setup' || name === 'teardown') continue
if (name === 'setup' || name === 'teardown' || name === 'requires') continue
if (options.test && !name.endsWith(options.test)) continue

const junitTestCase = junitTestSuite.testcase(name, `node_${process.version}: ${cleanPath}`)
Expand Down
5 changes: 5 additions & 0 deletions test/integration/test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,14 @@ function build (opts = {}) {
if (JSON.stringify(exc).includes('resource_already_exists_exception')) {
console.warn(`Resource already exists: ${JSON.stringify(cmd.params)}`)
// setup task was already done because cleanup didn't catch it? do nothing
} else if (JSON.stringify(exc).includes('api_not_available_exception')) {
// 410 api_not_available_exception should be ignored
console.warn(`API not available on serverless: ${cmd.method}`)
} else {
throw exc
}
}

let warnings = result ? result.warnings : null
const body = result ? result.body : null

Expand Down Expand Up @@ -881,6 +885,7 @@ async function deleteIndices(client) {
.trim()
.split('\n')
.map(row => row.split(' ')[2])
.filter(Boolean)
.filter(name => !name.startsWith('.'))
if (indexNames.length > 0) {
await client.indices.delete({
Expand Down

0 comments on commit e4e110e

Please sign in to comment.