Update load-cluster.js

This commit is contained in:
Aleksandr Statciuk 2022-02-07 06:18:31 +03:00
parent 002d8804df
commit c7dc04e1bb
4 changed files with 9 additions and 8 deletions

View File

@ -51,7 +51,7 @@ jobs:
with:
node-version: '14'
- run: npm install
- run: node scripts/commands/load-streams.js --cluster-id=${{ matrix.cluster_id }}
- run: node scripts/commands/load-cluster.js --cluster-id=${{ matrix.cluster_id }}
- uses: actions/upload-artifact@v2
with:
name: logs

View File

@ -15,7 +15,7 @@ const config = {
debug: options.debug
}
const LOGS_PATH = process.env.LOGS_PATH || 'scripts/logs/load-streams'
const LOGS_DIR = process.env.LOGS_DIR || 'scripts/logs/load-cluster'
async function main() {
logger.info('starting...')
@ -23,11 +23,12 @@ async function main() {
logger.info(`delay: ${options.delay}ms`)
timer.start()
const clusterLog = `${LOGS_PATH}/cluster_${options.clusterId}.log`
const clusterLog = `${LOGS_DIR}/cluster_${options.clusterId}.log`
logger.info(`loading cluster: ${options.clusterId}`)
logger.info(`creating '${clusterLog}'...`)
await file.create(clusterLog)
const items = await db.find({ cluster_id: options.clusterId })
await db.streams.load()
const items = await db.streams.find({ cluster_id: options.clusterId })
const total = items.length
logger.info(`found ${total} links`)

View File

@ -5,17 +5,17 @@ const { execSync } = require('child_process')
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
fs.emptyDirSync('tests/__data__/temp')
fs.copyFileSync('tests/__data__/input/streams.db', 'tests/__data__/temp/streams.db')
fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/temp/streams.db')
const stdout = execSync(
'DB_FILEPATH=tests/__data__/temp/streams.db LOGS_PATH=tests/__data__/output/logs/load-streams node scripts/commands/load-streams.js --cluster-id=1 --timeout=1',
'DB_DIR=tests/__data__/temp LOGS_DIR=tests/__data__/output/logs/load-cluster node scripts/commands/load-cluster.js --cluster-id=1 --timeout=1',
{ encoding: 'utf8' }
)
})
it('return results', () => {
let output = content('tests/__data__/output/logs/load-streams/cluster_1.log')
let expected = content('tests/__data__/expected/logs/load-streams/cluster_1.log')
let output = content('tests/__data__/output/logs/load-cluster/cluster_1.log')
let expected = content('tests/__data__/expected/logs/load-cluster/cluster_1.log')
expect(output).toEqual(expected)
})