Added integration test stats (#1083)
This commit is contained in:
committed by
delvedor
parent
a91e5375ac
commit
874b04f819
@ -20,7 +20,7 @@ const xPackYamlFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resou
|
|||||||
|
|
||||||
const MAX_API_TIME = 1000 * 90
|
const MAX_API_TIME = 1000 * 90
|
||||||
const MAX_FILE_TIME = 1000 * 30
|
const MAX_FILE_TIME = 1000 * 30
|
||||||
const MAX_TEST_TIME = 1000 * 2
|
const MAX_TEST_TIME = 1000 * 3
|
||||||
|
|
||||||
const ossSkips = {
|
const ossSkips = {
|
||||||
'cat.indices/10_basic.yml': ['Test cat indices output for closed index (pre 7.2.0)'],
|
'cat.indices/10_basic.yml': ['Test cat indices output for closed index (pre 7.2.0)'],
|
||||||
@ -111,6 +111,12 @@ async function start ({ client, isXPack }) {
|
|||||||
|
|
||||||
log(`Testing ${isXPack ? 'XPack' : 'oss'} api...`)
|
log(`Testing ${isXPack ? 'XPack' : 'oss'} api...`)
|
||||||
|
|
||||||
|
const stats = {
|
||||||
|
total: 0,
|
||||||
|
skip: 0,
|
||||||
|
pass: 0,
|
||||||
|
assertions: 0
|
||||||
|
}
|
||||||
const folders = getAllFiles(isXPack ? xPackYamlFolder : yamlFolder)
|
const folders = getAllFiles(isXPack ? xPackYamlFolder : yamlFolder)
|
||||||
.filter(t => !/(README|TODO)/g.test(t))
|
.filter(t => !/(README|TODO)/g.test(t))
|
||||||
// we cluster the array based on the folder names,
|
// we cluster the array based on the folder names,
|
||||||
@ -172,10 +178,15 @@ async function start ({ client, isXPack }) {
|
|||||||
const testTime = now()
|
const testTime = now()
|
||||||
const name = Object.keys(test)[0]
|
const name = Object.keys(test)[0]
|
||||||
if (name === 'setup' || name === 'teardown') continue
|
if (name === 'setup' || name === 'teardown') continue
|
||||||
if (shouldSkip(isXPack, file, name)) continue
|
stats.total += 1
|
||||||
|
if (shouldSkip(isXPack, file, name)) {
|
||||||
|
stats.skip += 1
|
||||||
|
continue
|
||||||
|
}
|
||||||
log(' - ' + name)
|
log(' - ' + name)
|
||||||
try {
|
try {
|
||||||
await testRunner.run(setupTest, test[name], teardownTest)
|
await testRunner.run(setupTest, test[name], teardownTest, stats)
|
||||||
|
stats.pass += 1
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
@ -202,6 +213,12 @@ async function start ({ client, isXPack }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log(`Total testing time: ${ms(now() - totalTime)}`)
|
log(`Total testing time: ${ms(now() - totalTime)}`)
|
||||||
|
log(`Test stats:
|
||||||
|
- Total: ${stats.total}
|
||||||
|
- Skip: ${stats.skip}
|
||||||
|
- Pass: ${stats.pass}
|
||||||
|
- Assertions: ${stats.assertions}
|
||||||
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function log (text) {
|
function log (text) {
|
||||||
|
|||||||
@ -214,7 +214,7 @@ function build (opts = {}) {
|
|||||||
* @oaram {object} teardown (null if not needed)
|
* @oaram {object} teardown (null if not needed)
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async function run (setup, test, teardown) {
|
async function run (setup, test, teardown, stats) {
|
||||||
// if we should skip a feature in the setup/teardown section
|
// if we should skip a feature in the setup/teardown section
|
||||||
// we should skip the entire test file
|
// we should skip the entire test file
|
||||||
const skip = getSkip(setup) || getSkip(teardown)
|
const skip = getSkip(setup) || getSkip(teardown)
|
||||||
@ -236,11 +236,11 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setup) await exec('Setup', setup)
|
if (setup) await exec('Setup', setup, stats)
|
||||||
|
|
||||||
await exec('Test', test)
|
await exec('Test', test, stats)
|
||||||
|
|
||||||
if (teardown) await exec('Teardown', teardown)
|
if (teardown) await exec('Teardown', teardown, stats)
|
||||||
|
|
||||||
if (isXPack) await cleanupXPack()
|
if (isXPack) await cleanupXPack()
|
||||||
|
|
||||||
@ -371,9 +371,14 @@ function build (opts = {}) {
|
|||||||
* @param {object} the action to perform
|
* @param {object} the action to perform
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async function doAction (action) {
|
async function doAction (action, stats) {
|
||||||
const cmd = parseDo(action)
|
const cmd = parseDo(action)
|
||||||
const api = delve(client, cmd.method).bind(client)
|
try {
|
||||||
|
var api = delve(client, cmd.method).bind(client)
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`\nError: Cannot find the method '${cmd.method}' in the client.\n`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
const options = { ignore: cmd.params.ignore, headers: action.headers }
|
const options = { ignore: cmd.params.ignore, headers: action.headers }
|
||||||
if (cmd.params.ignore) delete cmd.params.ignore
|
if (cmd.params.ignore) delete cmd.params.ignore
|
||||||
@ -414,10 +419,12 @@ function build (opts = {}) {
|
|||||||
warnings = warnings.filter(h => !h.test(/default\snumber\sof\sshards/g))
|
warnings = warnings.filter(h => !h.test(/default\snumber\sof\sshards/g))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stats.assertions += 1
|
||||||
assert.ok(deepEqual(warnings, action.warnings))
|
assert.ok(deepEqual(warnings, action.warnings))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.catch) {
|
if (action.catch) {
|
||||||
|
stats.assertions += 1
|
||||||
assert.ok(
|
assert.ok(
|
||||||
parseDoError(err, action.catch),
|
parseDoError(err, action.catch),
|
||||||
`the error should be: ${action.catch}`
|
`the error should be: ${action.catch}`
|
||||||
@ -428,6 +435,7 @@ function build (opts = {}) {
|
|||||||
response = err.body
|
response = err.body
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
stats.assertions += 1
|
||||||
assert.ifError(err, `should not error: ${cmd.method}`, action)
|
assert.ifError(err, `should not error: ${cmd.method}`, action)
|
||||||
response = body
|
response = body
|
||||||
}
|
}
|
||||||
@ -439,7 +447,7 @@ function build (opts = {}) {
|
|||||||
* @param {object} the actions to perform
|
* @param {object} the actions to perform
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
async function exec (name, actions) {
|
async function exec (name, actions, stats) {
|
||||||
// tap.comment(name)
|
// tap.comment(name)
|
||||||
for (const action of actions) {
|
for (const action of actions) {
|
||||||
if (action.skip) {
|
if (action.skip) {
|
||||||
@ -450,7 +458,7 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.do) {
|
if (action.do) {
|
||||||
await doAction(fillStashedValues(action.do))
|
await doAction(fillStashedValues(action.do), stats)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.set) {
|
if (action.set) {
|
||||||
@ -464,6 +472,7 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.match) {
|
if (action.match) {
|
||||||
|
stats.assertions += 1
|
||||||
const key = Object.keys(action.match)[0]
|
const key = Object.keys(action.match)[0]
|
||||||
match(
|
match(
|
||||||
// in some cases, the yaml refers to the body with an empty string
|
// in some cases, the yaml refers to the body with an empty string
|
||||||
@ -478,6 +487,7 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.lt) {
|
if (action.lt) {
|
||||||
|
stats.assertions += 1
|
||||||
const key = Object.keys(action.lt)[0]
|
const key = Object.keys(action.lt)[0]
|
||||||
lt(
|
lt(
|
||||||
delve(response, fillStashedValues(key)),
|
delve(response, fillStashedValues(key)),
|
||||||
@ -486,6 +496,7 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.gt) {
|
if (action.gt) {
|
||||||
|
stats.assertions += 1
|
||||||
const key = Object.keys(action.gt)[0]
|
const key = Object.keys(action.gt)[0]
|
||||||
gt(
|
gt(
|
||||||
delve(response, fillStashedValues(key)),
|
delve(response, fillStashedValues(key)),
|
||||||
@ -494,6 +505,7 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.lte) {
|
if (action.lte) {
|
||||||
|
stats.assertions += 1
|
||||||
const key = Object.keys(action.lte)[0]
|
const key = Object.keys(action.lte)[0]
|
||||||
lte(
|
lte(
|
||||||
delve(response, fillStashedValues(key)),
|
delve(response, fillStashedValues(key)),
|
||||||
@ -502,6 +514,7 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.gte) {
|
if (action.gte) {
|
||||||
|
stats.assertions += 1
|
||||||
const key = Object.keys(action.gte)[0]
|
const key = Object.keys(action.gte)[0]
|
||||||
gte(
|
gte(
|
||||||
delve(response, fillStashedValues(key)),
|
delve(response, fillStashedValues(key)),
|
||||||
@ -510,6 +523,7 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.length) {
|
if (action.length) {
|
||||||
|
stats.assertions += 1
|
||||||
const key = Object.keys(action.length)[0]
|
const key = Object.keys(action.length)[0]
|
||||||
length(
|
length(
|
||||||
key === '$body' || key === ''
|
key === '$body' || key === ''
|
||||||
@ -522,6 +536,7 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.is_true) {
|
if (action.is_true) {
|
||||||
|
stats.assertions += 1
|
||||||
const isTrue = fillStashedValues(action.is_true)
|
const isTrue = fillStashedValues(action.is_true)
|
||||||
is_true(
|
is_true(
|
||||||
delve(response, isTrue),
|
delve(response, isTrue),
|
||||||
@ -530,6 +545,7 @@ function build (opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.is_false) {
|
if (action.is_false) {
|
||||||
|
stats.assertions += 1
|
||||||
const isFalse = fillStashedValues(action.is_false)
|
const isFalse = fillStashedValues(action.is_false)
|
||||||
is_false(
|
is_false(
|
||||||
delve(response, isFalse),
|
delve(response, isFalse),
|
||||||
|
|||||||
Reference in New Issue
Block a user