Updated test

This commit is contained in:
delvedor
2019-03-13 16:11:47 +01:00
parent 0b739ea23c
commit a8c19984d6
3 changed files with 32 additions and 29 deletions

View File

@ -53,6 +53,8 @@ const platinumBlackList = {
'monitoring/bulk/10_basic.yml': '*', 'monitoring/bulk/10_basic.yml': '*',
'monitoring/bulk/20_privileges.yml': '*', 'monitoring/bulk/20_privileges.yml': '*',
'license/20_put_license.yml': '*', 'license/20_put_license.yml': '*',
// failing because `username` should not be there
'privileges/40_get_user_privs.yml': 'Test get_user_privileges for single role',
'snapshot/10_basic.yml': '*', 'snapshot/10_basic.yml': '*',
// the body is correct, but the regex is failing // the body is correct, but the regex is failing
'sql/sql.yml': 'Getting textual representation', 'sql/sql.yml': 'Getting textual representation',

View File

@ -105,34 +105,34 @@ TestRunner.prototype.cleanupPlatinum = function (q, done) {
this.tap.comment('Platinum Cleanup') this.tap.comment('Platinum Cleanup')
q.add((q, done) => { q.add((q, done) => {
this.client.security.getRole((err, { body }) => { this.client.xpack.security.getRole((err, { body }) => {
this.tap.error(err, 'should not error: security.getRole') this.tap.error(err, 'should not error: xpack.security.getRole')
const roles = Object.keys(body).filter(n => helper.esDefaultRoles.indexOf(n) === -1) const roles = Object.keys(body).filter(n => helper.esDefaultRoles.indexOf(n) === -1)
helper.runInParallel( helper.runInParallel(
this.client, 'security.deleteRole', this.client, 'xpack.security.deleteRole',
roles.map(r => ({ name: r, refresh: 'wait_for' })) roles.map(r => ({ name: r, refresh: 'wait_for' }))
) )
.then(() => done()) .then(() => done())
.catch(err => this.tap.error(err, 'should not error: security.deleteRole')) .catch(err => this.tap.error(err, 'should not error: xpack.security.deleteRole'))
}) })
}) })
q.add((q, done) => { q.add((q, done) => {
this.client.security.getUser((err, { body }) => { this.client.xpack.security.getUser((err, { body }) => {
this.tap.error(err, 'should not error: security.getUser') this.tap.error(err, 'should not error: xpack.security.getUser')
const users = Object.keys(body).filter(n => helper.esDefaultUsers.indexOf(n) === -1) const users = Object.keys(body).filter(n => helper.esDefaultUsers.indexOf(n) === -1)
helper.runInParallel( helper.runInParallel(
this.client, 'security.deleteUser', this.client, 'xpack.security.deleteUser',
users.map(r => ({ username: r, refresh: 'wait_for' })) users.map(r => ({ username: r, refresh: 'wait_for' }))
) )
.then(() => done()) .then(() => done())
.catch(err => this.tap.error(err, 'should not error: security.deleteUser')) .catch(err => this.tap.error(err, 'should not error: xpack.security.deleteUser'))
}) })
}) })
q.add((q, done) => { q.add((q, done) => {
this.client.security.getPrivileges((err, { body }) => { this.client.xpack.security.getPrivileges((err, { body }) => {
this.tap.error(err, 'should not error: security.getPrivileges') this.tap.error(err, 'should not error: xpack.security.getPrivileges')
const privileges = [] const privileges = []
Object.keys(body).forEach(app => { Object.keys(body).forEach(app => {
Object.keys(body[app]).forEach(priv => { Object.keys(body[app]).forEach(priv => {
@ -143,47 +143,47 @@ TestRunner.prototype.cleanupPlatinum = function (q, done) {
}) })
}) })
}) })
helper.runInParallel(this.client, 'security.deletePrivileges', privileges) helper.runInParallel(this.client, 'xpack.security.deletePrivileges', privileges)
.then(() => done()) .then(() => done())
.catch(err => this.tap.error(err, 'should not error: security.deletePrivileges')) .catch(err => this.tap.error(err, 'should not error: xpack.security.deletePrivileges'))
}) })
}) })
q.add((q, done) => { q.add((q, done) => {
this.client.ml.stopDatafeed({ datafeedId: '*', force: true }, err => { this.client.xpack.ml.stopDatafeed({ datafeedId: '*', force: true }, err => {
this.tap.error(err, 'should not error: ml.stopDatafeed') this.tap.error(err, 'should not error: xpack.ml.stopDatafeed')
this.client.ml.getDatafeeds({ datafeedId: '*' }, (err, { body }) => { this.client.xpack.ml.getDatafeeds({ datafeedId: '*' }, (err, { body }) => {
this.tap.error(err, 'should error: not ml.getDatafeeds') this.tap.error(err, 'should error: not xpack.ml.getDatafeeds')
const feeds = body.datafeeds.map(f => f.datafeed_id) const feeds = body.datafeeds.map(f => f.datafeed_id)
helper.runInParallel( helper.runInParallel(
this.client, 'ml.deleteDatafeed', this.client, 'xpack.ml.deleteDatafeed',
feeds.map(f => ({ datafeedId: f })) feeds.map(f => ({ datafeedId: f }))
) )
.then(() => done()) .then(() => done())
.catch(err => this.tap.error(err, 'should not error: ml.deleteDatafeed')) .catch(err => this.tap.error(err, 'should not error: xpack.ml.deleteDatafeed'))
}) })
}) })
}) })
q.add((q, done) => { q.add((q, done) => {
this.client.ml.closeJob({ jobId: '*', force: true }, err => { this.client.xpack.ml.closeJob({ jobId: '*', force: true }, err => {
this.tap.error(err, 'should not error: ml.closeJob') this.tap.error(err, 'should not error: xpack.ml.closeJob')
this.client.ml.getJobs({ jobId: '*' }, (err, { body }) => { this.client.xpack.ml.getJobs({ jobId: '*' }, (err, { body }) => {
this.tap.error(err, 'should not error: ml.getJobs') this.tap.error(err, 'should not error: xpack.ml.getJobs')
const jobs = body.jobs.map(j => j.job_id) const jobs = body.jobs.map(j => j.job_id)
helper.runInParallel( helper.runInParallel(
this.client, 'ml.deleteJob', this.client, 'xpack.ml.deleteJob',
jobs.map(j => ({ jobId: j, waitForCompletion: true, force: true })) jobs.map(j => ({ jobId: j, waitForCompletion: true, force: true }))
) )
.then(() => done()) .then(() => done())
.catch(err => this.tap.error(err, 'should not error: ml.deleteJob')) .catch(err => this.tap.error(err, 'should not error: xpack.ml.deleteJob'))
}) })
}) })
}) })
q.add((q, done) => { q.add((q, done) => {
this.client.xpack.rollup.getJobs({ id: '_all' }, (err, { body }) => { this.client.xpack.rollup.getJobs({ id: '_all' }, (err, { body }) => {
this.tap.error(err, 'should not error: rollup.getJobs') this.tap.error(err, 'should not error: xpack.rollup.getJobs')
const jobs = body.jobs.map(j => j.config.id) const jobs = body.jobs.map(j => j.config.id)
helper.runInParallel( helper.runInParallel(
this.client, 'xpack.rollup.stopJob', this.client, 'xpack.rollup.stopJob',
@ -194,7 +194,7 @@ TestRunner.prototype.cleanupPlatinum = function (q, done) {
jobs.map(j => ({ id: j })) jobs.map(j => ({ id: j }))
)) ))
.then(() => done()) .then(() => done())
.catch(err => this.tap.error(err, 'should not error: rollup.stopJob/deleteJob')) .catch(err => this.tap.error(err, 'should not error: xpack.rollup.stopJob/deleteJob'))
}) })
}) })
@ -255,11 +255,11 @@ TestRunner.prototype.run = function (setup, test, teardown, end) {
this.tap.comment('Creating x-pack user') this.tap.comment('Creating x-pack user')
// Some platinum test requires this user // Some platinum test requires this user
this.q.add((q, done) => { this.q.add((q, done) => {
this.client.security.putUser({ this.client.xpack.security.putUser({
username: 'x_pack_rest_user', username: 'x_pack_rest_user',
body: { password: 'x-pack-test-password', roles: ['superuser'] } body: { password: 'x-pack-test-password', roles: ['superuser'] }
}, (err, { body }) => { }, (err, { body }) => {
this.tap.error(err, 'should not error: security.putUser') this.tap.error(err, 'should not error: xpack.security.putUser')
done() done()
}) })
}) })
@ -539,7 +539,7 @@ TestRunner.prototype.do = function (action, done) {
this.response = err.body this.response = err.body
} }
} else { } else {
this.tap.error(err, `should not error: ${cmd.method}`, action) this.tap.error(err && err.body ? err.body : err, `should not error: ${cmd.method}`, action)
this.response = body this.response = body
} }

View File

@ -66,6 +66,7 @@ function runAsyncTest (test) {
try { try {
await client.index({ await client.index({
index: 'test', index: 'test',
type: 'test',
body: { foo: 'bar' } body: { foo: 'bar' }
}) })
t.pass('ok') t.pass('ok')