Skip to content

Commit

Permalink
Add test for bulk insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
tdeo committed Feb 4, 2019
1 parent 48165b0 commit b1082f3
Showing 1 changed file with 51 additions and 23 deletions.
74 changes: 51 additions & 23 deletions test/acceptance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,6 @@ setTimeout(function () {
process.exit(1)
}, 60 * 1000).unref()

test('replaces date in index', { timeout }, (t) => {
t.plan(3)
const index = 'pinotest-%{DATE}'

const instance = elastic({ index, type, consistency, host, port })
const log = pino(instance)

log.info('hello world')

instance.on('insert', (obj, body) => {
t.ok('data uploaded')

client.get({
index: index.replace('%{DATE}', new Date().toISOString().substring(0, 10)),
type,
id: obj._id
}, (err, response) => {
t.error(err)
t.deepEqual(response._source, body, 'obj matches')
})
})
})

test('store a log line', { timeout }, (t) => {
t.plan(3)

Expand Down Expand Up @@ -134,3 +111,54 @@ test('store lines in bulk', { timeout }, (t) => {
}, refreshInterval)
})
})

test('replaces date in index', { timeout }, (t) => {
t.plan(3)
const index = 'pinotest-%{DATE}'

const instance = elastic({ index, type, consistency, host, port })
const log = pino(instance)

log.info('hello world')

instance.on('insert', (obj, body) => {
t.ok('data uploaded')

client.get({
index: index.replace('%{DATE}', new Date().toISOString().substring(0, 10)),
type,
id: obj._id
}, (err, response) => {
t.error(err)
t.deepEqual(response._source, body, 'obj matches')
})
})
})

test('replaces date in index during bulk insert', { timeout }, (t) => {
t.plan(15)

const index = 'pinotest-%{DATE}'
const instance = elastic({ index, type, consistency, host, port })
const log = pino(instance)

log.info('hello world')
log.info('hello world')
log.info('hello world')
log.info('hello world')
log.info('hello world')

instance.on('insert', (obj, body) => {
t.ok(obj, 'data uploaded')
setTimeout(function () {
client.get({
index: index.replace('%{DATE}', new Date().toISOString().substring(0, 10)),
type,
id: obj._id
}, (err, response) => {
t.error(err)
t.deepEqual(response._source, body, 'obj matches')
})
}, refreshInterval)
})
})

0 comments on commit b1082f3

Please sign in to comment.