Drop node v10 support (#1471)

This commit is contained in:
Tomas Della Vedova
2021-05-20 16:16:45 +02:00
committed by GitHub
parent 507ed99e74
commit c64152b9b3
33 changed files with 655 additions and 668 deletions

View File

@ -30,7 +30,7 @@ test('API', t => {
const href = 'http://localhost:9200/'
pool.addConnection(href)
t.ok(pool.connections.find(c => c.id === href) instanceof Connection)
t.strictEqual(pool.connections.find(c => c.id === href).status, Connection.statuses.ALIVE)
t.equal(pool.connections.find(c => c.id === href).status, Connection.statuses.ALIVE)
t.end()
})
@ -42,7 +42,7 @@ test('API', t => {
pool.addConnection(href)
t.fail('Should throw')
} catch (err) {
t.is(err.message, `Connection with id '${href}' is already present`)
t.equal(err.message, `Connection with id '${href}' is already present`)
}
t.end()
})
@ -52,8 +52,8 @@ test('API', t => {
const href = 'http://us"er:p@assword@localhost:9200/'
pool.addConnection(href)
const conn = pool.connections[0]
t.strictEqual(conn.url.username, 'us%22er')
t.strictEqual(conn.url.password, 'p%40assword')
t.equal(conn.url.username, 'us%22er')
t.equal(conn.url.password, 'p%40assword')
t.match(conn.headers, {
authorization: 'Basic ' + Buffer.from('us"er:p@assword').toString('base64')
})
@ -66,7 +66,7 @@ test('API', t => {
let connection = pool.addConnection(href)
t.same(pool.markDead(connection), pool)
connection = pool.connections.find(c => c.id === href)
t.strictEqual(connection.status, Connection.statuses.ALIVE)
t.equal(connection.status, Connection.statuses.ALIVE)
t.end()
})
@ -76,7 +76,7 @@ test('API', t => {
let connection = pool.addConnection(href)
t.same(pool.markAlive(connection), pool)
connection = pool.connections.find(c => c.id === href)
t.strictEqual(connection.status, Connection.statuses.ALIVE)
t.equal(connection.status, Connection.statuses.ALIVE)
t.end()
})
@ -88,7 +88,7 @@ test('API', t => {
pool.getConnection()
t.fail('Should fail')
} catch (err) {
t.is(err.message, 'getConnection must be implemented')
t.equal(err.message, 'getConnection must be implemented')
}
t.end()
})
@ -98,7 +98,7 @@ test('API', t => {
const href = 'http://localhost:9200/'
const connection = pool.addConnection(href)
pool.removeConnection(connection)
t.strictEqual(pool.size, 0)
t.equal(pool.size, 0)
t.end()
})
@ -107,7 +107,7 @@ test('API', t => {
pool.addConnection('http://localhost:9200/')
pool.addConnection('http://localhost:9201/')
pool.empty(() => {
t.strictEqual(pool.size, 0)
t.equal(pool.size, 0)
t.end()
})
})
@ -115,7 +115,7 @@ test('API', t => {
t.test('urlToHost', t => {
const pool = new BaseConnectionPool({ Connection })
const url = 'http://localhost:9200'
t.deepEqual(
t.same(
pool.urlToHost(url),
{ url: new URL(url) }
)
@ -140,7 +140,7 @@ test('API', t => {
}
}
t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{
t.same(pool.nodesToHost(nodes, 'http:'), [{
url: new URL('http://127.0.0.1:9200'),
id: 'a1',
roles: {
@ -160,8 +160,8 @@ test('API', t => {
}
}])
t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, '127.0.0.1:9200')
t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, '127.0.0.1:9201')
t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, '127.0.0.1:9200')
t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, '127.0.0.1:9201')
t.end()
})
@ -182,7 +182,7 @@ test('API', t => {
}
}
t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{
t.same(pool.nodesToHost(nodes, 'http:'), [{
url: new URL('http://[::1]:9200'),
id: 'a1',
roles: {
@ -202,8 +202,8 @@ test('API', t => {
}
}])
t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, '[::1]:9200')
t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, '[::1]:9201')
t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, '[::1]:9200')
t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, '[::1]:9201')
t.end()
})
@ -224,7 +224,7 @@ test('API', t => {
}
}
t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{
t.same(pool.nodesToHost(nodes, 'http:'), [{
url: new URL('http://example.com:9200'),
id: 'a1',
roles: {
@ -244,8 +244,8 @@ test('API', t => {
}
}])
t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200')
t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201')
t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200')
t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201')
t.end()
})
@ -266,7 +266,7 @@ test('API', t => {
}
}
t.deepEqual(pool.nodesToHost(nodes, 'http:'), [{
t.same(pool.nodesToHost(nodes, 'http:'), [{
url: new URL('http://example.com:9200'),
id: 'a1',
roles: {
@ -286,8 +286,8 @@ test('API', t => {
}
}])
t.strictEqual(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200')
t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201')
t.equal(pool.nodesToHost(nodes, 'http:')[0].url.host, 'example.com:9200')
t.equal(pool.nodesToHost(nodes, 'http:')[1].url.host, 'example.com:9201')
t.end()
})
@ -308,8 +308,8 @@ test('API', t => {
}
}
t.strictEqual(pool.nodesToHost(nodes, 'https:')[0].url.protocol, 'https:')
t.strictEqual(pool.nodesToHost(nodes, 'http:')[1].url.protocol, 'http:')
t.equal(pool.nodesToHost(nodes, 'https:')[0].url.protocol, 'https:')
t.equal(pool.nodesToHost(nodes, 'http:')[1].url.protocol, 'http:')
t.end()
})
@ -425,13 +425,13 @@ test('API', t => {
// roles will never be updated, we only use it to do
// a dummy check to see if the connection has been updated
t.deepEqual(pool.connections.find(c => c.id === 'a1').roles, {
t.same(pool.connections.find(c => c.id === 'a1').roles, {
master: true,
data: true,
ingest: true,
ml: false
})
t.strictEqual(pool.connections.find(c => c.id === 'http://127.0.0.1:9200/'), undefined)
t.equal(pool.connections.find(c => c.id === 'http://127.0.0.1:9200/'), undefined)
})
t.test('Add a new connection', t => {
@ -480,9 +480,9 @@ test('API', t => {
roles: null
}])
t.false(pool.connections.find(c => c.id === 'a1'))
t.true(pool.connections.find(c => c.id === 'a2'))
t.true(pool.connections.find(c => c.id === 'a3'))
t.notOk(pool.connections.find(c => c.id === 'a1'))
t.ok(pool.connections.find(c => c.id === 'a2'))
t.ok(pool.connections.find(c => c.id === 'a3'))
})
t.end()
@ -497,7 +497,7 @@ test('API', t => {
pool.createConnection('http://localhost:9200')
t.fail('Should throw')
} catch (err) {
t.is(err.message, 'Connection with id \'http://localhost:9200/\' is already present')
t.equal(err.message, 'Connection with id \'http://localhost:9200/\' is already present')
}
})