Improve code coverage (#1124)
* Helpers: Fixed stats counting * Improve code coverage
This commit is contained in:
committed by
GitHub
parent
f99fe71b67
commit
85616b07ef
@ -229,10 +229,12 @@ class Helpers {
|
||||
chunkBytes += Buffer.byteLength(actionBody) + Buffer.byteLength(payloadBody)
|
||||
bulkBody.push(actionBody)
|
||||
bulkBody.push(payloadBody)
|
||||
} else { // delete
|
||||
} else if (operation === 'delete') {
|
||||
actionBody = serialize(action)
|
||||
chunkBytes += Buffer.byteLength(actionBody)
|
||||
bulkBody.push(actionBody)
|
||||
} else {
|
||||
throw new ConfigurationError(`Bulk helper invalid action: '${operation}'`)
|
||||
}
|
||||
|
||||
if (chunkBytes >= flushBytes) {
|
||||
@ -315,6 +317,7 @@ class Helpers {
|
||||
}
|
||||
|
||||
function send (bulkBody) {
|
||||
/* istanbul ignore if */
|
||||
if (running >= concurrency) {
|
||||
throw new Error('Max concurrency reached')
|
||||
}
|
||||
@ -351,11 +354,12 @@ class Helpers {
|
||||
function retryDocuments (err, bulkBody) {
|
||||
if (err) return callback(err)
|
||||
if (shouldAbort === true) return callback()
|
||||
isRetrying = true
|
||||
|
||||
if (bulkBody.length > 0) {
|
||||
if (retryCount > 0) {
|
||||
isRetrying = true
|
||||
retryCount -= 1
|
||||
stats.retry += bulkBody.length
|
||||
setTimeout(tryBulk, wait, bulkBody, retryDocuments)
|
||||
return
|
||||
}
|
||||
@ -397,7 +401,6 @@ class Helpers {
|
||||
// a document, because it was not an error in the document itself,
|
||||
// but the ES node were handling too many operations.
|
||||
if (status === 429) {
|
||||
stats.retry += 1
|
||||
retry.push(bulkBody[indexSlice])
|
||||
if (operation !== 'delete') {
|
||||
retry.push(bulkBody[indexSlice + 1])
|
||||
|
||||
@ -49,6 +49,7 @@ class Transport {
|
||||
} else if (opts.nodeSelector === 'round-robin') {
|
||||
this.nodeSelector = roundRobinSelector()
|
||||
} else if (opts.nodeSelector === 'random') {
|
||||
/* istanbul ignore next */
|
||||
this.nodeSelector = randomSelector
|
||||
} else {
|
||||
this.nodeSelector = roundRobinSelector()
|
||||
|
||||
Reference in New Issue
Block a user