All files / Nodejs/test kinesisSpeedTest.js

0% Statements 0/21
0% Branches 0/4
0% Functions 0/3
0% Lines 0/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58                                                                                                                   
"use strict";
var leo = require("../index.js");
var moment = require("moment");
var async = require("async");
 
 
var stream = leo.load("KinesisSpeedTest", "KinesisSpeedTestQueue", {
	useS3: false,
	debug: true,
	autoDetectPayload: true,
	records: 0
});
 
 
let i = 0;
 
let queue = async.queue(function (task, callback) {
	let result = true;
	while (result) {
		i++;
		if (i % 50000 == 0) {
			console.log("Count", i)
		}
		result = stream.write({
			payload: {
				innerdata: Math.round(Math.random() * 100)
 
			},
			now: moment().format(),
			index: i,
			number: Math.round(Math.random() * 10000),
			v: 2,
			daolyap: {
				atadrenni: Math.round(Math.random() * 100)
 
			},
			won: moment().add({
				seconds: 30
			}).format(),
			xedni: i,
			rebmun: Math.round(Math.random() * 10000),
			version: 2
		});
	}
	if (!result) {
		console.log("Waiting for Drain")
		stream.once("drain", () => {
			console.log("Drain Done")
			queue.push({});
		});
	} else {
		queue.push({});
	}
	setTimeout(function () {
		callback();
	}, 1000);
}, 1);
queue.push({});