Updated test

This commit is contained in:
delvedor
2019-02-19 08:31:09 +01:00
parent 98e8bbd63d
commit bcf895294b
3 changed files with 75 additions and 6 deletions

View File

@ -53,6 +53,20 @@ TestRunner.prototype.cleanup = function (q, done) {
})
})
q.add((q, done) => {
this.client.snapshot.delete({ repository: '*', snapshot: '*' }, { ignore: 404 }, err => {
this.tap.error(err, 'should not error:snapshot.delete')
done()
})
})
q.add((q, done) => {
this.client.snapshot.deleteRepository({ repository: '*' }, { ignore: 404 }, err => {
this.tap.error(err, 'should not error:snapshot.deleteRepository')
done()
})
})
done()
}

View File

@ -496,3 +496,30 @@ test('Extend client APIs', t => {
t.end()
})
test('Elastic cloud config', t => {
t.plan(1)
const client = new Client({
cloud: {
// 'localhost$abcd$efgh'
id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==',
username: 'elastic',
password: 'changeme'
}
})
const pool = client.connectionPool
t.match(pool.connections.get('https://abcd.localhost/'), {
url: new URL('https://elastic:changeme@abcd.localhost'),
id: 'https://abcd.localhost/',
ssl: null,
deadCount: 0,
resurrectTimeout: 0,
roles: {
master: true,
data: true,
ingest: true,
ml: false
}
})
})

View File

@ -47,7 +47,7 @@ test('API', t => {
})
t.test('markDead', t => {
const pool = new ConnectionPool({ Connection })
const pool = new ConnectionPool({ Connection, sniffEnabled: true })
const href = 'http://localhost:9200/'
var connection = pool.addConnection(href)
pool.markDead(connection)
@ -73,7 +73,7 @@ test('API', t => {
})
t.test('markAlive', t => {
const pool = new ConnectionPool({ Connection })
const pool = new ConnectionPool({ Connection, sniffEnabled: true })
const href = 'http://localhost:9200/'
var connection = pool.addConnection(href)
pool.markDead(connection)
@ -92,7 +92,8 @@ test('API', t => {
const pool = new ConnectionPool({
resurrectStrategy: 'ping',
pingTimeout: 3000,
Connection: MockConnection
Connection: MockConnection,
sniffEnabled: true
})
const href = 'http://localhost:9200/'
var connection = pool.addConnection(href)
@ -112,7 +113,8 @@ test('API', t => {
const pool = new ConnectionPool({
resurrectStrategy: 'ping',
pingTimeout: 3000,
Connection: MockConnectionTimeout
Connection: MockConnectionTimeout,
sniffEnabled: true
})
const href = 'http://localhost:9200/'
var connection = pool.addConnection(href)
@ -134,7 +136,8 @@ test('API', t => {
t.test('optimistic strategy', t => {
const pool = new ConnectionPool({
resurrectStrategy: 'optimistic',
Connection
Connection,
sniffEnabled: true
})
const href = 'http://localhost:9200/'
var connection = pool.addConnection(href)
@ -153,7 +156,8 @@ test('API', t => {
t.test('none strategy', t => {
const pool = new ConnectionPool({
resurrectStrategy: 'none',
Connection
Connection,
sniffEnabled: true
})
const href = 'http://localhost:9200/'
var connection = pool.addConnection(href)
@ -567,3 +571,27 @@ test('Node filter', t => {
t.end()
})
test('Single node behavior', t => {
t.test('sniffing disabled (markDead and markAlive should be noop)', t => {
t.plan(2)
const pool = new ConnectionPool({ Connection, sniffEnabled: false })
const conn = pool.addConnection('http://localhost:9200/')
pool.markDead(conn)
t.strictEqual(pool.dead.length, 0)
pool.markAlive(conn)
t.strictEqual(pool.dead.length, 0)
})
t.test('sniffing enabled (markDead and markAlive should work)', t => {
t.plan(2)
const pool = new ConnectionPool({ Connection, sniffEnabled: true })
const conn = pool.addConnection('http://localhost:9200/')
pool.markDead(conn)
t.strictEqual(pool.dead.length, 1)
pool.markAlive(conn)
t.strictEqual(pool.dead.length, 0)
})
t.end()
})