-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflood.js
More file actions
62 lines (54 loc) · 2.02 KB
/
Copy pathflood.js
File metadata and controls
62 lines (54 loc) · 2.02 KB
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
59
60
61
62
const amqp = require('amqplib')
// const AMQP_URL = '' // Add your rabbitmq connection string
const queueName = 'test'
const x = amqp.connect(AMQP_URL).then(async(conn) => {
console.log('amqp.connected!')
const channel = await conn.createChannel()
await channel.assertQueue(queueName)
const arrayProvider = ['car2go', 'drivenow', 'muving', 'emio', 'eddy', 'scout']
var arrayCity = ['berlin','dusseldorf','munich','frankfurt']
const totalFlood = 100000;
for (var i = 1; i<=totalFlood; i++) {
var startTime = Date.now() - Math.floor(Math.random() * Math.floor(30 * 24 * 60 * 60 * 1000));
var endTime = startTime + Math.floor(Math.random() * Math.floor(2 * 60 * 1000));
var provider = arrayProvider[Math.floor(Math.random() * arrayProvider.length)]
const city = arrayCity[Math.floor(Math.random() * arrayCity.length)]
const carId = Math.floor(Math.random() * Math.floor(1000))
let travelledDistanceMeters = Math.floor(Math.random() * Math.floor(30000));
const elapsedTimeMinutes = Math.floor(Math.random() * Math.floor(60));
console.log(`${i}-${totalFlood}`);
channel.sendToQueue(queueName, new Buffer(JSON.stringify({
"@timestamp": startTime,
"id": `${provider}-${carId}`,
"provider": provider,
"type": "local",
"vehicle": {
"id": carId,
"kind": "Car",
"numberplate": "ABC123",
"transmission": "Automatic",
"engine": "Electric"
},
"start": {
"city": city,
"country": "de",
"@timestamp": startTime
},
"end": {
"city": city,
"country": "de",
"@timestamp": endTime
},
"summary": {
"travelledDistanceMeters": travelledDistanceMeters,
"elapsedTimeMinutes": elapsedTimeMinutes,
}
})
))
}
setTimeout(() => {
process.exit(0)
}, 10000)
}).catch((err) => {
console.log(err)
})